Previous 199869 Revisions Next

r37065 Wednesday 1st April, 2015 at 10:49:51 UTC by Zoë Blade
Merge branch 'master' of https://github.com/mamedev/mame
[/trunk].gitignore makefile
[3rdparty/bgfx].editorconfig README.md makefile
[3rdparty/bgfx/3rdparty/ocornut-imgui]imgui.cpp
[3rdparty/bgfx/3rdparty/sdf]sdf.h
[3rdparty/bgfx/3rdparty/stb]stb_image.c
[3rdparty/bgfx/examples/02-metaballs]metaballs.cpp
[3rdparty/bgfx/examples/05-instancing]instancing.cpp
[3rdparty/bgfx/examples/06-bump]bump.cpp
[3rdparty/bgfx/examples/07-callback]callback.cpp
[3rdparty/bgfx/examples/08-update]update.cpp
[3rdparty/bgfx/examples/09-hdr]hdr.cpp
[3rdparty/bgfx/examples/12-lod]lod.cpp
[3rdparty/bgfx/examples/13-stencil]stencil.cpp
[3rdparty/bgfx/examples/14-shadowvolumes]shadowvolumes.cpp
[3rdparty/bgfx/examples/15-shadowmaps-simple]shadowmaps_simple.cpp
[3rdparty/bgfx/examples/16-shadowmaps]shadowmaps.cpp
[3rdparty/bgfx/examples/20-nanovg]blendish.h nanovg.cpp
[3rdparty/bgfx/examples/21-deferred]deferred.cpp
[3rdparty/bgfx/examples/23-vectordisplay]main.cpp vectordisplay.cpp
[3rdparty/bgfx/examples/24-nbody]nbody.cpp
[3rdparty/bgfx/examples/25-c99]helloworld.c
[3rdparty/bgfx/examples/common]bounds.cpp
[3rdparty/bgfx/examples/common/entry]entry.cpp entry_glfw.cpp* entry_osx.mm entry_p.h
[3rdparty/bgfx/examples/common/nanovg]nanovg.cpp
[3rdparty/bgfx/examples/runtime].gitignore
[3rdparty/bgfx/include]bgfx.c99.h bgfx.h bgfxdefines.h bgfxplatform.h
[3rdparty/bgfx/scripts]bgfx.lua example-common.lua genie.lua
[3rdparty/bgfx/src]amalgamated.cpp* bgfx.cpp bgfx_p.h glcontext_eagl.h glcontext_eagl.mm glcontext_egl.cpp glcontext_egl.h glcontext_glx.cpp glcontext_glx.h glcontext_nsgl.h glcontext_nsgl.mm glcontext_ppapi.cpp glcontext_ppapi.h glcontext_wgl.cpp glcontext_wgl.h image.cpp ovr.cpp ovr.h renderdoc.h renderer.h renderer_d3d11.cpp renderer_d3d11.h renderer_d3d12.cpp renderer_d3d9.cpp renderer_d3d9.h renderer_gl.cpp renderer_gl.h renderer_null.cpp renderer_vk.cpp
[3rdparty/bgfx/tools/geometryc]geometryc.cpp
[3rdparty/bgfx/tools/shaderc]shaderc.cpp shaderc_dx11.cpp
[3rdparty/bx/include/bx]handlealloc.h platform.h radixsort.h
[3rdparty/bx/scripts]toolchain.lua
[3rdparty/bx/tests]unordered_map_nonpod.cpp
[3rdparty/bx/tools/bin/darwin]genie
[3rdparty/bx/tools/bin/linux]genie
[3rdparty/bx/tools/bin/windows]genie.exe
[3rdparty/genie].gitignore README.md
[3rdparty/genie/build/gmake.darwin]genie.make
[3rdparty/genie/build/gmake.linux]genie.make
[3rdparty/genie/build/gmake.windows]genie.make
[3rdparty/genie/scripts]genie.lua
[3rdparty/genie/src/actions/make]make_cpp.lua
[3rdparty/genie/src/actions/vstudio]vs2010_vcxproj.lua
[3rdparty/genie/src/base]api.lua bake.lua inspect.lua table.lua
[3rdparty/genie/src/host]os_ticks.c* premake.c premake.h scripts.c version.h
[3rdparty/genie/src/host/lua-5.2.3]Makefile README
[3rdparty/genie/src/host/lua-5.2.3/doc]contents.html logo.gif lua.1 lua.css luac.1 manual.css manual.html osi-certified-72x60.png readme.html
[3rdparty/genie/src/host/lua-5.2.3/src]Makefile lapi.c lapi.h lauxlib.c lauxlib.h lbaselib.c lbitlib.c lcode.c lcode.h lcorolib.c lctype.c lctype.h ldblib.c ldebug.c ldebug.h ldo.c ldo.h ldump.c lfunc.c lfunc.h lgc.c lgc.h linit.c liolib.c llex.c llex.h llimits.h lmathlib.c lmem.c lmem.h loadlib.c lobject.c lobject.h lopcodes.c lopcodes.h loslib.c lparser.c lparser.h lstate.c lstate.h lstring.c lstring.h lstrlib.c ltable.c ltable.h ltablib.c ltm.c ltm.h lua.c lua.h lua.hpp luac.c luaconf.h lualib.h lundump.c lundump.h lvm.c lvm.h lzio.c lzio.h
[3rdparty/genie/src/host/lua-5.3.0]Makefile* README*
[3rdparty/genie/src/host/lua-5.3.0/doc]contents.html* logo.gif* lua.1* lua.css* luac.1* manual.css* manual.html* osi-certified-72x60.png* readme.html*
[3rdparty/genie/src/host/lua-5.3.0/src]Makefile* lapi.c* lapi.h* lauxlib.c* lauxlib.h* lbaselib.c* lbitlib.c* lcode.c* lcode.h* lcorolib.c* lctype.c* lctype.h* ldblib.c* ldebug.c* ldebug.h* ldo.c* ldo.h* ldump.c* lfunc.c* lfunc.h* lgc.c* lgc.h* linit.c* liolib.c* llex.c* llex.h* llimits.h* lmathlib.c* lmem.c* lmem.h* loadlib.c* lobject.c* lobject.h* lopcodes.c* lopcodes.h* loslib.c* lparser.c* lparser.h* lprefix.h* lstate.c* lstate.h* lstring.c* lstring.h* lstrlib.c* ltable.c* ltable.h* ltablib.c* ltm.c* ltm.h* lua.c* lua.h* lua.hpp* luac.c* luaconf.h* lualib.h* lundump.c* lundump.h* lutf8lib.c* lvm.c* lvm.h* lzio.c* lzio.h*
[3rdparty/genie/src/tools]gcc.lua
[docs]hlsl.txt
[hash]abc80.xml abc80_cass.xml* abc80_flop.xml* n64dd.xml nes.xml pasogo.xml pc88va.xml pet_rom.xml snread.xml*
[scripts]depfilter.awk* genie.lua* toolchain.lua*
[scripts/src]3rdparty.lua* bus.lua* cpu.lua* emu.lua* lib.lua* machine.lua* main.lua* netlist.lua* sound.lua* tools.lua* video.lua*
[scripts/src/osd]modules.lua* osdmini.lua* osdmini_cfg.lua* sdl.lua* sdl_cfg.lua* windows.lua* windows_cfg.lua*
[scripts/target/ldplayer]ldplayer.lua*
[scripts/target/mame]mame.lua* tiny.lua*
[scripts/target/mess]mess.lua* tiny.lua*
[scripts/target/ume]tiny.lua* ume.lua*
[src]version.c
[src/build]build.mak cc_detection.mak flags_clang.mak flags_gcc.mak verinfo.py
[src/emu]emu.mak emucore.h luaengine.c machine.c mame.c render.c video.c video.h
[src/emu/bus]bus.mak
[src/emu/bus/a2bus]ezcgi.c
[src/emu/bus/scsi]omti5100.c
[src/emu/cpu]cpu.mak
[src/emu/cpu/arm7]arm7ops.c
[src/emu/cpu/hmcs40]hmcs40.c hmcs40.h hmcs40d.c hmcs40op.inc
[src/emu/cpu/i386]i386ops.h pentops.inc
[src/emu/cpu/m68000]m68kcpu.h
[src/emu/cpu/mips]mips3.c mips3.h mips3drc.c
[src/emu/cpu/nec]v53.c v53.h
[src/emu/cpu/pic16c5x]pic16c5x.c pic16c5x.h
[src/emu/cpu/z80]kl5c80a12.c kl5c80a12.h
[src/emu/machine]am9517a.c am9517a.h corvushd.c i8251.c i8257.c machine.mak mcf5206e.c tmp68301.c upd71071.c vrc4373.c vrc4373.h
[src/emu/netlist]netlist.mak plists.h
[src/emu/sound]aica.c discrete.h es1373.h flt_rc.c iremga20.c l7a1045_l6028_dsp_a.c* l7a1045_l6028_dsp_a.h* okim9810.c okim9810.h sound.mak tms5220.c tms5220.h
[src/emu/ui]ui.c
[src/emu/video]tms34061.c video.mak voodoo_pci.c
[src/ldplayer]ldplayer.mak
[src/lib]lib.mak
[src/lib/formats]d88_dsk.c flex_dsk.c fmtowns_dsk.c nfd_dsk.c
[src/mame]mame.lst mame.mak tiny.mak
[src/mame/audio]dcs.c hng64.c
[src/mame/drivers]argus.c astrcorp.c cabal.c capbowl.c cocoloco.c cps2.c dynax.c fgoal.c flyball.c gambl186.c goldstar.c hexion.c hng64.c hotblock.c iteagle.c jankenmn.c jchan.c junofrst.c kinst.c m107.c m72.c madalien.c mainsnk.c mgolf.c mirax.c namcops2.c namcos23.c naomi.c neogeo.c neogeo_noslot.c niyanpai.c nmk16.c paradise.c peplus.c playmark.c portrait.c powerins.c ppmast93.c psychic5.c pturn.c re900.c rltennis.c rmhaihai.c route16.c sandscrp.c scobra.c seattle.c segas32.c seibuspi.c seicross.c seta.c seta2.c shougi.c sidearms.c simple_st0016.c sothello.c speglsht.c spool99.c srmp2.c srmp5.c srmp6.c srumbler.c sstrangr.c ssv.c stactics.c sub.c suna16.c suna8.c supdrapo.c supertnk.c superwng.c suprgolf.c suprslam.c tankbust.c taotaido.c tbowl.c tgtpanic.c thepit.c thunderx.c toaplan2.c tryout.c tsamurai.c ttchamp.c tugboat.c tunhunt.c twins.c unkhorse.c usgames.c vamphalf.c vegas.c vigilant.c wc90b.c xain.c xtheball.c zn.c
[src/mame/includes]argus.h bbusters.h cabal.h capbowl.h fgoal.h hng64.h ironhors.h m107.h m72.h mainsnk.h mosaic.h n64.h niyanpai.h paradise.h pooyan.h portrait.h powerins.h psychic5.h realbrk.h rltennis.h route16.h seta2.h shuuz.h sidearms.h simple_st0016.h speedbal.h srmp2.h srumbler.h ssozumo.h ssrj.h ssv.h stactics.h subs.h suna16.h suprloco.h suprridr.h tankbatt.h tankbust.h taotaido.h tbowl.h thepit.h thunderx.h timelimt.h tryout.h tsamurai.h tunhunt.h usgames.h vigilant.h vulgus.h wc90b.h
[src/mame/machine]cps2crpt.c hng64_net.c iteagle_fpga.c iteagle_fpga.h n64.c
[src/mame/video]bbusters.c deadang.c decmxc06.c dynax.c hng64.c hng64_3d.c hng64_sprite.c jalblend.c jalblend.h m107.c m72.c mainsnk.c niyanpai.c pc080sn.c portrait.c powerins.c psychic5.c realbrk.c rltennis.c route16.c seta001.c seta2.c sidearms.c srumbler.c ssv.c stactics.c suna16.c suprloco.c suprridr.c tankbust.c tbowl.c thedeep.c thepit.c timelimt.c tryout.c tsamurai.c tunhunt.c vulgus.c xain.c
[src/mess]mess.lst mess.mak messcore.mak tiny.mak
[src/mess/audio]gamate.c
[src/mess/drivers]a7800.c abc80.c alesis.c apple2.c apple2e.c gamate.c gba.c hh_hmcs40.c hh_pic16.c hh_tms1k.c hh_ucom4.c imds2.c mbdtower.c mpf1.c n64.c ngen.c pc88va.c snes.c ticalc1x.c tispeak.c
[src/mess/includes]abc80.h hh_tms1k.h imds2.h mpf1.h
[src/mess/layout]astro.lay* mbdtower.lay ssimon.lay
[src/mess/osd/windows]windows.mak
[src/mess/tools]tools.mak
[src/mess/tools/castool]castool.mak
[src/mess/tools/floptool]floptool.mak
[src/mess/tools/imgtool]imgtool.mak
[src/osd]eivc.h* eivcx86.h* eminline.h osdcomm.h osdcore.h strconv.c* strconv.h*
[src/osd/modules]osdwindow.h
[src/osd/modules/debugger]debugosx.m
[src/osd/modules/debugger/osx]debugview.m
[src/osd/modules/lib]osdobj_common.c
[src/osd/modules/netdev]pcap.c taptun.c
[src/osd/modules/opengl]gl_shader_mgr.c osd_opengl.h
[src/osd/modules/render]blit13.h draw13.c drawbgfx.c drawogl.c drawsdl.c
[src/osd/modules/sync]sync_ntc.c sync_os2.c sync_sdl.c sync_windows.c
[src/osd/osdmini]minimisc.c osdmini.mak
[src/osd/sdl]build.mak osdsdl.h osinline.h sdl.mak sdlfile.c sdlmain.c sdlprefix.h strconv.c strconv.h video.h watchdog.c window.c
[src/osd/windows]eivc.h eivcx86.h osinline.h strconv.c strconv.h video.h windows.mak winfile.c winprefix.h
[src/targets]mame.lst mess.lst ume.lst
[src/tools]tools.mak
[src/ume]tiny.lst* ume.mak
[src/ume/osd/windows]windows.mak

trunk/.gitignore
r245576r245577
1111/inp
1212/nvram
1313/obj
14/roms
1415/snap
1516src/regtests/chdman/temp
1617src/regtests/jedutil/output
1718/sta
1819*.pyc
20/build
No newline at end of file
trunk/3rdparty/bgfx/.editorconfig
r245576r245577
88insert_final_newline     = true
99trim_trailing_whitespace = true
1010
11[*.c99.h]
12indent_style = space
13
1114[*.md]
1215trim_trailing_whitespace = false
1316max_line_length = 80
trunk/3rdparty/bgfx/3rdparty/ocornut-imgui/imgui.cpp
r245576r245577
350350#pragma clang diagnostic ignored "-Wexit-time-destructors"  // warning : declaration requires an exit-time destructor       // exit-time destruction order is undefined. if MemFree() leads to users code that has been disabled before exit it might cause problems. ImGui coding style welcomes static/globals.
351351#pragma clang diagnostic ignored "-Wglobal-constructors"    // warning : declaration requires a global destructor           // similar to above, not sure what the exact difference it.
352352#pragma clang diagnostic ignored "-Wsign-conversion"        // warning : implicit conversion changes signedness             //
353#endif
354#ifdef __GNUC__
353#pragma clang diagnostic ignored "-Wunused-parameter"         // warning: unused parameter ‘xxxx’
354#elif defined(__GNUC__)
355355#pragma GCC diagnostic ignored "-Wunused-function"          // warning: 'xxxx' defined but not used
356356#pragma GCC diagnostic ignored "-Wunused-parameter"         // warning: unused parameter ‘xxxx’
357357#pragma GCC diagnostic ignored "-Wtype-limits"              // warning: comparison is always true due to limited range of data type
trunk/3rdparty/bgfx/3rdparty/sdf/sdf.h
r245576r245577
9292      } else if (a < (1.0-a1)) { // a1 <= a <= 1-a1
9393         df = (0.5f-a)*gx;
9494      } else { // 1-a1 < a <= 1
95         df = -0.5f*(gx + gy) + sqrt(2.0f*gx*gy*(1.0f-a));
95         df = -0.5f*(gx + gy) + sqrtf(2.0f*gx*gy*(1.0f-a));
9696      }
9797   }   
9898   return df;
trunk/3rdparty/bgfx/3rdparty/stb/stb_image.c
r245576r245577
187187
188188#ifndef STBI_NO_STDIO
189189
190#if defined(_MSC_VER) && _MSC_VER >= 1400 && !defined(_CRT_SECURE_NO_WARNINGS)
191#define _CRT_SECURE_NO_WARNINGS // suppress warnings about fopen()
192#pragma warning(push)
193#pragma warning(disable:4996)   // suppress even more warnings about fopen()
190#if defined(_MSC_VER) && _MSC_VER >= 1400
191#   if !defined(_CRT_SECURE_NO_WARNINGS)
192#      define _CRT_SECURE_NO_WARNINGS // suppress warnings about fopen()
193#   endif
194#   pragma warning(push)
195#   pragma warning(disable:4996)   // suppress even more warnings about fopen()
196#   pragma warning(disable:4312)   // warning C4312: 'type cast': conversion from 'int' to 'unsigned char *' of greater size
197#   pragma warning(disable:4456)   // warning C4456: declaration of 'k' hides previous local declaration
198#   pragma warning(disable:4457)   // warning C4457: declaration of 'y' hides function parameter
194199#endif
195200#include <stdio.h>
196201#endif // STBI_NO_STDIO
r245576r245577
32493254   unsigned char *tga_data;
32503255   unsigned char *tga_palette = NULL;
32513256   int i, j;
3252   unsigned char raw_data[4];
3257   unsigned char raw_data[4] = {};
32533258   int RLE_count = 0;
32543259   int RLE_repeating = 0;
32553260   int read_next_pixel = 1;
trunk/3rdparty/bgfx/README.md
r245576r245577
432432   linux-release32, nacl-debug64, nacl-arm-debug, pnacl-release,
433433   android-release, etc.
434434
435Amalgamated build
436-----------------
437
438For ease of integration to other build system bgfx library can be built with
439single .cpp file. It's only necessary to build [src/amalgamated.cpp](https://github.com/bkaradzic/bgfx/blob/master/src/amalgamated.cpp)
440inside different build system.
441
435442OculusVR integration
436443--------------------
437444
r245576r245577
568575
569576   genie --with-sdl vs2012
570577
578**NOTE** Special care is necessary to make custom windowing to work with
579multithreaded renderer. Each platform has rules about where renderer can be and
580how multithreading interacts with context/device. To disable multithreaded
581render use `BGFX_CONFIG_MULTITHREDED=0` preprocessor define.
582
571583Tools
572584-----
573585
trunk/3rdparty/bgfx/examples/02-metaballs/metaballs.cpp
r245576r245577
592592      float sphere[numSpheres][4];
593593      for (uint32_t ii = 0; ii < numSpheres; ++ii)
594594      {
595         sphere[ii][0] = sin(time*(ii*0.21f)+ii*0.37f) * (DIMS * 0.5f - 8.0f);
596         sphere[ii][1] = sin(time*(ii*0.37f)+ii*0.67f) * (DIMS * 0.5f - 8.0f);
597         sphere[ii][2] = cos(time*(ii*0.11f)+ii*0.13f) * (DIMS * 0.5f - 8.0f);
598         sphere[ii][3] = 1.0f/(2.0f + (sin(time*(ii*0.13f) )*0.5f+0.5f)*2.0f);
595         sphere[ii][0] = sinf(time*(ii*0.21f)+ii*0.37f) * (DIMS * 0.5f - 8.0f);
596         sphere[ii][1] = sinf(time*(ii*0.37f)+ii*0.67f) * (DIMS * 0.5f - 8.0f);
597         sphere[ii][2] = cosf(time*(ii*0.11f)+ii*0.13f) * (DIMS * 0.5f - 8.0f);
598         sphere[ii][3] = 1.0f/(2.0f + (sinf(time*(ii*0.13f) )*0.5f+0.5f)*2.0f);
599599      }
600600
601601      profUpdate = bx::getHPCounter();
trunk/3rdparty/bgfx/examples/05-instancing/instancing.cpp
r245576r245577
182182                  mtx[14] = 0.0f;
183183
184184                  float* color = (float*)&data[64];
185                  color[0] = sin(time+float(xx)/11.0f)*0.5f+0.5f;
186                  color[1] = cos(time+float(yy)/11.0f)*0.5f+0.5f;
187                  color[2] = sin(time*3.0f)*0.5f+0.5f;
185                  color[0] = sinf(time+float(xx)/11.0f)*0.5f+0.5f;
186                  color[1] = cosf(time+float(yy)/11.0f)*0.5f+0.5f;
187                  color[2] = sinf(time*3.0f)*0.5f+0.5f;
188188                  color[3] = 1.0f;
189189
190190                  data += instanceStride;
trunk/3rdparty/bgfx/examples/06-bump/bump.cpp
r245576r245577
192192
193193      float at[3]  = { 0.0f, 0.0f,  0.0f };
194194      float eye[3] = { 0.0f, 0.0f, -7.0f };
195     
195
196196      // Set view and projection matrix for view 0.
197197      const bgfx::HMD* hmd = bgfx::getHMD();
198198      if (NULL != hmd)
r245576r245577
227227      float lightPosRadius[4][4];
228228      for (uint32_t ii = 0; ii < numLights; ++ii)
229229      {
230         lightPosRadius[ii][0] = sin( (time*(0.1f + ii*0.17f) + ii*bx::piHalf*1.37f ) )*3.0f;
231         lightPosRadius[ii][1] = cos( (time*(0.2f + ii*0.29f) + ii*bx::piHalf*1.49f ) )*3.0f;
230         lightPosRadius[ii][0] = sinf( (time*(0.1f + ii*0.17f) + ii*bx::piHalf*1.37f ) )*3.0f;
231         lightPosRadius[ii][1] = cosf( (time*(0.2f + ii*0.29f) + ii*bx::piHalf*1.49f ) )*3.0f;
232232         lightPosRadius[ii][2] = -2.5f;
233233         lightPosRadius[ii][3] = 3.0f;
234234      }
r245576r245577
338338         }
339339      }
340340
341      // Advance to next frame. Rendering thread will be kicked to
341      // Advance to next frame. Rendering thread will be kicked to
342342      // process submitted rendering primitives.
343343      bgfx::frame();
344344   }
trunk/3rdparty/bgfx/examples/07-callback/callback.cpp
r245576r245577
372372
373373   bgfx::init(
374374        renderers[bx::getHPCounter() % numRenderers] /* randomize renderer */
375      , BGFX_PCI_ID_NONE
376      , 0
375377      , &callback  // custom callback handler
376378      , &allocator // custom allocator
377379      );
r245576r245577
442444
443445      float at[3] = { 0.0f, 0.0f, 0.0f };
444446      float eye[3] = { 0.0f, 0.0f, -35.0f };
445     
447
446448      float view[16];
447449      float proj[16];
448450      bx::mtxLookAt(view, eye, at);
r245576r245577
488490         bgfx::saveScreenShot("temp/frame150");
489491      }
490492
491      // Advance to next frame. Rendering thread will be kicked to
493      // Advance to next frame. Rendering thread will be kicked to
492494      // process submitted rendering primitives.
493495      bgfx::frame();
494496   }
trunk/3rdparty/bgfx/examples/08-update/update.cpp
r245576r245577
167167      }
168168   }
169169
170   bgfx::TextureHandle textures3d[] =
170   const bgfx::Caps* caps = bgfx::getCaps();
171   const bool texture3DSupported = !!(caps->supported & BGFX_CAPS_TEXTURE_3D);
172
173   uint32_t numTextures3d = 0;
174   bgfx::TextureHandle textures3d[3] = {};
175
176   if (texture3DSupported)
171177   {
172      bgfx::createTexture3D(32, 32, 32, 0, bgfx::TextureFormat::R8,   BGFX_TEXTURE_U_CLAMP|BGFX_TEXTURE_V_CLAMP|BGFX_TEXTURE_W_CLAMP, mem8),
173      bgfx::createTexture3D(32, 32, 32, 0, bgfx::TextureFormat::R16F, BGFX_TEXTURE_U_CLAMP|BGFX_TEXTURE_V_CLAMP|BGFX_TEXTURE_W_CLAMP, mem16f),
174      bgfx::createTexture3D(32, 32, 32, 0, bgfx::TextureFormat::R32F, BGFX_TEXTURE_U_CLAMP|BGFX_TEXTURE_V_CLAMP|BGFX_TEXTURE_W_CLAMP, mem32f),
175   };
178      if (0 != (BGFX_CAPS_FORMAT_TEXTURE_COLOR & caps->formats[bgfx::TextureFormat::R8]) )
179      {
180         textures3d[numTextures3d++] = bgfx::createTexture3D(32, 32, 32, 0, bgfx::TextureFormat::R8,   BGFX_TEXTURE_U_CLAMP|BGFX_TEXTURE_V_CLAMP|BGFX_TEXTURE_W_CLAMP, mem8);
181      }
176182
183      if (0 != (BGFX_CAPS_FORMAT_TEXTURE_COLOR & caps->formats[bgfx::TextureFormat::R16F]) )
184      {
185         textures3d[numTextures3d++] = bgfx::createTexture3D(32, 32, 32, 0, bgfx::TextureFormat::R16F, BGFX_TEXTURE_U_CLAMP|BGFX_TEXTURE_V_CLAMP|BGFX_TEXTURE_W_CLAMP, mem16f);
186      }
187
188      if (0 != (BGFX_CAPS_FORMAT_TEXTURE_COLOR & caps->formats[bgfx::TextureFormat::R32F]) )
189      {
190         textures3d[numTextures3d++] = bgfx::createTexture3D(32, 32, 32, 0, bgfx::TextureFormat::R32F, BGFX_TEXTURE_U_CLAMP|BGFX_TEXTURE_V_CLAMP|BGFX_TEXTURE_W_CLAMP, mem32f);
191      }
192   }
193
177194   // Create static vertex buffer.
178195   bgfx::VertexBufferHandle vbh = bgfx::createVertexBuffer(bgfx::makeRef(s_cubeVertices, sizeof(s_cubeVertices) ), PosTexcoordVertex::ms_decl);
179196
r245576r245577
188205
189206   bgfx::ProgramHandle program     = loadProgram("vs_update", "fs_update");
190207   bgfx::ProgramHandle programCmp  = loadProgram("vs_update", "fs_update_cmp");
191   bgfx::ProgramHandle program3d   = loadProgram("vs_update", "fs_update_3d");
208   bgfx::ProgramHandle program3d   = BGFX_INVALID_HANDLE;
209   if (texture3DSupported)
210   {
211      program3d = loadProgram("vs_update", "fs_update_3d");
212   }
192213
193214   const uint32_t textureSide = 2048;
194215
r245576r245577
271292
272293            for (uint32_t ii = 0, num = bx::uint32_min(10, (uint32_t)quads.size() ); ii < num; ++ii)
273294            {
274               const PackCube& face = quads.front();
275               cube.clear(face);
295               cube.clear(quads.front() );
276296               quads.pop_front();
277297            }
278298         }
r245576r245577
399419         bgfx::submit(1);
400420      }
401421
402      for (uint32_t ii = 0; ii < BX_COUNTOF(textures3d); ++ii)
422      for (uint32_t ii = 0; ii < numTextures3d; ++ii)
403423      {
404424         bx::mtxTranslate(mtx, xpos + ii*2.1f, -4.0f, 0.0f);
405425
r245576r245577
465485      bgfx::destroyTexture(textures[ii]);
466486   }
467487
468   for (uint32_t ii = 0; ii < BX_COUNTOF(textures3d); ++ii)
488   for (uint32_t ii = 0; ii < numTextures3d; ++ii)
469489   {
470490      bgfx::destroyTexture(textures3d[ii]);
471491   }
r245576r245577
474494   bgfx::destroyTexture(textureCube);
475495   bgfx::destroyIndexBuffer(ibh);
476496   bgfx::destroyVertexBuffer(vbh);
477   bgfx::destroyProgram(program3d);
497   if (bgfx::isValid(program3d) )
498   {
499      bgfx::destroyProgram(program3d);
500   }
478501   bgfx::destroyProgram(programCmp);
479502   bgfx::destroyProgram(program);
480503   bgfx::destroyUniform(u_time);
trunk/3rdparty/bgfx/examples/09-hdr/hdr.cpp
r245576r245577
174174   bgfx::setViewName(8, "Blur vertical");
175175   bgfx::setViewName(9, "Blur horizontal + tonemap");
176176
177   bgfx::TextureHandle uffizi = loadTexture("uffizi.dds", BGFX_TEXTURE_U_CLAMP|BGFX_TEXTURE_V_CLAMP|BGFX_TEXTURE_W_CLAMP);
177   bgfx::TextureHandle uffizi = loadTexture("uffizi.dds"
178         , 0
179         | BGFX_TEXTURE_U_CLAMP
180         | BGFX_TEXTURE_V_CLAMP
181         | BGFX_TEXTURE_W_CLAMP
182         );
178183
179184   bgfx::ProgramHandle skyProgram     = loadProgram("vs_hdr_skybox",  "fs_hdr_skybox");
180185   bgfx::ProgramHandle lumProgram     = loadProgram("vs_hdr_lum",     "fs_hdr_lum");
r245576r245577
371376
372377      // Render skybox into view 0.
373378      bgfx::setTexture(0, u_texCube, uffizi);
379
374380      bgfx::setProgram(skyProgram);
375381      bgfx::setState(BGFX_STATE_RGB_WRITE|BGFX_STATE_ALPHA_WRITE);
376382      screenSpaceQuad( (float)width, (float)height, true);
trunk/3rdparty/bgfx/examples/12-lod/lod.cpp
r245576r245577
2020   {0,0}, {1,2}, {3,3}, {4,1}, {5,3}, {7,2}, {6,0}, {5,2},
2121   {7,3}, {6,1}, {4,0}, {3,2}, {2,0}, {0,1}, {1,3}, {2,1},
2222   {0,2}, {1,0}, {2,2}, {0,3}, {1,1}, {3,0}, {4,2}, {5,0},
23   {7,1}, {6,3}, {5,1}, {7,0}, {6,2}, {4,3}, {3,1}, {2,3}
23   {7,1}, {6,3}, {5,1}, {7,0}, {6,2}, {4,3}, {3,1}, {2,3},
2424};
2525
2626int _main_(int /*_argc*/, char** /*_argv*/)
r245576r245577
5555
5656   bgfx::TextureHandle textureStipple;
5757
58   const bgfx::Memory* stipple = bgfx::alloc(8*4);
59   memset(stipple->data, 0, stipple->size);
58   const bgfx::Memory* stippleTex = bgfx::alloc(8*4);
59   memset(stippleTex->data, 0, stippleTex->size);
6060
6161   for (uint32_t ii = 0; ii < 32; ++ii)
6262   {
63      stipple->data[knightTour[ii].m_y * 8 + knightTour[ii].m_x] = ii*4;
63      stippleTex->data[knightTour[ii].m_y * 8 + knightTour[ii].m_x] = ii*4;
6464   }
6565
66   textureStipple = bgfx::createTexture2D(8, 4, 1, bgfx::TextureFormat::R8, BGFX_TEXTURE_MAG_POINT|BGFX_TEXTURE_MIN_POINT, stipple);
66   textureStipple = bgfx::createTexture2D(8, 4, 1
67         , bgfx::TextureFormat::R8
68         , BGFX_TEXTURE_MAG_POINT|BGFX_TEXTURE_MIN_POINT
69         , stippleTex
70         );
6771
6872   Mesh* meshTop[3] =
6973   {
trunk/3rdparty/bgfx/examples/13-stencil/stencil.cpp
r245576r245577
10401040      const float radius = (scene == StencilReflectionScene) ? 15.0f : 25.0f;
10411041      for (uint8_t ii = 0; ii < numLights; ++ii)
10421042      {
1043         lightPosRadius[ii][0] = sin( (lightTimeAccumulator*1.1f + ii*0.03f + ii*bx::piHalf*1.07f ) )*20.0f;
1044         lightPosRadius[ii][1] = 8.0f + (1.0f - cos( (lightTimeAccumulator*1.5f + ii*0.29f + bx::piHalf*1.49f ) ))*4.0f;
1045         lightPosRadius[ii][2] = cos( (lightTimeAccumulator*1.3f + ii*0.13f + ii*bx::piHalf*1.79f ) )*20.0f;
1043         lightPosRadius[ii][0] = sinf( (lightTimeAccumulator*1.1f + ii*0.03f + ii*bx::piHalf*1.07f ) )*20.0f;
1044         lightPosRadius[ii][1] = 8.0f + (1.0f - cosf( (lightTimeAccumulator*1.5f + ii*0.29f + bx::piHalf*1.49f ) ))*4.0f;
1045         lightPosRadius[ii][2] = cosf( (lightTimeAccumulator*1.3f + ii*0.13f + ii*bx::piHalf*1.79f ) )*20.0f;
10461046         lightPosRadius[ii][3] = radius;
10471047      }
10481048      memcpy(s_uniforms.m_lightPosRadius, lightPosRadius, numLights * 4*sizeof(float));
r245576r245577
11121112            , 0.0f
11131113            , 0.0f
11141114            , 0.0f
1115            , sin(ii * 2.0f + 13.0f - sceneTimeAccumulator) * 13.0f
1115            , sinf(ii * 2.0f + 13.0f - sceneTimeAccumulator) * 13.0f
11161116            , 4.0f
1117            , cos(ii * 2.0f + 13.0f - sceneTimeAccumulator) * 13.0f
1117            , cosf(ii * 2.0f + 13.0f - sceneTimeAccumulator) * 13.0f
11181118            );
11191119      }
11201120
r245576r245577
11881188
11891189            // Set lights back.
11901190            memcpy(s_uniforms.m_lightPosRadius, lightPosRadius, numLights * 4*sizeof(float));
1191
11921191            // Third pass - Blend plane.
11931192
11941193            // Floor.
r245576r245577
12171216                  , s_renderStates[RenderState::StencilReflection_DrawScene]
12181217                  );
12191218            }
1219
12201220         }
12211221         break;
12221222
r245576r245577
13191319                  );
13201320
13211321               // Cubes.
1322               for (uint8_t ii = 0; ii < numCubes; ++ii)
1322               for (uint8_t jj = 0; jj < numCubes; ++jj)
13231323               {
13241324                  cubeMesh.submit(viewId
1325                     , cubeMtx[ii]
1325                     , cubeMtx[jj]
13261326                     , programTextureLightning
13271327                     , s_renderStates[RenderState::ProjectionShadows_DrawDiffuse]
13281328                     , figureTex
trunk/3rdparty/bgfx/examples/14-shadowvolumes/shadowvolumes.cpp
r245576r245577
22762276      {
22772277         for (uint8_t ii = 0; ii < settings_numLights; ++ii)
22782278         {
2279            lightPosRadius[ii][0] = cos(2.0f*bx::pi/settings_numLights * float(ii) + lightTimeAccumulator * 1.1f + 3.0f) * 20.0f;
2279            lightPosRadius[ii][0] = cosf(2.0f*bx::pi/settings_numLights * float(ii) + lightTimeAccumulator * 1.1f + 3.0f) * 20.0f;
22802280            lightPosRadius[ii][1] = 20.0f;
2281            lightPosRadius[ii][2] = sin(2.0f*bx::pi/settings_numLights * float(ii) + lightTimeAccumulator * 1.1f + 3.0f) * 20.0f;
2281            lightPosRadius[ii][2] = sinf(2.0f*bx::pi/settings_numLights * float(ii) + lightTimeAccumulator * 1.1f + 3.0f) * 20.0f;
22822282            lightPosRadius[ii][3] = 20.0f;
22832283         }
22842284      }
r245576r245577
22862286      {
22872287         for (uint8_t ii = 0; ii < settings_numLights; ++ii)
22882288         {
2289            lightPosRadius[ii][0] = cos(float(ii) * 2.0f/settings_numLights + lightTimeAccumulator * 1.3f + bx::pi) * 40.0f;
2289            lightPosRadius[ii][0] = cosf(float(ii) * 2.0f/settings_numLights + lightTimeAccumulator * 1.3f + bx::pi) * 40.0f;
22902290            lightPosRadius[ii][1] = 20.0f;
2291            lightPosRadius[ii][2] = sin(float(ii) * 2.0f/settings_numLights + lightTimeAccumulator * 1.3f + bx::pi) * 40.0f;
2291            lightPosRadius[ii][2] = sinf(float(ii) * 2.0f/settings_numLights + lightTimeAccumulator * 1.3f + bx::pi) * 40.0f;
22922292            lightPosRadius[ii][3] = 20.0f;
22932293         }
22942294      }
r245576r245577
23622362         inst.m_rotation[0] = 0.0f;
23632363         inst.m_rotation[1] = 0.0f;
23642364         inst.m_rotation[2] = 0.0f;
2365         inst.m_pos[0]      = sin(ii * 2.0f + 13.0f + sceneTimeAccumulator * 1.1f) * 13.0f;
2365         inst.m_pos[0]      = sinf(ii * 2.0f + 13.0f + sceneTimeAccumulator * 1.1f) * 13.0f;
23662366         inst.m_pos[1]      = 6.0f;
2367         inst.m_pos[2]      = cos(ii * 2.0f + 13.0f + sceneTimeAccumulator * 1.1f) * 13.0f;
2367         inst.m_pos[2]      = cosf(ii * 2.0f + 13.0f + sceneTimeAccumulator * 1.1f) * 13.0f;
23682368         inst.m_model       = &cubeModel;
23692369      }
23702370
r245576r245577
23792379         inst.m_rotation[0] = 0.0f;
23802380         inst.m_rotation[1] = 0.0f;
23812381         inst.m_rotation[2] = 0.0f;
2382         inst.m_pos[0]      = sin(ii * 2.0f + 13.0f + sceneTimeAccumulator * 1.1f) * 13.0f;
2382         inst.m_pos[0]      = sinf(ii * 2.0f + 13.0f + sceneTimeAccumulator * 1.1f) * 13.0f;
23832383         inst.m_pos[1]      = 22.0f;
2384         inst.m_pos[2]      = cos(ii * 2.0f + 13.0f + sceneTimeAccumulator * 1.1f) * 13.0f;
2384         inst.m_pos[2]      = cosf(ii * 2.0f + 13.0f + sceneTimeAccumulator * 1.1f) * 13.0f;
23852385         inst.m_model       = &cubeModel;
23862386      }
23872387
trunk/3rdparty/bgfx/examples/15-shadowmaps-simple/shadowmaps_simple.cpp
r245576r245577
221221
222222      // Setup lights.
223223      float lightPos[4];
224      lightPos[0] = -cos(timeAccumulatorLight);
224      lightPos[0] = -cosf(timeAccumulatorLight);
225225      lightPos[1] = -1.0f;
226      lightPos[2] = -sin(timeAccumulatorLight);
226      lightPos[2] = -sinf(timeAccumulatorLight);
227227      lightPos[3] = 0.0f;
228228
229229      bgfx::setUniform(u_lightPos, lightPos);
trunk/3rdparty/bgfx/examples/16-shadowmaps/shadowmaps.cpp
r245576r245577
21652165      if (settings.m_updateScene)  { timeAccumulatorScene += deltaTime; }
21662166
21672167      // Setup lights.
2168      pointLight.m_position.m_x = cos(timeAccumulatorLight) * 20.0f;
2168      pointLight.m_position.m_x = cosf(timeAccumulatorLight) * 20.0f;
21692169      pointLight.m_position.m_y = 26.0f;
2170      pointLight.m_position.m_z = sin(timeAccumulatorLight) * 20.0f;
2170      pointLight.m_position.m_z = sinf(timeAccumulatorLight) * 20.0f;
21712171      pointLight.m_spotDirectionInner.m_x = -pointLight.m_position.m_x;
21722172      pointLight.m_spotDirectionInner.m_y = -pointLight.m_position.m_y;
21732173      pointLight.m_spotDirectionInner.m_z = -pointLight.m_position.m_z;
21742174
2175      directionalLight.m_position.m_x = -cos(timeAccumulatorLight);
2175      directionalLight.m_position.m_x = -cosf(timeAccumulatorLight);
21762176      directionalLight.m_position.m_y = -1.0f;
2177      directionalLight.m_position.m_z = -sin(timeAccumulatorLight);
2177      directionalLight.m_position.m_z = -sinf(timeAccumulatorLight);
21782178
21792179      // Setup instance matrices.
21802180      float mtxFloor[16];
trunk/3rdparty/bgfx/examples/20-nanovg/blendish.h
r245576r245577
11091109    #pragma warning (disable: 4100) // Switch off unreferenced formal parameter warnings
11101110    #pragma warning (disable: 4244)
11111111    #pragma warning (disable: 4305)
1112    #pragma warning (disable: 4838) // warning C4838: conversion from 'double' to 'float' requires a narrowing conversion
11121113    #ifdef __cplusplus
11131114    #define BND_INLINE inline
11141115    #else
trunk/3rdparty/bgfx/examples/20-nanovg/nanovg.cpp
r245576r245577
387387   float ry = y + ey;
388388   float dx,dy,d;
389389   float br = (ex < ey ? ex : ey) * 0.5f;
390   float blink = 1 - pow(sinf(t*0.5f),200)*0.8f;
390   float blink = 1 - powf(sinf(t*0.5f),200)*0.8f;
391391
392392   bg = nvgLinearGradient(vg, x,y+h*0.5f,x+w*0.1f,y+h, nvgRGBA(0,0,0,32), nvgRGBA(0,0,0,16));
393393   nvgBeginPath(vg);
r245576r245577
10421042            for (j = 0; j < nglyphs; j++) {
10431043               float x0 = glyphs[j].x;
10441044               float x1 = (j+1 < nglyphs) ? glyphs[j+1].x : x+row->width;
1045               float gx = x0 * 0.3f + x1 * 0.7f;
1046               if (mx >= px && mx < gx)
1045               float tgx = x0 * 0.3f + x1 * 0.7f;
1046               if (mx >= px && mx < tgx)
10471047                  caretx = glyphs[j].x;
1048               px = gx;
1048               px = tgx;
10491049            }
10501050            nvgBeginPath(vg);
10511051            nvgFillColor(vg, nvgRGBA(255,192,0,255));
r245576r245577
10751075      nvgBeginPath(vg);
10761076      nvgFillColor(vg, nvgRGBA(255,192,0,255));
10771077      nvgRoundedRect(vg
1078         , round(bounds[0])-4.0f
1079         , round(bounds[1])-2.0f
1080         , round(bounds[2]-bounds[0])+8.0f
1081         , round(bounds[3]-bounds[1])+4.0f
1082         , (round(bounds[3]-bounds[1])+4.0f)/2.0f-1.0f
1078         , roundf(bounds[0])-4.0f
1079         , roundf(bounds[1])-2.0f
1080         , roundf(bounds[2]-bounds[0])+8.0f
1081         , roundf(bounds[3]-bounds[1])+4.0f
1082         , (roundf(bounds[3]-bounds[1])+4.0f)/2.0f-1.0f
10831083         );
10841084      nvgFill(vg);
10851085
r245576r245577
10971097   nvgBeginPath(vg);
10981098   nvgFillColor(vg, nvgRGBA(220,220,220,255));
10991099   nvgRoundedRect(vg
1100      , round(bounds[0]-2.0f)
1101      , round(bounds[1]-2.0f)
1102      , round(bounds[2]-bounds[0])+4.0f
1103      , round(bounds[3]-bounds[1])+4.0f
1100      , roundf(bounds[0]-2.0f)
1101      , roundf(bounds[1]-2.0f)
1102      , roundf(bounds[2]-bounds[0])+4.0f
1103      , roundf(bounds[3]-bounds[1])+4.0f
11041104      , 3.0f
11051105      );
11061106   px = float( (int)((bounds[2]+bounds[0])/2) );
trunk/3rdparty/bgfx/examples/21-deferred/deferred.cpp
r245576r245577
529529         {
530530            Sphere lightPosRadius;
531531
532            float lightTime = time * lightAnimationSpeed * (sin(light/float(numLights) * bx::piHalf ) * 0.5f + 0.5f);
533            lightPosRadius.m_center[0] = sin( ( (lightTime + light*0.47f) + bx::piHalf*1.37f ) )*offset;
534            lightPosRadius.m_center[1] = cos( ( (lightTime + light*0.69f) + bx::piHalf*1.49f ) )*offset;
535            lightPosRadius.m_center[2] = sin( ( (lightTime + light*0.37f) + bx::piHalf*1.57f ) )*2.0f;
532            float lightTime = time * lightAnimationSpeed * (sinf(light/float(numLights) * bx::piHalf ) * 0.5f + 0.5f);
533            lightPosRadius.m_center[0] = sinf( ( (lightTime + light*0.47f) + bx::piHalf*1.37f ) )*offset;
534            lightPosRadius.m_center[1] = cosf( ( (lightTime + light*0.69f) + bx::piHalf*1.49f ) )*offset;
535            lightPosRadius.m_center[2] = sinf( ( (lightTime + light*0.37f) + bx::piHalf*1.57f ) )*2.0f;
536536            lightPosRadius.m_radius = 2.0f;
537537
538538            Aabb aabb;
trunk/3rdparty/bgfx/examples/23-vectordisplay/main.cpp
r245576r245577
150150      // draw moving shape
151151      static float counter = 0.0f;
152152      counter += 0.01f;
153      float posX = width  / 2.0f + sin(counter * 3.18378f) * (width / 2.0f);
154      float posY = height / 2.0f + cos(counter) * (height / 2.0f);
153      float posX = width  / 2.0f + sinf(counter * 3.18378f) * (width / 2.0f);
154      float posY = height / 2.0f + cosf(counter) * (height / 2.0f);
155155      vd.drawCircle(posX, posY, 5.0f, 10.0f);
156156
157157      vd.endFrame();
trunk/3rdparty/bgfx/examples/23-vectordisplay/vectordisplay.cpp
r245576r245577
361361      line->y0 = m_pendingPoints[i - 1].y;
362362      line->x1 = m_pendingPoints[i].x;
363363      line->y1 = m_pendingPoints[i].y;
364      line->a = atan2(line->y1 - line->y0, line->x1 - line->x0);                  // angle from positive x axis, increasing ccw, [-pi, pi]
364      line->a = atan2f(line->y1 - line->y0, line->x1 - line->x0); // angle from positive x axis, increasing ccw, [-pi, pi]
365365      line->sin_a = sinf(line->a);
366366      line->cos_a = cosf(line->a);
367      line->len = sqrt( (line->x1 - line->x0) * (line->x1 - line->x0) + (line->y1 - line->y0) * (line->y1 - line->y0) );
367      line->len = sqrtf( (line->x1 - line->x0) * (line->x1 - line->x0) + (line->y1 - line->y0) * (line->y1 - line->y0) );
368368
369369      // figure out what connections we have
370370      line->has_prev = (!line->is_first
trunk/3rdparty/bgfx/examples/24-nbody/nbody.cpp
r245576r245577
117117      , 0
118118      );
119119
120   // Imgui.
121   imguiCreate();
120   const bgfx::Caps* caps = bgfx::getCaps();
121   const bool computeSupported = !!(caps->supported & BGFX_CAPS_COMPUTE);
122122
123   bgfx::VertexDecl quadVertexDecl;
124   quadVertexDecl.begin()
125      .add(bgfx::Attrib::Position, 2, bgfx::AttribType::Float)
126      .end();
123   if (computeSupported)
124   {
125      // Imgui.
126      imguiCreate();
127127
128   // Create static vertex buffer.
129   bgfx::VertexBufferHandle vbh = bgfx::createVertexBuffer(
130        // Static data can be passed with bgfx::makeRef
131        bgfx::makeRef(s_quadVertices, sizeof(s_quadVertices) )
132      , quadVertexDecl
133      );
128      bgfx::VertexDecl quadVertexDecl;
129      quadVertexDecl.begin()
130         .add(bgfx::Attrib::Position, 2, bgfx::AttribType::Float)
131         .end();
134132
135   // Create static index buffer.
136   bgfx::IndexBufferHandle ibh = bgfx::createIndexBuffer(
137      // Static data can be passed with bgfx::makeRef
138      bgfx::makeRef(s_quadIndices, sizeof(s_quadIndices) )
139      );
133      // Create static vertex buffer.
134      bgfx::VertexBufferHandle vbh = bgfx::createVertexBuffer(
135            // Static data can be passed with bgfx::makeRef
136            bgfx::makeRef(s_quadVertices, sizeof(s_quadVertices) )
137            , quadVertexDecl
138            );
140139
141   // Create particle program from shaders.
142   bgfx::ProgramHandle particleProgram = loadProgram("vs_particle", "fs_particle");
140      // Create static index buffer.
141      bgfx::IndexBufferHandle ibh = bgfx::createIndexBuffer(
142            // Static data can be passed with bgfx::makeRef
143            bgfx::makeRef(s_quadIndices, sizeof(s_quadIndices) )
144            );
143145
144   // Setup compute buffers
145   bgfx::VertexDecl computeVertexDecl;
146   computeVertexDecl.begin()
147      .add(bgfx::Attrib::TexCoord0, 4, bgfx::AttribType::Float)
148      .end();
146      // Create particle program from shaders.
147      bgfx::ProgramHandle particleProgram = loadProgram("vs_particle", "fs_particle");
149148
150   const uint32_t threadGroupUpdateSize = 512;
151   const uint32_t maxParticleCount = 32 * 1024;
149      // Setup compute buffers
150      bgfx::VertexDecl computeVertexDecl;
151      computeVertexDecl.begin()
152         .add(bgfx::Attrib::TexCoord0, 4, bgfx::AttribType::Float)
153         .end();
152154
153   bgfx::DynamicVertexBufferHandle currPositionBuffer0 = bgfx::createDynamicVertexBuffer(1 << 15, computeVertexDecl, BGFX_BUFFER_COMPUTE_READ_WRITE);
154   bgfx::DynamicVertexBufferHandle currPositionBuffer1 = bgfx::createDynamicVertexBuffer(1 << 15, computeVertexDecl, BGFX_BUFFER_COMPUTE_READ_WRITE);
155   bgfx::DynamicVertexBufferHandle prevPositionBuffer0 = bgfx::createDynamicVertexBuffer(1 << 15, computeVertexDecl, BGFX_BUFFER_COMPUTE_READ_WRITE);
156   bgfx::DynamicVertexBufferHandle prevPositionBuffer1 = bgfx::createDynamicVertexBuffer(1 << 15, computeVertexDecl, BGFX_BUFFER_COMPUTE_READ_WRITE);
155      const uint32_t threadGroupUpdateSize = 512;
156      const uint32_t maxParticleCount = 32 * 1024;
157157
158   bgfx::UniformHandle u_params = bgfx::createUniform("u_params", bgfx::UniformType::Uniform4fv, 3);
158      bgfx::DynamicVertexBufferHandle currPositionBuffer0 = bgfx::createDynamicVertexBuffer(1 << 15, computeVertexDecl, BGFX_BUFFER_COMPUTE_READ_WRITE);
159      bgfx::DynamicVertexBufferHandle currPositionBuffer1 = bgfx::createDynamicVertexBuffer(1 << 15, computeVertexDecl, BGFX_BUFFER_COMPUTE_READ_WRITE);
160      bgfx::DynamicVertexBufferHandle prevPositionBuffer0 = bgfx::createDynamicVertexBuffer(1 << 15, computeVertexDecl, BGFX_BUFFER_COMPUTE_READ_WRITE);
161      bgfx::DynamicVertexBufferHandle prevPositionBuffer1 = bgfx::createDynamicVertexBuffer(1 << 15, computeVertexDecl, BGFX_BUFFER_COMPUTE_READ_WRITE);
159162
160   bgfx::ShaderHandle  initInstancesShader    = loadShader("cs_init_instances");
161   bgfx::ProgramHandle initInstancesProgram   = bgfx::createProgram(initInstancesShader, true);
162   bgfx::ShaderHandle  updateInstancesShader  = loadShader("cs_update_instances");
163   bgfx::ProgramHandle updateInstancesProgram = bgfx::createProgram(updateInstancesShader, true);
163      bgfx::UniformHandle u_params = bgfx::createUniform("u_params", bgfx::UniformType::Uniform4fv, 3);
164164
165   u_paramsDataStruct u_paramsData;
166   InitializeParams(0, &u_paramsData);
165      bgfx::ShaderHandle  initInstancesShader    = loadShader("cs_init_instances");
166      bgfx::ProgramHandle initInstancesProgram   = bgfx::createProgram(initInstancesShader, true);
167      bgfx::ShaderHandle  updateInstancesShader  = loadShader("cs_update_instances");
168      bgfx::ProgramHandle updateInstancesProgram = bgfx::createProgram(updateInstancesShader, true);
167169
168   bgfx::setUniform(u_params, &u_paramsData, 3);
169   bgfx::setBuffer(0, prevPositionBuffer0, bgfx::Access::Write);
170   bgfx::setBuffer(1, currPositionBuffer0, bgfx::Access::Write);
171   bgfx::dispatch(0, initInstancesProgram, maxParticleCount / threadGroupUpdateSize, 1, 1);
170      u_paramsDataStruct u_paramsData;
171      InitializeParams(0, &u_paramsData);
172172
173   float view[16];
174   float initialPos[3] = { 0.0f, 0.0f, -45.0f };
175   cameraCreate();
176   cameraSetPosition(initialPos);
177   cameraSetVerticalAngle(0.0f);
178   cameraGetViewMtx(view);
173      bgfx::setUniform(u_params, &u_paramsData, 3);
174      bgfx::setBuffer(0, prevPositionBuffer0, bgfx::Access::Write);
175      bgfx::setBuffer(1, currPositionBuffer0, bgfx::Access::Write);
176      bgfx::dispatch(0, initInstancesProgram, maxParticleCount / threadGroupUpdateSize, 1, 1);
179177
180   int32_t scrollArea = 0;
178      float view[16];
179      float initialPos[3] = { 0.0f, 0.0f, -45.0f };
180      cameraCreate();
181      cameraSetPosition(initialPos);
182      cameraSetVerticalAngle(0.0f);
183      cameraGetViewMtx(view);
181184
182   entry::MouseState mouseState;
183   while (!entry::processEvents(width, height, debug, reset, &mouseState) )
184   {
185      int64_t now = bx::getHPCounter();
186      static int64_t last = now;
187      const int64_t frameTime = now - last;
188      last = now;
189      const double freq = double(bx::getHPFrequency() );
190      const float deltaTime = float(frameTime/freq);
185      int32_t scrollArea = 0;
191186
192      // Set view 0 default viewport.
193      bgfx::setViewRect(0, 0, 0, width, height);
187      entry::MouseState mouseState;
188      while (!entry::processEvents(width, height, debug, reset, &mouseState) )
189      {
190         int64_t now = bx::getHPCounter();
191         static int64_t last = now;
192         const int64_t frameTime = now - last;
193         last = now;
194         const double freq = double(bx::getHPFrequency() );
195         const float deltaTime = float(frameTime/freq);
194196
195      // Use debug font to print information about this example.
196      bgfx::dbgTextClear();
197      bgfx::dbgTextPrintf(0, 1, 0x4f, "bgfx/examples/24-nbody");
198      bgfx::dbgTextPrintf(0, 2, 0x6f, "Description: N-body simulation with compute shaders using buffers.");
197         // Set view 0 default viewport.
198         bgfx::setViewRect(0, 0, 0, width, height);
199199
200      imguiBeginFrame(mouseState.m_mx
201         , mouseState.m_my
202         , (mouseState.m_buttons[entry::MouseButton::Left  ] ? IMGUI_MBUT_LEFT  : 0)
203         | (mouseState.m_buttons[entry::MouseButton::Right ] ? IMGUI_MBUT_RIGHT : 0)
204         , 0
205         , width
206         , height
207         );
208      imguiBeginScrollArea("Settings", width - width / 4 - 10, 10, width / 4, 500, &scrollArea);
209      imguiSlider("Random seed", u_paramsData.baseSeed, 0, 100);
210      int32_t shape = imguiChoose(u_paramsData.initialShape, "Point", "Sphere", "Box", "Donut");
211      imguiSlider("Initial speed", u_paramsData.initialSpeed, 0.0f, 300.0f, 0.1f);
212      bool reset = imguiButton("Reset");
213      imguiSeparatorLine();
214      imguiSlider("Particle count (x512)", u_paramsData.dispatchSize, 1, 64);
215      imguiSlider("Gravity", u_paramsData.gravity, 0.0f, 0.3f, 0.001f);
216      imguiSlider("Damping", u_paramsData.damping, 0.0f, 1.0f, 0.01f);
217      imguiSlider("Max acceleration", u_paramsData.maxAccel, 0.0f, 100.0f, 0.01f);
218      imguiSlider("Time step", u_paramsData.timeStep, 0.0f, 0.02f, 0.0001f);
219      imguiSeparatorLine();
220      imguiSlider("Particle intensity", u_paramsData.particleIntensity, 0.0f, 1.0f, 0.001f);
221      imguiSlider("Particle size", u_paramsData.particleSize, 0.0f, 1.0f, 0.001f);
222      imguiSlider("Particle power", u_paramsData.particlePower, 0.001f, 16.0f, 0.01f);
223      imguiEndScrollArea();
224      imguiEndFrame();
200         // Use debug font to print information about this example.
201         bgfx::dbgTextClear();
202         bgfx::dbgTextPrintf(0, 1, 0x4f, "bgfx/examples/24-nbody");
203         bgfx::dbgTextPrintf(0, 2, 0x6f, "Description: N-body simulation with compute shaders using buffers.");
225204
226      // Modify parameters and reset if shape is changed
227      if (shape != u_paramsData.initialShape)
228      {
229         reset = true;
230         InitializeParams(shape, &u_paramsData);
231      }
205         imguiBeginFrame(mouseState.m_mx
206               , mouseState.m_my
207               , (mouseState.m_buttons[entry::MouseButton::Left  ] ? IMGUI_MBUT_LEFT  : 0)
208               | (mouseState.m_buttons[entry::MouseButton::Right ] ? IMGUI_MBUT_RIGHT : 0)
209               , 0
210               , width
211               , height
212               );
213         imguiBeginScrollArea("Settings", width - width / 4 - 10, 10, width / 4, 500, &scrollArea);
214         imguiSlider("Random seed", u_paramsData.baseSeed, 0, 100);
215         int32_t shape = imguiChoose(u_paramsData.initialShape, "Point", "Sphere", "Box", "Donut");
216         imguiSlider("Initial speed", u_paramsData.initialSpeed, 0.0f, 300.0f, 0.1f);
217         bool defaults = imguiButton("Reset");
218         imguiSeparatorLine();
219         imguiSlider("Particle count (x512)", u_paramsData.dispatchSize, 1, 64);
220         imguiSlider("Gravity", u_paramsData.gravity, 0.0f, 0.3f, 0.001f);
221         imguiSlider("Damping", u_paramsData.damping, 0.0f, 1.0f, 0.01f);
222         imguiSlider("Max acceleration", u_paramsData.maxAccel, 0.0f, 100.0f, 0.01f);
223         imguiSlider("Time step", u_paramsData.timeStep, 0.0f, 0.02f, 0.0001f);
224         imguiSeparatorLine();
225         imguiSlider("Particle intensity", u_paramsData.particleIntensity, 0.0f, 1.0f, 0.001f);
226         imguiSlider("Particle size", u_paramsData.particleSize, 0.0f, 1.0f, 0.001f);
227         imguiSlider("Particle power", u_paramsData.particlePower, 0.001f, 16.0f, 0.01f);
228         imguiEndScrollArea();
229         imguiEndFrame();
232230
233      if (reset)
234      {
235         bgfx::setBuffer(0, prevPositionBuffer0, bgfx::Access::Write);
236         bgfx::setBuffer(1, currPositionBuffer0, bgfx::Access::Write);
231         // Modify parameters and reset if shape is changed
232         if (shape != u_paramsData.initialShape)
233         {
234            defaults = true;
235            InitializeParams(shape, &u_paramsData);
236         }
237
238         if (defaults)
239         {
240            bgfx::setBuffer(0, prevPositionBuffer0, bgfx::Access::Write);
241            bgfx::setBuffer(1, currPositionBuffer0, bgfx::Access::Write);
242            bgfx::setUniform(u_params, &u_paramsData, 3);
243            bgfx::dispatch(0, initInstancesProgram, maxParticleCount / threadGroupUpdateSize, 1, 1);
244         }
245
246         bgfx::setBuffer(0, prevPositionBuffer0, bgfx::Access::Read);
247         bgfx::setBuffer(1, currPositionBuffer0, bgfx::Access::Read);
248         bgfx::setBuffer(2, prevPositionBuffer1, bgfx::Access::Write);
249         bgfx::setBuffer(3, currPositionBuffer1, bgfx::Access::Write);
237250         bgfx::setUniform(u_params, &u_paramsData, 3);
238         bgfx::dispatch(0, initInstancesProgram, maxParticleCount / threadGroupUpdateSize, 1, 1);
239      }
251         bgfx::dispatch(0, updateInstancesProgram, u_paramsData.dispatchSize, 1, 1);
240252
241      bgfx::setBuffer(0, prevPositionBuffer0, bgfx::Access::Read);
242      bgfx::setBuffer(1, currPositionBuffer0, bgfx::Access::Read);
243      bgfx::setBuffer(2, prevPositionBuffer1, bgfx::Access::Write);
244      bgfx::setBuffer(3, currPositionBuffer1, bgfx::Access::Write);
245      bgfx::setUniform(u_params, &u_paramsData, 3);
246      bgfx::dispatch(0, updateInstancesProgram, u_paramsData.dispatchSize, 1, 1);
253         bx::xchg(currPositionBuffer0, currPositionBuffer1);
254         bx::xchg(prevPositionBuffer0, prevPositionBuffer1);
247255
248      bx::xchg(currPositionBuffer0, currPositionBuffer1);
249      bx::xchg(prevPositionBuffer0, prevPositionBuffer1);
256         // Update camera.
257         cameraUpdate(deltaTime, mouseState);
258         cameraGetViewMtx(view);
250259
251      float view[16];
260         // Set view and projection matrix for view 0.
261         const bgfx::HMD* hmd = bgfx::getHMD();
262         if (NULL != hmd)
263         {
264            float viewHead[16];
265            float eye[3] = {};
266            bx::mtxQuatTranslationHMD(viewHead, hmd->eye[0].rotation, eye);
252267
253      // Update camera.
254      cameraUpdate(deltaTime, mouseState);
255      cameraGetViewMtx(view);
268            float tmp[16];
269            bx::mtxMul(tmp, view, viewHead);
256270
257      // Set view and projection matrix for view 0.
258      const bgfx::HMD* hmd = bgfx::getHMD();
259      if (NULL != hmd)
260      {
261         float viewHead[16];
262         float eye[3] = {};
263         bx::mtxQuatTranslationHMD(viewHead, hmd->eye[0].rotation, eye);
271            float proj[16];
272            bx::mtxProj(proj, hmd->eye[0].fov, 0.1f, 10000.0f);
264273
265         float tmp[16];
266         bx::mtxMul(tmp, view, viewHead);
274            bgfx::setViewTransform(0, tmp, proj);
267275
268         float proj[16];
269         bx::mtxProj(proj, hmd->eye[0].fov, 0.1f, 10000.0f);
276            // Set view 0 default viewport.
277            //
278            // Use HMD's width/height since HMD's internal frame buffer size
279            // might be much larger than window size.
280            bgfx::setViewRect(0, 0, 0, hmd->width, hmd->height);
281         }
282         else
283         {
284            float proj[16];
285            bx::mtxProj(proj, 90.0f, float(width)/float(height), 0.1f, 10000.0f);
286            bgfx::setViewTransform(0, view, proj);
270287
271         bgfx::setViewTransform(0, tmp, proj);
288            // Set view 0 default viewport.
289            bgfx::setViewRect(0, 0, 0, width, height);
290         }
272291
273         // Set view 0 default viewport.
274         //
275         // Use HMD's width/height since HMD's internal frame buffer size
276         // might be much larger than window size.
277         bgfx::setViewRect(0, 0, 0, hmd->width, hmd->height);
292         // Set vertex and fragment shaders.
293         bgfx::setProgram(particleProgram);
294
295         // Set vertex and index buffer.
296         bgfx::setVertexBuffer(vbh);
297         bgfx::setIndexBuffer(ibh);
298         bgfx::setInstanceDataBuffer(currPositionBuffer0, 0, u_paramsData.dispatchSize * threadGroupUpdateSize);
299
300         // Set render states.
301         bgfx::setState(0
302               | BGFX_STATE_RGB_WRITE
303               | BGFX_STATE_BLEND_ADD
304               | BGFX_STATE_DEPTH_TEST_ALWAYS
305               );
306
307         // Submit primitive for rendering to view 0.
308         bgfx::submit(0);
309
310         // Advance to next frame. Rendering thread will be kicked to
311         // process submitted rendering primitives.
312         bgfx::frame();
278313      }
279      else
314
315      // Cleanup.
316      cameraDestroy();
317      imguiDestroy();
318      bgfx::destroyUniform(u_params);
319      bgfx::destroyDynamicVertexBuffer(currPositionBuffer0);
320      bgfx::destroyDynamicVertexBuffer(currPositionBuffer1);
321      bgfx::destroyDynamicVertexBuffer(prevPositionBuffer0);
322      bgfx::destroyDynamicVertexBuffer(prevPositionBuffer1);
323      bgfx::destroyProgram(updateInstancesProgram);
324      bgfx::destroyProgram(initInstancesProgram);
325      bgfx::destroyIndexBuffer(ibh);
326      bgfx::destroyVertexBuffer(vbh);
327      bgfx::destroyProgram(particleProgram);
328   }
329   else
330   {
331      int64_t timeOffset = bx::getHPCounter();
332
333      entry::MouseState mouseState;
334      while (!entry::processEvents(width, height, debug, reset, &mouseState) )
280335      {
281         float proj[16];
282         bx::mtxProj(proj, 90.0f, float(width)/float(height), 0.1f, 10000.0f);
283         bgfx::setViewTransform(0, view, proj);
336         int64_t now = bx::getHPCounter();
337         float time = (float)( (now - timeOffset)/double(bx::getHPFrequency() ) );
284338
285         // Set view 0 default viewport.
286339         bgfx::setViewRect(0, 0, 0, width, height);
287      }
288340
289      // Set vertex and fragment shaders.
290      bgfx::setProgram(particleProgram);
341         bgfx::dbgTextClear();
342         bgfx::dbgTextPrintf(0, 1, 0x4f, "bgfx/examples/24-nbody");
343         bgfx::dbgTextPrintf(0, 2, 0x6f, "Description: N-body simulation with compute shaders using buffers.");
291344
292      // Set vertex and index buffer.
293      bgfx::setVertexBuffer(vbh);
294      bgfx::setIndexBuffer(ibh);
295      bgfx::setInstanceDataBuffer(currPositionBuffer0, 0, u_paramsData.dispatchSize * threadGroupUpdateSize);
345         bool blink = uint32_t(time*3.0f)&1;
346         bgfx::dbgTextPrintf(0, 5, blink ? 0x1f : 0x01, " Compute is not supported by GPU. ");
296347
297      // Set render states.
298      bgfx::setState(0
299         | BGFX_STATE_RGB_WRITE
300         | BGFX_STATE_BLEND_ADD
301         | BGFX_STATE_DEPTH_TEST_ALWAYS
302         );
303
304      // Submit primitive for rendering to view 0.
305      bgfx::submit(0);
306
307      // Advance to next frame. Rendering thread will be kicked to
308      // process submitted rendering primitives.
309      bgfx::frame();
348         bgfx::submit(0);
349         bgfx::frame();
350      }
310351   }
311352
312   // Cleanup.
313   cameraDestroy();
314   imguiDestroy();
315   bgfx::destroyUniform(u_params);
316   bgfx::destroyDynamicVertexBuffer(currPositionBuffer0);
317   bgfx::destroyDynamicVertexBuffer(currPositionBuffer1);
318   bgfx::destroyDynamicVertexBuffer(prevPositionBuffer0);
319   bgfx::destroyDynamicVertexBuffer(prevPositionBuffer1);
320   bgfx::destroyProgram(updateInstancesProgram);
321   bgfx::destroyProgram(initInstancesProgram);
322   bgfx::destroyIndexBuffer(ibh);
323   bgfx::destroyVertexBuffer(vbh);
324   bgfx::destroyProgram(particleProgram);
325
326353   // Shutdown bgfx.
327354   bgfx::shutdown();
328355
trunk/3rdparty/bgfx/examples/25-c99/helloworld.c
r245576r245577
1515
1616int _main_(int _argc, char** _argv)
1717{
18   uint32_t width  = 1280;
19   uint32_t height = 720;
20   uint32_t debug  = BGFX_DEBUG_TEXT;
21   uint32_t reset  = BGFX_RESET_VSYNC;
1822   (void)_argc;
1923   (void)_argv;
20   uint32_t width = 1280;
21   uint32_t height = 720;
22   uint32_t debug = BGFX_DEBUG_TEXT;
23   uint32_t reset = BGFX_RESET_VSYNC;
2424
25   bgfx_init(BGFX_RENDERER_TYPE_COUNT, NULL, NULL);
25   bgfx_init(BGFX_RENDERER_TYPE_COUNT
26         , BGFX_PCI_ID_NONE
27         , 0
28         , NULL
29         , NULL
30         );
2631   bgfx_reset(width, height, reset);
2732
2833   // Enable debug text.
trunk/3rdparty/bgfx/examples/common/bounds.cpp
r245576r245577
264264      {
265265         position = (float*)&vertex[index*_stride];
266266
267         float xx = position[0] - center[0];
268         float yy = position[1] - center[1];
269         float zz = position[2] - center[2];
267         xx = position[0] - center[0];
268         yy = position[1] - center[1];
269         zz = position[2] - center[2];
270270         float distSq = xx*xx + yy*yy + zz*zz;
271271
272272         if (distSq > maxDistSq)
trunk/3rdparty/bgfx/examples/common/entry/entry.cpp
r245576r245577
2929#if ENTRY_CONFIG_IMPLEMENT_DEFAULT_ALLOCATOR
3030   bx::ReallocatorI* getDefaultAllocator()
3131   {
32BX_PRAGMA_DIAGNOSTIC_PUSH_MSVC();
33BX_PRAGMA_DIAGNOSTIC_IGNORED_MSVC(4459); // warning C4459: declaration of 's_allocator' hides global declaration
3234      static bx::CrtAllocator s_allocator;
3335      return &s_allocator;
36BX_PRAGMA_DIAGNOSTIC_POP_MSVC();
3437   }
3538#endif // ENTRY_CONFIG_IMPLEMENT_DEFAULT_ALLOCATOR
3639
trunk/3rdparty/bgfx/examples/common/entry/entry_glfw.cpp
r0r245577
1/*
2 * Copyright 2011-2015 Branimir Karadzic. All rights reserved.
3 * License: http://www.opensource.org/licenses/BSD-2-Clause
4 */
5
6#include "entry_p.h"
7
8#if ENTRY_CONFIG_USE_GLFW
9
10#define GLFW_DLL
11#include <GLFW/glfw3.h>
12#include <bgfxplatform.h>
13#include "dbg.h"
14
15// This is just trivial implementation of GLFW3 integration.
16// It's here just for testing purpose.
17
18namespace entry
19{
20   static void errorCb(int _error, const char* _description)
21   {
22      DBG("GLFW error %d: %s", _error, _description);
23   }
24
25   struct Context
26   {
27      Context()
28      {
29      }
30
31      int run(int _argc, char** _argv)
32      {
33         glfwSetErrorCallback(errorCb);
34
35         glfwInit();
36         m_window = glfwCreateWindow(1280, 720, "bgfx", NULL, NULL);
37         glfwMakeContextCurrent(m_window);
38
39         glfwSetKeyCallback(m_window, keyCb);
40
41         bgfx::glfwSetWindow(m_window);
42         int result = main(_argc, _argv);
43
44         glfwDestroyWindow(m_window);
45         glfwTerminate();
46         return result;
47      }
48
49      static void keyCb(GLFWwindow* _window, int _key, int _scancode, int _action, int _mods);
50
51      EventQueue m_eventQueue;
52
53      GLFWwindow* m_window;
54   };
55
56   Context s_ctx;
57
58   void Context::keyCb(GLFWwindow* _window, int _key, int _scancode, int _action, int _mods)
59   {
60      BX_UNUSED(_window, _scancode, _mods);
61      if (_key    == GLFW_KEY_Q
62      &&  _action == GLFW_PRESS
63      &&  _mods   == GLFW_MOD_CONTROL)
64      {
65         s_ctx.m_eventQueue.postExitEvent();
66      }
67   }
68
69   const Event* poll()
70   {
71      glfwPollEvents();
72
73      if (glfwWindowShouldClose(s_ctx.m_window) )
74      {
75         s_ctx.m_eventQueue.postExitEvent();
76      }
77      return s_ctx.m_eventQueue.poll();
78   }
79
80   const Event* poll(WindowHandle _handle)
81   {
82      return s_ctx.m_eventQueue.poll(_handle);
83   }
84
85   void release(const Event* _event)
86   {
87      s_ctx.m_eventQueue.release(_event);
88   }
89
90   WindowHandle createWindow(int32_t _x, int32_t _y, uint32_t _width, uint32_t _height, uint32_t _flags, const char* _title)
91   {
92      BX_UNUSED(_x, _y, _width, _height, _flags, _title);
93      WindowHandle handle = { UINT16_MAX };
94      return handle;
95   }
96
97   void destroyWindow(WindowHandle _handle)
98   {
99      BX_UNUSED(_handle);
100   }
101
102   void setWindowPos(WindowHandle _handle, int32_t _x, int32_t _y)
103   {
104      BX_UNUSED(_handle, _x, _y);
105   }
106
107   void setWindowSize(WindowHandle _handle, uint32_t _width, uint32_t _height)
108   {
109      BX_UNUSED(_handle, _width, _height);
110   }
111
112   void setWindowTitle(WindowHandle _handle, const char* _title)
113   {
114      BX_UNUSED(_handle, _title);
115   }
116
117   void toggleWindowFrame(WindowHandle _handle)
118   {
119      BX_UNUSED(_handle);
120   }
121
122   void toggleFullscreen(WindowHandle _handle)
123   {
124      BX_UNUSED(_handle);
125   }
126
127   void setMouseLock(WindowHandle _handle, bool _lock)
128   {
129      BX_UNUSED(_handle, _lock);
130   }
131}
132
133int main(int _argc, char** _argv)
134{
135   using namespace entry;
136   return s_ctx.run(_argc, _argv);
137}
138
139#endif // ENTRY_CONFIG_USE_GLFW
trunk/3rdparty/bgfx/examples/common/entry/entry_osx.mm
r245576r245577
311311                     else
312312                     {
313313                        enum { ShiftMask = Modifier::LeftShift|Modifier::RightShift };
314                        const bool nonShiftModifiers = (0 != (modifiers&(~ShiftMask) ) );
315                        const bool isCharPressed = (Key::Key0 <= key && key <= Key::KeyZ) || (Key::Esc <= key && key <= Key::Minus);
316                        const bool isText = isCharPressed && !nonShiftModifiers;
317                        if (isText)
318                        {
319                           m_eventQueue.postCharEvent(s_defaultWindow, 1, pressedChar);
320                           return false;
321                        }
322                        else
323                        {
324                           m_eventQueue.postKeyEvent(s_defaultWindow, key, modifiers, true);
325                           return false;
326                        }
314                        m_eventQueue.postCharEvent(s_defaultWindow, 1, pressedChar);
315                        m_eventQueue.postKeyEvent(s_defaultWindow, key, modifiers, true);
316                        return false;
327317                     }
328318                  }
329319
trunk/3rdparty/bgfx/examples/common/entry/entry_p.h
r245576r245577
1717#   define ENTRY_CONFIG_USE_SDL 0
1818#endif // ENTRY_CONFIG_USE_SDL
1919
20#if !ENTRY_CONFIG_USE_SDL && \
21   !defined(ENTRY_CONFIG_USE_NATIVE)
20#ifndef ENTRY_CONFIG_USE_GLFW
21#   define ENTRY_CONFIG_USE_GLFW 0
22#endif // ENTRY_CONFIG_USE_GLFW
23
24#if !defined(ENTRY_CONFIG_USE_NATIVE) \
25   && !ENTRY_CONFIG_USE_SDL \
26   && !ENTRY_CONFIG_USE_GLFW
2227#   define ENTRY_CONFIG_USE_NATIVE 1
2328#else
2429#   define ENTRY_CONFIG_USE_NATIVE 0
r245576r245577
156161   class EventQueue
157162   {
158163   public:
164      ~EventQueue()
165      {
166         for (const Event* ev = poll(); NULL != ev; ev = poll() )
167         {
168            release(ev);
169         }
170      }
171
159172      void postAxisEvent(WindowHandle _handle, GamepadHandle _gamepad, GamepadAxis::Enum _axis, int32_t _value)
160173      {
161174         AxisEvent* ev = new AxisEvent(_handle);
trunk/3rdparty/bgfx/examples/common/nanovg/nanovg.cpp
r245576r245577
412412   {
413413      cint.rgba[i] = c0.rgba[i] * oneminu + c1.rgba[i] * u;
414414   }
415   
415
416416   return cint;
417417}
418418
r245576r245577
934934   }
935935
936936   // Transform the current scissor rect into current transform space.
937   // If there is difference in rotation, this will be approximation.
937   // If there is difference in rotation, this will be approximation.
938938   memcpy(pxform, state->scissor.xform, sizeof(float)*6);
939939   ex = state->scissor.extent[0];
940940   ey = state->scissor.extent[1];
r245576r245577
11941194{
11951195   float x12,y12,x23,y23,x34,y34,x123,y123,x234,y234,x1234,y1234;
11961196   float dx,dy,d2,d3;
1197   
1197
11981198   if (level > 10) return;
11991199
12001200   x12 = (x1+x2)*0.5f;
r245576r245577
12261226   x1234 = (x123+x234)*0.5f;
12271227   y1234 = (y123+y234)*0.5f;
12281228
1229   nvg__tesselateBezier(ctx, x1,y1, x12,y12, x123,y123, x1234,y1234, level+1, 0);
1230   nvg__tesselateBezier(ctx, x1234,y1234, x234,y234, x34,y34, x4,y4, level+1, type);
1229   nvg__tesselateBezier(ctx, x1,y1, x12,y12, x123,y123, x1234,y1234, level+1, 0);
1230   nvg__tesselateBezier(ctx, x1234,y1234, x234,y234, x34,y34, x4,y4, level+1, type);
12311231}
12321232
12331233static void nvg__flattenPaths(NVGcontext* ctx)
r245576r245577
16251625
16261626
16271627static int nvg__expandStroke(NVGcontext* ctx, float w, int lineCap, int lineJoin, float miterLimit)
1628{   
1628{
16291629   NVGpathCache* cache = ctx->cache;
16301630   NVGvertex* verts;
16311631   NVGvertex* dst;
r245576r245577
18891889{
18901890    float x0 = ctx->commandx;
18911891    float y0 = ctx->commandy;
1892    float vals[] = { NVG_BEZIERTO,
1892    float vals[] = { NVG_BEZIERTO,
18931893        x0 + 2.0f/3.0f*(cx - x0), y0 + 2.0f/3.0f*(cy - y0),
18941894        x + 2.0f/3.0f*(cx - x), y + 2.0f/3.0f*(cy - y),
18951895        x, y };
r245576r245577
19711971   float px = 0, py = 0, ptanx = 0, ptany = 0;
19721972   float vals[3 + 5*7 + 100];
19731973   int i, ndivs, nvals;
1974   int move = ctx->ncommands > 0 ? NVG_LINETO : NVG_MOVETO;
1974   int move = ctx->ncommands > 0 ? NVG_LINETO : NVG_MOVETO;
19751975
19761976   // Clamp angles
19771977   da = a1 - a0;
r245576r245577
23642364      }
23652365   }
23662366
2367   // TODO: add back-end bit to do this just once per frame.
2367   // TODO: add back-end bit to do this just once per frame.
23682368   nvg__flushTextTexture(ctx);
23692369
23702370   nvg__renderText(ctx, verts, nverts);
trunk/3rdparty/bgfx/examples/runtime/.gitignore
r245576r245577
11*.dll
2*.so
23*.pdb
34imgui*
trunk/3rdparty/bgfx/include/bgfx.c99.h
r245576r245577
273273} bgfx_texture_info_t;
274274
275275/**
276 */
277typedef struct bgfx_caps_gpu
278{
279    uint16_t vendorId;
280    uint16_t deviceId;
281
282} bgfx_caps_gpu_t;
283
284/**
276285 *  Renderer capabilities.
277286 */
278287typedef struct bgfx_caps
r245576r245577
293302    uint16_t maxViews;          /* < Maximum views.                    */
294303    uint16_t maxDrawCalls;      /* < Maximum draw calls.               */
295304    uint8_t  maxFBAttachments;  /* < Maximum frame buffer attachments. */
305    uint8_t  numGPUs;           /* <                                   */
296306
307    uint16_t vendorId;          /* <                                   */
308    uint16_t deviceId;          /* <                                   */
309    bgfx_caps_gpu_t gpu[4];     /* <                                   */
310
297311    /**
298312     *  Supported texture formats.
299313     *   `BGFX_CAPS_FORMAT_TEXTURE_NONE` - not supported
r245576r245577
559573 *    specified, library uses default CRT allocator. The library assumes
560574 *    custom allocator is thread safe.
561575 */
562BGFX_C_API void bgfx_init(bgfx_renderer_type_t _type, bgfx_callback_interface_t* _callback, bgfx_reallocator_interface_t* _allocator);
576BGFX_C_API void bgfx_init(bgfx_renderer_type_t _type, uint16_t _vendorId, uint16_t _deviceId, bgfx_callback_interface_t* _callback, bgfx_reallocator_interface_t* _allocator);
563577
564578/**
565579 *  Shutdown bgfx library.
trunk/3rdparty/bgfx/include/bgfx.h
r245576r245577
315315      uint16_t maxViews;         ///< Maximum views.
316316      uint16_t maxDrawCalls;     ///< Maximum draw calls.
317317      uint8_t  maxFBAttachments; ///< Maximum frame buffer attachments.
318      uint8_t  numGPUs; ///<
318319
320      uint16_t vendorId; ///<
321      uint16_t deviceId; ///<
322
323      struct GPU
324      {
325         uint16_t vendorId;
326         uint16_t deviceId;
327      };
328
329      GPU gpu[4];      ///<
330
319331      /// Supported texture formats.
320332      ///   - `BGFX_CAPS_FORMAT_TEXTURE_NONE` - not supported
321333      ///   - `BGFX_CAPS_FORMAT_TEXTURE_COLOR` - supported
r245576r245577
508520   ///   default rendering backend will be selected.
509521   ///   See: `bgfx::RendererType`
510522   ///
523   /// @param _vendorId Vendor PCI id. If set to BGFX_PCI_ID_NONE it will select the first device.
524   ///   - `BGFX_PCI_ID_NONE` - autoselect.
525   ///   - `BGFX_PCI_ID_AMD` - AMD.
526   ///   - `BGFX_PCI_ID_INTEL` - Intel.
527   ///   - `BGFX_PCI_ID_NVIDIA` - nVidia.
528   ///
529   /// @param _deviceId Device id. If set to 0 it will select first device, or device with
530   ///   matching id.
531   ///
511532   /// @param _callback Provide application specific callback interface.
512533   ///   See: `bgfx::CallbackI`
513534   ///
r245576r245577
517538   ///
518539   /// @attention C99 equivalent is `bgfx_init`.
519540   ///
520   void init(RendererType::Enum _type = RendererType::Count, CallbackI* _callback = NULL, bx::ReallocatorI* _reallocator = NULL);
541   void init(RendererType::Enum _type = RendererType::Count, uint16_t _vendorId = BGFX_PCI_ID_NONE, uint16_t _deviceId = 0, CallbackI* _callback = NULL, bx::ReallocatorI* _reallocator = NULL);
521542
522543   /// Shutdown bgfx library.
523544   ///
trunk/3rdparty/bgfx/include/bgfxdefines.h
r245576r245577
8181               | BGFX_STATE_MSAA \
8282               )
8383
84#define BGFX_STATE_ALPHA_REF(_ref) ( (uint64_t(_ref)<<BGFX_STATE_ALPHA_REF_SHIFT)&BGFX_STATE_ALPHA_REF_MASK)
85#define BGFX_STATE_POINT_SIZE(_size) ( (uint64_t(_size)<<BGFX_STATE_POINT_SIZE_SHIFT)&BGFX_STATE_POINT_SIZE_MASK)
84#define BGFX_STATE_ALPHA_REF(_ref)   ( ( (uint64_t)(_ref )<<BGFX_STATE_ALPHA_REF_SHIFT )&BGFX_STATE_ALPHA_REF_MASK)
85#define BGFX_STATE_POINT_SIZE(_size) ( ( (uint64_t)(_size)<<BGFX_STATE_POINT_SIZE_SHIFT)&BGFX_STATE_POINT_SIZE_MASK)
8686
8787///
88#define BGFX_STATE_BLEND_FUNC_SEPARATE(_srcRGB, _dstRGB, _srcA, _dstA) (0 \
89               | ( (uint64_t(_srcRGB)|(uint64_t(_dstRGB)<<4) )   ) \
90               | ( (uint64_t(_srcA  )|(uint64_t(_dstA  )<<4) )<<8) \
88#define BGFX_STATE_BLEND_FUNC_SEPARATE(_srcRGB, _dstRGB, _srcA, _dstA) (UINT64_C(0) \
89               | ( ( (uint64_t)(_srcRGB)|( (uint64_t)(_dstRGB)<<4) )   ) \
90               | ( ( (uint64_t)(_srcA  )|( (uint64_t)(_dstA  )<<4) )<<8) \
9191               )
9292
93#define BGFX_STATE_BLEND_EQUATION_SEPARATE(_rgb, _a) (uint64_t(_rgb)|(uint64_t(_a)<<3) )
93#define BGFX_STATE_BLEND_EQUATION_SEPARATE(_rgb, _a) ( (uint64_t)(_rgb)|( (uint64_t)(_a)<<3) )
9494
9595///
9696#define BGFX_STATE_BLEND_FUNC(_src, _dst)    BGFX_STATE_BLEND_FUNC_SEPARATE(_src, _dst, _src, _dst)
r245576r245577
333333#define BGFX_SUBMIT_EYE_MASK  UINT8_C(0x03)
334334#define BGFX_SUBMIT_EYE_FIRST BGFX_SUBMIT_EYE_LEFT
335335
336///
337#define BGFX_PCI_ID_NONE   UINT16_C(0x0000)
338#define BGFX_PCI_ID_AMD    UINT16_C(0x1002)
339#define BGFX_PCI_ID_INTEL  UINT16_C(0x8086)
340#define BGFX_PCI_ID_NVIDIA UINT16_C(0x10de)
341
336342#endif // BGFX_DEFINES_H_HEADER_GUARD
trunk/3rdparty/bgfx/include/bgfxplatform.h
r245576r245577
5555namespace bgfx
5656{
5757   ///
58   void x11SetDisplayWindow(void* _display, uint32_t _window);
58   void x11SetDisplayWindow(void* _display, uint32_t _window, void* _glx = NULL);
5959
6060} // namespace bgfx
6161
r245576r245577
7676namespace bgfx
7777{
7878   ///
79   void osxSetNSWindow(void* _window);
79   void osxSetNSWindow(void* _window, void* _nsgl = NULL);
8080
8181} // namespace bgfx
8282
r245576r245577
155155   {
156156#   if BX_PLATFORM_LINUX || BX_PLATFORM_FREEBSD
157157      ::Display* display = glfwGetX11Display();
158      ::Window window = glfwGetX11Window(_window);
159      x11SetDisplayWindow(display, window);
158      ::Window   window  = glfwGetX11Window(_window);
159      void* glx          = glfwGetGLXContext(_window);
160      x11SetDisplayWindow(display, window, glx);
160161#   elif BX_PLATFORM_OSX
161      void* id = glfwGetCocoaWindow(_window);
162      osxSetNSWindow(id);
162      void* window = glfwGetCocoaWindow(_window);
163      void* nsgl   = glfwGetNSGLContext(_window);
164      osxSetNSWindow(window, nsgl);
163165#   elif BX_PLATFORM_WINDOWS
164166      HWND hwnd = glfwGetWin32Window(_window);
165167      winSetHwnd(hwnd);
166#   endif BX_PLATFORM_WINDOWS
168#   endif // BX_PLATFORM_WINDOWS
167169   }
168170
169171} // namespace bgfx
trunk/3rdparty/bgfx/makefile
r245576r245577
217217BUILD_PROJECT_DIR=gmake-osx
218218BUILD_OUTPUT_DIR=osx64_clang
219219BUILD_TOOLS_CONFIG=release64
220BUILD_TOOLS_SUFFIX=Release
220221EXE=
221222else
222223OS=linux
223224BUILD_PROJECT_DIR=gmake-linux
224225BUILD_OUTPUT_DIR=linux64_gcc
225226BUILD_TOOLS_CONFIG=release64
227BUILD_TOOLS_SUFFIX=Release
226228EXE=
227229endif
228230else
r245576r245577
230232BUILD_PROJECT_DIR=gmake-mingw-gcc
231233BUILD_OUTPUT_DIR=win32_mingw-gcc
232234BUILD_TOOLS_CONFIG=release32
235BUILD_TOOLS_SUFFIX=Release
233236EXE=.exe
234237endif
235238
236.build/$(BUILD_OUTPUT_DIR)/bin/shadercRelease$(EXE): .build/projects/$(BUILD_PROJECT_DIR)
239tools/bin/$(OS)/shaderc$(EXE): .build/projects/$(BUILD_PROJECT_DIR)
237240   $(SILENT) make -C .build/projects/$(BUILD_PROJECT_DIR) -f shaderc.make config=$(BUILD_TOOLS_CONFIG)
241   $(SILENT) cp .build/$(BUILD_OUTPUT_DIR)/bin/shaderc$(BUILD_TOOLS_SUFFIX)$(EXE) $(@)
238242
239tools/bin/$(OS)/shaderc$(EXE): .build/$(BUILD_OUTPUT_DIR)/bin/shadercRelease$(EXE)
240   $(SILENT) cp $(<) $(@)
241
242.build/$(BUILD_OUTPUT_DIR)/bin/geometrycRelease$(EXE): .build/projects/$(BUILD_PROJECT_DIR)
243tools/bin/$(OS)/geometryc$(EXE): .build/projects/$(BUILD_PROJECT_DIR)
243244   $(SILENT) make -C .build/projects/$(BUILD_PROJECT_DIR) -f geometryc.make config=$(BUILD_TOOLS_CONFIG)
245   $(SILENT) cp .build/$(BUILD_OUTPUT_DIR)/bin/geometryc$(BUILD_TOOLS_SUFFIX)$(EXE) $(@)
244246
245tools/bin/$(OS)/geometryc$(EXE): .build/$(BUILD_OUTPUT_DIR)/bin/geometrycRelease$(EXE)
246   $(SILENT) cp $(<) $(@)
247
248247tools: tools/bin/$(OS)/shaderc$(EXE) tools/bin/$(OS)/geometryc$(EXE)
trunk/3rdparty/bgfx/scripts/bgfx.lua
r245576r245577
2626            }
2727
2828         configuration { "linux-*" }
29            buildoptions {
29            buildoptions {
3030               "-fPIC",
3131            }
3232
r245576r245577
4242         _defines,
4343      }
4444
45      if _OPTIONS["with-glfw"] then
46         defines {
47            "BGFX_CONFIG_MULTITHREADED=0",
48         }
49      end
50
4551      if _OPTIONS["with-ovr"] then
4652         defines {
4753            "BGFX_CONFIG_USE_OVR=1",
r245576r245577
113119         path.join(BGFX_DIR, "src/**.h"),
114120      }
115121
116      excludes {
122      removefiles {
117123         path.join(BGFX_DIR, "src/**.bin.h"),
118124      }
119125
126      if _OPTIONS["with-amalgamated"] then
127         excludes {
128            path.join(BGFX_DIR, "src/bgfx.cpp"),
129            path.join(BGFX_DIR, "src/glcontext_egl.cpp"),
130            path.join(BGFX_DIR, "src/glcontext_glx.cpp"),
131            path.join(BGFX_DIR, "src/glcontext_ppapi.cpp"),
132            path.join(BGFX_DIR, "src/glcontext_wgl.cpp"),
133            path.join(BGFX_DIR, "src/image.cpp"),
134            path.join(BGFX_DIR, "src/ovr.cpp"),
135            path.join(BGFX_DIR, "src/renderdoc.cpp"),
136            path.join(BGFX_DIR, "src/renderer_d3d9.cpp"),
137            path.join(BGFX_DIR, "src/renderer_d3d11.cpp"),
138            path.join(BGFX_DIR, "src/renderer_d3d12.cpp"),
139            path.join(BGFX_DIR, "src/renderer_null.cpp"),
140            path.join(BGFX_DIR, "src/renderer_gl.cpp"),
141            path.join(BGFX_DIR, "src/renderer_vk.cpp"),
142            path.join(BGFX_DIR, "src/vertexdecl.cpp"),
143         }
144      else
145         excludes {
146            path.join(BGFX_DIR, "src/amalgamated.cpp"),
147         }
148      end
149
120150      configuration {}
121151
122152      copyLib()
trunk/3rdparty/bgfx/scripts/example-common.lua
r245576r245577
3131      }
3232   end
3333
34   if _OPTIONS["with-glfw"] then
35      defines {
36         "ENTRY_CONFIG_USE_GLFW=1",
37      }
38   end
39
3440   configuration { "mingw* or vs2008" }
3541      includedirs {
3642         "$(DXSDK_DIR)/include",
trunk/3rdparty/bgfx/scripts/genie.lua
r245576r245577
44--
55
66newoption {
7   trigger = "with-tools",
8   description = "Enable building tools.",
7   trigger = "with-amalgamated",
8   description = "Enable amalgamated build.",
99}
1010
1111newoption {
12   trigger = "with-shared-lib",
13   description = "Enable building shared library.",
12   trigger = "with-ovr",
13   description = "Enable OculusVR integration.",
1414}
1515
1616newoption {
r245576r245577
1919}
2020
2121newoption {
22   trigger = "with-ovr",
23   description = "Enable OculusVR integration.",
22   trigger = "with-glfw",
23   description = "Enable GLFW entry.",
2424}
2525
26newoption {
27   trigger = "with-shared-lib",
28   description = "Enable building shared library.",
29}
30
31newoption {
32   trigger = "with-tools",
33   description = "Enable building tools.",
34}
35
2636solution "bgfx"
2737   configurations {
2838      "Debug",
r245576r245577
3242   if _ACTION == "xcode4" then
3343      platforms {
3444         "Universal",
35   }
45      }
3646   else
3747      platforms {
3848         "x32",
3949         "x64",
4050--         "Xbox360",
4151         "Native", -- for targets where bitness is not specified
42   }
52      }
4353   end
4454
4555   language "C++"
r245576r245577
96106      path.join(BGFX_DIR, "examples", _name, "**.h"),
97107   }
98108
109   removefiles {
110      path.join(BGFX_DIR, "examples", _name, "**.bin.h"),
111   }
112
99113   links {
100114      "bgfx",
101115      "example-common",
r245576r245577
114128      configuration {}
115129   end
116130
131   if _OPTIONS["with-glfw"] then
132      defines { "ENTRY_CONFIG_USE_GLFW=1" }
133      links   {
134         "glfw3"
135      }
136
137      configuration { "linux" }
138         links {
139            "Xrandr",
140            "Xinerama",
141            "Xi",
142            "Xxf86vm",
143            "Xcursor",
144         }
145
146      configuration { "osx" }
147         linkoptions {
148            "-framework CoreVideo",
149            "-framework IOKit",
150         }
151
152      configuration {}
153   end
154
117155   if _OPTIONS["with-ovr"] then
118156      links   {
119157         "winmm",
120158         "ws2_32",
121159      }
122160
123      configuration { "x32" }
124         libdirs { path.join("$(OVR_DIR)/LibOVR/Lib/Win32", _ACTION) }
161      -- Check for LibOVR 5.0+
162      if os.isdir(path.join(os.getenv("OVR_DIR"), "LibOVR/Lib/Windows/Win32/Debug/VS2012")) then
125163
126      configuration { "x64" }
127         libdirs { path.join("$(OVR_DIR)/LibOVR/Lib/x64", _ACTION) }
164         configuration { "x32", "Debug" }
165            libdirs { path.join("$(OVR_DIR)/LibOVR/Lib/Windows/Win32/Debug", _ACTION) }
128166
129      configuration { "x32", "Debug" }
130         links { "libovrd" }
167         configuration { "x32", "Release" }
168            libdirs { path.join("$(OVR_DIR)/LibOVR/Lib/Windows/Win32/Release", _ACTION) }
131169
132      configuration { "x32", "Release" }
133         links { "libovr" }
170         configuration { "x64", "Debug" }
171            libdirs { path.join("$(OVR_DIR)/LibOVR/Lib/Windows/x64/Debug", _ACTION) }
134172
135      configuration { "x64", "Debug" }
136         links { "libovr64d" }
173         configuration { "x64", "Release" }
174            libdirs { path.join("$(OVR_DIR)/LibOVR/Lib/Windows/x64/Release", _ACTION) }
137175
138      configuration { "x64", "Release" }
139         links { "libovr64" }
176         configuration { "x32 or x64" }
177            links { "libovr" }
178      else
179         configuration { "x32" }
180            libdirs { path.join("$(OVR_DIR)/LibOVR/Lib/Win32", _ACTION) }
140181
182         configuration { "x64" }
183            libdirs { path.join("$(OVR_DIR)/LibOVR/Lib/x64", _ACTION) }
184
185         configuration { "x32", "Debug" }
186            links { "libovrd" }
187
188         configuration { "x32", "Release" }
189            links { "libovr" }
190
191         configuration { "x64", "Debug" }
192            links { "libovr64d" }
193
194         configuration { "x64", "Release" }
195            links { "libovr64" }
196      end
197
141198      configuration {}
142199   end
143200
trunk/3rdparty/bgfx/src/amalgamated.cpp
r0r245577
1/*
2 * Copyright 2011-2015 Branimir Karadzic. All rights reserved.
3 * License: http://www.opensource.org/licenses/BSD-2-Clause
4 */
5
6#include "bgfx.cpp"
7#include "glcontext_egl.cpp"
8#include "glcontext_glx.cpp"
9#include "glcontext_ppapi.cpp"
10#include "glcontext_wgl.cpp"
11#include "image.cpp"
12#include "ovr.cpp"
13#include "renderdoc.cpp"
14#include "renderer_d3d9.cpp"
15#include "renderer_d3d11.cpp"
16#include "renderer_d3d12.cpp"
17#include "renderer_null.cpp"
18#include "renderer_gl.cpp"
19#include "renderer_vk.cpp"
20#include "vertexdecl.cpp"
trunk/3rdparty/bgfx/src/bgfx.cpp
r245576r245577
1919#   define BGFX_CHECK_RENDER_THREAD()
2020#endif // BGFX_CONFIG_MULTITHREADED && !BX_PLATFORM_OSX && !BX_PLATFORM_IOS
2121
22#define BGFX_CHECK_HANDLE(_handle, _max) \
23         BX_CHECK(isValid(_handle) \
24            && _handle.idx < _max \
25            , "Invalid handle. %d (< %d " #_max ")" \
26            , _handle.idx \
27            , _max \
28            );
29
3022#if BX_PLATFORM_ANDROID
3123   ::ANativeWindow* g_bgfxAndroidWindow = NULL;
3224
r245576r245577
4436#elif BX_PLATFORM_LINUX
4537   void*    g_bgfxX11Display;
4638   uint32_t g_bgfxX11Window;
39   void*    g_bgfxGLX;
4740
48   void x11SetDisplayWindow(void* _display, uint32_t _window)
41   void x11SetDisplayWindow(void* _display, uint32_t _window, void* _glx)
4942   {
5043      g_bgfxX11Display = _display;
5144      g_bgfxX11Window  = _window;
45      g_bgfxGLX        = _glx;
5246   }
5347#elif BX_PLATFORM_OSX
5448   void* g_bgfxNSWindow = NULL;
49   void* g_bgfxNSGL = NULL;
5550
56   void osxSetNSWindow(void* _window)
51   void osxSetNSWindow(void* _window, void* _nsgl)
5752   {
5853      g_bgfxNSWindow = _window;
54      g_bgfxNSGL     = _nsgl;
5955   }
6056#elif BX_PLATFORM_WINDOWS
6157   ::HWND g_bgfxHwnd = NULL;
r245576r245577
892888
893889   static void dumpCaps()
894890   {
895      BX_TRACE("Supported capabilities (%s):", s_ctx->m_renderCtx->getRendererName() );
891      BX_TRACE("Supported capabilities (renderer %s, vendor 0x%04x, device 0x%04x):"
892            , s_ctx->m_renderCtx->getRendererName()
893            , g_caps.vendorId
894            , g_caps.deviceId
895            );
896896      for (uint32_t ii = 0; ii < BX_COUNTOF(s_capsFlags); ++ii)
897897      {
898898         if (0 != (g_caps.supported & s_capsFlags[ii].m_flag) )
r245576r245577
13321332   typedef RendererContextI* (*RendererCreateFn)();
13331333   typedef void (*RendererDestroyFn)();
13341334
1335   extern RendererContextI* rendererCreateNULL();
1336   extern void rendererDestroyNULL();
1335#define BGFX_RENDERER_CONTEXT(_namespace) \
1336         namespace _namespace \
1337         { \
1338            extern RendererContextI* rendererCreate(); \
1339            extern void rendererDestroy(); \
1340         }
13371341
1338   extern RendererContextI* rendererCreateGL();
1339   extern void rendererDestroyGL();
1342   BGFX_RENDERER_CONTEXT(noop);
1343   BGFX_RENDERER_CONTEXT(d3d9);
1344   BGFX_RENDERER_CONTEXT(d3d11);
1345   BGFX_RENDERER_CONTEXT(d3d12);
1346   BGFX_RENDERER_CONTEXT(gl);
1347   BGFX_RENDERER_CONTEXT(vk);
13401348
1341   extern RendererContextI* rendererCreateD3D9();
1342   extern void rendererDestroyD3D9();
1349#undef BGFX_RENDERER_CONTEXT
13431350
1344   extern RendererContextI* rendererCreateD3D11();
1345   extern void rendererDestroyD3D11();
1346
1347   extern RendererContextI* rendererCreateD3D12();
1348   extern void rendererDestroyD3D12();
1349
1350   extern RendererContextI* rendererCreateVK();
1351   extern void rendererDestroyVK();
1352
13531351   struct RendererCreator
13541352   {
13551353      RendererCreateFn  createFn;
r245576r245577
13601358
13611359   static const RendererCreator s_rendererCreator[] =
13621360   {
1363      { rendererCreateNULL,  rendererDestroyNULL,  BGFX_RENDERER_NULL_NAME,       !!BGFX_CONFIG_RENDERER_NULL       }, // Null
1364      { rendererCreateD3D9,  rendererDestroyD3D9,  BGFX_RENDERER_DIRECT3D9_NAME,  !!BGFX_CONFIG_RENDERER_DIRECT3D9  }, // Direct3D9
1365      { rendererCreateD3D11, rendererDestroyD3D11, BGFX_RENDERER_DIRECT3D11_NAME, !!BGFX_CONFIG_RENDERER_DIRECT3D11 }, // Direct3D11
1366      { rendererCreateD3D12, rendererDestroyD3D12, BGFX_RENDERER_DIRECT3D12_NAME, !!BGFX_CONFIG_RENDERER_DIRECT3D12 }, // Direct3D12
1367      { rendererCreateGL,    rendererDestroyGL,    BGFX_RENDERER_OPENGL_NAME,     !!BGFX_CONFIG_RENDERER_OPENGLES   }, // OpenGLES
1368      { rendererCreateGL,    rendererDestroyGL,    BGFX_RENDERER_OPENGL_NAME,     !!BGFX_CONFIG_RENDERER_OPENGL     }, // OpenGL
1369      { rendererCreateVK,    rendererDestroyVK,    BGFX_RENDERER_VULKAN_NAME,     !!BGFX_CONFIG_RENDERER_VULKAN     }, // Vulkan
1361      { noop::rendererCreate,  noop::rendererDestroy,  BGFX_RENDERER_NULL_NAME,       !!BGFX_CONFIG_RENDERER_NULL       }, // Null
1362      { d3d9::rendererCreate,  d3d9::rendererDestroy,  BGFX_RENDERER_DIRECT3D9_NAME,  !!BGFX_CONFIG_RENDERER_DIRECT3D9  }, // Direct3D9
1363      { d3d11::rendererCreate, d3d11::rendererDestroy, BGFX_RENDERER_DIRECT3D11_NAME, !!BGFX_CONFIG_RENDERER_DIRECT3D11 }, // Direct3D11
1364      { d3d12::rendererCreate, d3d12::rendererDestroy, BGFX_RENDERER_DIRECT3D12_NAME, !!BGFX_CONFIG_RENDERER_DIRECT3D12 }, // Direct3D12
1365      { gl::rendererCreate,    gl::rendererDestroy,    BGFX_RENDERER_OPENGL_NAME,     !!BGFX_CONFIG_RENDERER_OPENGLES   }, // OpenGLES
1366      { gl::rendererCreate,    gl::rendererDestroy,    BGFX_RENDERER_OPENGL_NAME,     !!BGFX_CONFIG_RENDERER_OPENGL     }, // OpenGL
1367      { vk::rendererCreate,    vk::rendererDestroy,    BGFX_RENDERER_VULKAN_NAME,     !!BGFX_CONFIG_RENDERER_VULKAN     }, // Vulkan
13701368   };
13711369   BX_STATIC_ASSERT(BX_COUNTOF(s_rendererCreator) == RendererType::Count);
13721370
r245576r245577
19831981      return s_rendererCreator[_type].name;
19841982   }
19851983
1986   void init(RendererType::Enum _type, CallbackI* _callback, bx::ReallocatorI* _allocator)
1984   void init(RendererType::Enum _type, uint16_t _vendorId, uint16_t _deviceId, CallbackI* _callback, bx::ReallocatorI* _allocator)
19871985   {
19881986      BX_CHECK(NULL == s_ctx, "bgfx is already initialized.");
19891987      BX_TRACE("Init...");
r245576r245577
19951993      g_caps.maxViews     = BGFX_CONFIG_MAX_VIEWS;
19961994      g_caps.maxDrawCalls = BGFX_CONFIG_MAX_DRAW_CALLS;
19971995      g_caps.maxFBAttachments = 1;
1996      g_caps.vendorId = _vendorId;
1997      g_caps.deviceId = _deviceId;
19981998
19991999      if (NULL != _allocator)
20002000      {
r245576r245577
27702770   void setUniform(UniformHandle _handle, const void* _value, uint16_t _num)
27712771   {
27722772      BGFX_CHECK_MAIN_THREAD();
2773      BGFX_CHECK_HANDLE(_handle, BGFX_CONFIG_MAX_UNIFORMS);
27742773      s_ctx->setUniform(_handle, _value, _num);
27752774   }
27762775
27772776   void setIndexBuffer(IndexBufferHandle _handle, uint32_t _firstIndex, uint32_t _numIndices)
27782777   {
27792778      BGFX_CHECK_MAIN_THREAD();
2780      BGFX_CHECK_HANDLE(_handle, BGFX_CONFIG_MAX_INDEX_BUFFERS);
27812779      s_ctx->setIndexBuffer(_handle, _firstIndex, _numIndices);
27822780   }
27832781
27842782   void setIndexBuffer(DynamicIndexBufferHandle _handle, uint32_t _firstIndex, uint32_t _numIndices)
27852783   {
27862784      BGFX_CHECK_MAIN_THREAD();
2787      BGFX_CHECK_HANDLE(_handle, BGFX_CONFIG_MAX_DYNAMIC_INDEX_BUFFERS);
27882785      s_ctx->setIndexBuffer(_handle, _firstIndex, _numIndices);
27892786   }
27902787
r245576r245577
28092806   void setVertexBuffer(VertexBufferHandle _handle, uint32_t _startVertex, uint32_t _numVertices)
28102807   {
28112808      BGFX_CHECK_MAIN_THREAD();
2812      BGFX_CHECK_HANDLE(_handle, BGFX_CONFIG_MAX_VERTEX_BUFFERS);
28132809      s_ctx->setVertexBuffer(_handle, _startVertex, _numVertices);
28142810   }
28152811
28162812   void setVertexBuffer(DynamicVertexBufferHandle _handle, uint32_t _numVertices)
28172813   {
28182814      BGFX_CHECK_MAIN_THREAD();
2819      BGFX_CHECK_HANDLE(_handle, BGFX_CONFIG_MAX_DYNAMIC_VERTEX_BUFFERS);
28202815      s_ctx->setVertexBuffer(_handle, _numVertices);
28212816   }
28222817
r245576r245577
28422837   void setInstanceDataBuffer(VertexBufferHandle _handle, uint32_t _startVertex, uint32_t _num)
28432838   {
28442839      BGFX_CHECK_MAIN_THREAD();
2845      BGFX_CHECK_HANDLE(_handle, BGFX_CONFIG_MAX_VERTEX_BUFFERS);
28462840      s_ctx->setInstanceDataBuffer(_handle, _startVertex, _num);
28472841   }
28482842
28492843   void setInstanceDataBuffer(DynamicVertexBufferHandle _handle, uint32_t _startVertex, uint32_t _num)
28502844   {
28512845      BGFX_CHECK_MAIN_THREAD();
2852      BGFX_CHECK_HANDLE(_handle, BGFX_CONFIG_MAX_DYNAMIC_VERTEX_BUFFERS);
28532846      s_ctx->setInstanceDataBuffer(_handle, _startVertex, _num);
28542847   }
28552848
28562849   void setProgram(ProgramHandle _handle)
28572850   {
28582851      BGFX_CHECK_MAIN_THREAD();
2859      BGFX_CHECK_HANDLE(_handle, BGFX_CONFIG_MAX_PROGRAMS);
28602852      s_ctx->setProgram(_handle);
28612853   }
28622854
r245576r245577
28812873   void setBuffer(uint8_t _stage, IndexBufferHandle _handle, Access::Enum _access)
28822874   {
28832875      BGFX_CHECK_MAIN_THREAD();
2884      BGFX_CHECK_HANDLE(_handle, BGFX_CONFIG_MAX_INDEX_BUFFERS);
28852876      s_ctx->setBuffer(_stage, _handle, _access);
28862877   }
28872878
28882879   void setBuffer(uint8_t _stage, VertexBufferHandle _handle, Access::Enum _access)
28892880   {
28902881      BGFX_CHECK_MAIN_THREAD();
2891      BGFX_CHECK_HANDLE(_handle, BGFX_CONFIG_MAX_VERTEX_BUFFERS);
28922882      s_ctx->setBuffer(_stage, _handle, _access);
28932883   }
28942884
28952885   void setBuffer(uint8_t _stage, DynamicIndexBufferHandle _handle, Access::Enum _access)
28962886   {
28972887      BGFX_CHECK_MAIN_THREAD();
2898      BGFX_CHECK_HANDLE(_handle, BGFX_CONFIG_MAX_DYNAMIC_INDEX_BUFFERS);
28992888      s_ctx->setBuffer(_stage, _handle, _access);
29002889   }
29012890
29022891   void setBuffer(uint8_t _stage, DynamicVertexBufferHandle _handle, Access::Enum _access)
29032892   {
29042893      BGFX_CHECK_MAIN_THREAD();
2905      BGFX_CHECK_HANDLE(_handle, BGFX_CONFIG_MAX_DYNAMIC_VERTEX_BUFFERS);
29062894      s_ctx->setBuffer(_stage, _handle, _access);
29072895   }
29082896
r245576r245577
30303018   return bgfx::getRendererName(bgfx::RendererType::Enum(_type) );
30313019}
30323020
3033BGFX_C_API void bgfx_init(bgfx_renderer_type_t _type, struct bgfx_callback_interface* _callback, struct bgfx_reallocator_interface* _allocator)
3021BGFX_C_API void bgfx_init(bgfx_renderer_type_t _type, uint16_t _vendorId, uint16_t _deviceId, bgfx_callback_interface_t* _callback, bgfx_reallocator_interface_t* _allocator)
30343022{
30353023   return bgfx::init(bgfx::RendererType::Enum(_type)
3024      , _vendorId
3025      , _deviceId
30363026      , reinterpret_cast<bgfx::CallbackI*>(_callback)
30373027      , reinterpret_cast<bx::ReallocatorI*>(_allocator)
30383028      );
trunk/3rdparty/bgfx/src/bgfx_p.h
r245576r245577
2929#include <string.h>
3030#include <alloca.h>
3131
32// Check handle, cannot be bgfx::invalidHandle and must be valid.
33#define BGFX_CHECK_HANDLE(_desc, _handleAlloc, _handle) \
34         BX_CHECK(isValid(_handle) \
35            && _handleAlloc.isValid(_handle.idx) \
36            , "Invalid handle. %s handle: %d (max %d)" \
37            , _desc \
38            , _handle.idx \
39            , _handleAlloc.getMaxHandles() \
40            )
41
42// Check handle, it's ok to be bgfx::invalidHandle or must be valid.
43#define BGFX_CHECK_HANDLE_INVALID_OK(_desc, _handleAlloc, _handle) \
44         BX_CHECK(!isValid(_handle) \
45            || _handleAlloc.isValid(_handle.idx) \
46            , "Invalid handle. %s handle: %d (max %d)" \
47            , _desc \
48            , _handle.idx \
49            , _handleAlloc.getMaxHandles() \
50            )
51
3252namespace bgfx
3353{
3454#if BX_COMPILER_CLANG_ANALYZER
r245576r245577
204224#elif BX_PLATFORM_LINUX
205225   extern void*    g_bgfxX11Display;
206226   extern uint32_t g_bgfxX11Window;
227   extern void*    g_bgfxGLX;
207228#elif BX_PLATFORM_OSX
208229   extern void* g_bgfxNSWindow;
230   extern void* g_bgfxNSGL;
209231#elif BX_PLATFORM_WINDOWS
210232   extern ::HWND g_bgfxHwnd;
211233#elif BX_PLATFORM_WINRT
r245576r245577
14181440      {
14191441         Binding& sampler = m_draw.m_bind[_stage];
14201442         sampler.m_idx    = _handle.idx;
1421         sampler.m_un.m_draw.m_flags = (_flags&BGFX_SAMPLER_DEFAULT_FLAGS) ? BGFX_SAMPLER_DEFAULT_FLAGS : _flags;
1443         sampler.m_un.m_draw.m_flags = (_flags&BGFX_SAMPLER_DEFAULT_FLAGS)
1444            ? BGFX_SAMPLER_DEFAULT_FLAGS
1445            : _flags
1446            ;
14221447
14231448         if (isValid(_sampler)
14241449         && (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGL) || BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGLES) ) )
r245576r245577
19892014
19902015      BGFX_API_FUNC(void destroyIndexBuffer(IndexBufferHandle _handle) )
19912016      {
2017         BGFX_CHECK_HANDLE("destroyIndexBuffer", m_indexBufferHandle, _handle);
2018
19922019         CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::DestroyIndexBuffer);
19932020         cmdbuf.write(_handle);
19942021         m_submit->free(_handle);
r245576r245577
20342061
20352062      BGFX_API_FUNC(void destroyVertexBuffer(VertexBufferHandle _handle) )
20362063      {
2064         BGFX_CHECK_HANDLE("destroyVertexBuffer", m_vertexBufferHandle, _handle);
2065
20372066         CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::DestroyVertexBuffer);
20382067         cmdbuf.write(_handle);
20392068         m_submit->free(_handle);
r245576r245577
21352164
21362165      BGFX_API_FUNC(void updateDynamicIndexBuffer(DynamicIndexBufferHandle _handle, const Memory* _mem) )
21372166      {
2167         BGFX_CHECK_HANDLE("updateDynamicIndexBuffer", m_dynamicIndexBufferHandle, _handle);
2168
21382169         DynamicIndexBuffer& dib = m_dynamicIndexBuffers[_handle.idx];
21392170         BX_CHECK(0 == (dib.m_flags &  BGFX_BUFFER_COMPUTE_READ_WRITE), "Can't update GPU buffer from CPU.");
21402171
r245576r245577
21662197
21672198      BGFX_API_FUNC(void destroyDynamicIndexBuffer(DynamicIndexBufferHandle _handle) )
21682199      {
2200         BGFX_CHECK_HANDLE("destroyDynamicIndexBuffer", m_dynamicIndexBufferHandle, _handle);
2201
21692202         m_freeDynamicIndexBufferHandle[m_numFreeDynamicIndexBufferHandles++] = _handle;
21702203      }
21712204
r245576r245577
22792312
22802313      BGFX_API_FUNC(void updateDynamicVertexBuffer(DynamicVertexBufferHandle _handle, const Memory* _mem) )
22812314      {
2315         BGFX_CHECK_HANDLE("updateDynamicVertexBuffer", m_dynamicVertexBufferHandle, _handle);
2316
22822317         DynamicVertexBuffer& dvb = m_dynamicVertexBuffers[_handle.idx];
22832318         BX_CHECK(0 == (dvb.m_flags &  BGFX_BUFFER_COMPUTE_READ_WRITE), "Can't update GPU buffer from CPU.");
22842319
r245576r245577
23112346
23122347      BGFX_API_FUNC(void destroyDynamicVertexBuffer(DynamicVertexBufferHandle _handle) )
23132348      {
2349         BGFX_CHECK_HANDLE("destroyDynamicVertexBuffer", m_dynamicVertexBufferHandle, _handle);
2350
23142351         m_freeDynamicVertexBufferHandle[m_numFreeDynamicVertexBufferHandles++] = _handle;
23152352      }
23162353
r245576r245577
25932630
25942631      BGFX_API_FUNC(void destroyShader(ShaderHandle _handle) )
25952632      {
2633         BGFX_CHECK_HANDLE("destroyShader", m_shaderHandle, _handle);
2634
25962635         if (!isValid(_handle) )
25972636         {
25982637            BX_WARN(false, "Passing invalid shader handle to bgfx::destroyShader.");
r245576r245577
27042743
27052744      BGFX_API_FUNC(void destroyProgram(ProgramHandle _handle) )
27062745      {
2746         BGFX_CHECK_HANDLE("destroyProgram", m_programHandle, _handle);
2747
27072748         CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::DestroyProgram);
27082749         cmdbuf.write(_handle);
27092750         m_submit->free(_handle);
r245576r245577
27692810
27702811      BGFX_API_FUNC(void destroyTexture(TextureHandle _handle) )
27712812      {
2813         BGFX_CHECK_HANDLE("destroyTexture", m_textureHandle, _handle);
2814
27722815         if (!isValid(_handle) )
27732816         {
27742817            BX_WARN(false, "Passing invalid texture handle to bgfx::destroyTexture");
r245576r245577
28322875            for (uint32_t ii = 0; ii < _num; ++ii)
28332876            {
28342877               TextureHandle texHandle = _handles[ii];
2878               BGFX_CHECK_HANDLE("createFrameBuffer texture handle", m_textureHandle, texHandle);
28352879
28362880               cmdbuf.write(texHandle);
28372881
r245576r245577
28682912
28692913      BGFX_API_FUNC(void destroyFrameBuffer(FrameBufferHandle _handle) )
28702914      {
2915         BGFX_CHECK_HANDLE("destroyFrameBuffer", m_frameBufferHandle, _handle);
2916
28712917         CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::DestroyFrameBuffer);
28722918         cmdbuf.write(_handle);
28732919         m_submit->free(_handle);
r245576r245577
29512997
29522998      BGFX_API_FUNC(void destroyUniform(UniformHandle _handle) )
29532999      {
3000         BGFX_CHECK_HANDLE("destroyUniform", m_uniformHandle, _handle);
3001
29543002         UniformRef& uniform = m_uniformRef[_handle.idx];
29553003         BX_CHECK(uniform.m_refCount > 0, "Destroying already destroyed uniform %d.", _handle.idx);
29563004         int32_t refs = --uniform.m_refCount;
r245576r245577
30543102
30553103      BGFX_API_FUNC(void setViewFrameBuffer(uint8_t _id, FrameBufferHandle _handle) )
30563104      {
3105         BGFX_CHECK_HANDLE_INVALID_OK("setViewFrameBuffer", m_frameBufferHandle, _handle);
30573106         m_fb[_id] = _handle;
30583107      }
30593108
r245576r245577
30913140
30923141      BGFX_API_FUNC(void setViewRemap(uint8_t _id, uint8_t _num, const void* _remap) )
30933142      {
3094         const uint32_t num = bx::uint32_min( (BGFX_CONFIG_MAX_VIEWS - _id) + _num, BGFX_CONFIG_MAX_VIEWS) - _id;
3143         const uint32_t num = bx::uint32_min(_id + _num, BGFX_CONFIG_MAX_VIEWS) - _id;
30953144         if (NULL == _remap)
30963145         {
30973146            for (uint32_t ii = 0; ii < num; ++ii)
r245576r245577
31483197
31493198      BGFX_API_FUNC(void setUniform(UniformHandle _handle, const void* _value, uint16_t _num) )
31503199      {
3200         BGFX_CHECK_HANDLE("setUniform", m_uniformHandle, _handle);
31513201         UniformRef& uniform = m_uniformRef[_handle.idx];
31523202         BX_CHECK(uniform.m_num >= _num, "Truncated uniform update. %d (max: %d)", _num, uniform.m_num);
31533203         m_submit->writeUniform(uniform.m_type, _handle, _value, bx::uint16_min(uniform.m_num, _num) );
r245576r245577
31553205
31563206      BGFX_API_FUNC(void setIndexBuffer(IndexBufferHandle _handle, uint32_t _firstIndex, uint32_t _numIndices) )
31573207      {
3208         BGFX_CHECK_HANDLE("setIndexBuffer", m_indexBufferHandle, _handle);
31583209         m_submit->setIndexBuffer(_handle, _firstIndex, _numIndices);
31593210      }
31603211
31613212      BGFX_API_FUNC(void setIndexBuffer(DynamicIndexBufferHandle _handle, uint32_t _firstIndex, uint32_t _numIndices) )
31623213      {
3214         BGFX_CHECK_HANDLE("setIndexBuffer", m_dynamicIndexBufferHandle, _handle);
31633215         m_submit->setIndexBuffer(m_dynamicIndexBuffers[_handle.idx], _firstIndex, _numIndices);
31643216      }
31653217
r245576r245577
31703222
31713223      BGFX_API_FUNC(void setVertexBuffer(VertexBufferHandle _handle, uint32_t _startVertex, uint32_t _numVertices) )
31723224      {
3225         BGFX_CHECK_HANDLE("setVertexBuffer", m_vertexBufferHandle, _handle);
31733226         m_submit->setVertexBuffer(_handle, _startVertex, _numVertices);
31743227      }
31753228
31763229      BGFX_API_FUNC(void setVertexBuffer(DynamicVertexBufferHandle _handle, uint32_t _numVertices) )
31773230      {
3231         BGFX_CHECK_HANDLE("setVertexBuffer", m_dynamicVertexBufferHandle, _handle);
31783232         m_submit->setVertexBuffer(m_dynamicVertexBuffers[_handle.idx], _numVertices);
31793233      }
31803234
r245576r245577
31923246
31933247      BGFX_API_FUNC(void setInstanceDataBuffer(VertexBufferHandle _handle, uint32_t _startVertex, uint32_t _num) )
31943248      {
3249         BGFX_CHECK_HANDLE("setInstanceDataBuffer", m_vertexBufferHandle, _handle);
31953250         const VertexBuffer& vb = m_vertexBuffers[_handle.idx];
31963251         m_submit->setInstanceDataBuffer(_handle, _startVertex, _num, vb.m_stride);
31973252      }
31983253
31993254      BGFX_API_FUNC(void setInstanceDataBuffer(DynamicVertexBufferHandle _handle, uint32_t _startVertex, uint32_t _num) )
32003255      {
3256         BGFX_CHECK_HANDLE("setInstanceDataBuffer", m_dynamicVertexBufferHandle, _handle);
32013257         const DynamicVertexBuffer& dvb = m_dynamicVertexBuffers[_handle.idx];
32023258         m_submit->setInstanceDataBuffer(dvb.m_handle
32033259            , dvb.m_startVertex + _startVertex
r245576r245577
32083264
32093265      BGFX_API_FUNC(void setProgram(ProgramHandle _handle) )
32103266      {
3267         BGFX_CHECK_HANDLE("setProgram", m_programHandle, _handle);
32113268         m_submit->setProgram(_handle);
32123269      }
32133270
32143271      BGFX_API_FUNC(void setTexture(uint8_t _stage, UniformHandle _sampler, TextureHandle _handle, uint32_t _flags) )
32153272      {
3273         BGFX_CHECK_HANDLE_INVALID_OK("setTexture/TextureHandle", m_textureHandle, _handle);
32163274         m_submit->setTexture(_stage, _sampler, _handle, _flags);
32173275      }
32183276
32193277      BGFX_API_FUNC(void setTexture(uint8_t _stage, UniformHandle _sampler, FrameBufferHandle _handle, uint8_t _attachment, uint32_t _flags) )
32203278      {
3279         BGFX_CHECK_HANDLE_INVALID_OK("setTexture/FrameBufferHandle", m_frameBufferHandle, _handle);
32213280         BX_CHECK(_attachment < g_caps.maxFBAttachments, "Frame buffer attachment index %d is invalid.", _attachment);
32223281         TextureHandle textureHandle = BGFX_INVALID_HANDLE;
32233282         if (isValid(_handle) )
r245576r245577
32383297
32393298      BGFX_API_FUNC(void setBuffer(uint8_t _stage, IndexBufferHandle _handle, Access::Enum _access) )
32403299      {
3300         BGFX_CHECK_HANDLE("setBuffer", m_indexBufferHandle, _handle);
32413301         m_submit->setBuffer(_stage, _handle, _access);
32423302      }
32433303
32443304      BGFX_API_FUNC(void setBuffer(uint8_t _stage, VertexBufferHandle _handle, Access::Enum _access) )
32453305      {
3306         BGFX_CHECK_HANDLE("setBuffer", m_vertexBufferHandle, _handle);
32463307         m_submit->setBuffer(_stage, _handle, _access);
32473308      }
32483309
32493310      BGFX_API_FUNC(void setBuffer(uint8_t _stage, DynamicIndexBufferHandle _handle, Access::Enum _access) )
32503311      {
3312         BGFX_CHECK_HANDLE("setBuffer", m_dynamicIndexBufferHandle, _handle);
32513313         const DynamicIndexBuffer& dib = m_dynamicIndexBuffers[_handle.idx];
32523314         m_submit->setBuffer(_stage, dib.m_handle, _access);
32533315      }
32543316
32553317      BGFX_API_FUNC(void setBuffer(uint8_t _stage, DynamicVertexBufferHandle _handle, Access::Enum _access) )
32563318      {
3319         BGFX_CHECK_HANDLE("setBuffer", m_dynamicVertexBufferHandle, _handle);
32573320         const DynamicVertexBuffer& dvb = m_dynamicVertexBuffers[_handle.idx];
32583321         m_submit->setBuffer(_stage, dvb.m_handle, _access);
32593322      }
trunk/3rdparty/bgfx/src/glcontext_eagl.h
r245576r245577
88
99#if BX_PLATFORM_IOS
1010
11namespace bgfx
11namespace bgfx { namespace gl
1212{
1313   struct SwapChainGL;
1414
r245576r245577
4848      GLuint m_colorRbo;
4949      GLuint m_depthStencilRbo;
5050   };
51} // namespace bgfx
51} /* namespace gl */ } // namespace bgfx
5252
5353#endif // BX_PLATFORM_IOS
5454
trunk/3rdparty/bgfx/src/glcontext_eagl.mm
r245576r245577
1010#   include <QuartzCore/CAEAGLLayer.h>
1111#   include "renderer_gl.h"
1212
13namespace bgfx
13namespace bgfx { namespace gl
1414{
1515#   define GL_IMPORT(_optional, _proto, _func, _import) _proto _func = NULL
1616#   include "glimports.h"
r245576r245577
123123   {
124124   }
125125
126} // namespace bgfx
126} /* namespace gl */ } // namespace bgfx
127127
128128#endif // BX_PLATFORM_IOS && (BGFX_CONFIG_RENDERER_OPENGLES2|BGFX_CONFIG_RENDERER_OPENGLES3|BGFX_CONFIG_RENDERER_OPENGL)
trunk/3rdparty/bgfx/src/glcontext_egl.cpp
r245576r245577
2222#   define EGL_CONTEXT_MINOR_VERSION_KHR 0x30FB
2323#endif // EGL_CONTEXT_MINOR_VERSION_KHR
2424
25namespace bgfx
25namespace bgfx { namespace gl
2626{
2727#if BGFX_USE_GL_DYNAMIC_LIB
2828
r245576r245577
369369#   include "glimports.h"
370370   }
371371
372} // namespace bgfx
372} /* namespace gl */ } // namespace bgfx
373373
374374#   endif // BGFX_USE_EGL
375375#endif // (BGFX_CONFIG_RENDERER_OPENGLES || BGFX_CONFIG_RENDERER_OPENGL)
trunk/3rdparty/bgfx/src/glcontext_egl.h
r245576r245577
1010
1111#include <EGL/egl.h>
1212
13namespace bgfx
13namespace bgfx { namespace gl
1414{
1515   struct SwapChainGL;
1616
r245576r245577
4848      EGLDisplay m_display;
4949      EGLSurface m_surface;
5050   };
51} // namespace bgfx
51} /* namespace gl */ } // namespace bgfx
5252
5353#endif // BGFX_USE_EGL
5454
trunk/3rdparty/bgfx/src/glcontext_glx.cpp
r245576r245577
1212#      define GLX_GLXEXT_PROTOTYPES
1313#      include <glx/glxext.h>
1414
15namespace bgfx
15namespace bgfx { namespace gl
1616{
1717   typedef int (*PFNGLXSWAPINTERVALMESAPROC)(uint32_t _interval);
1818
r245576r245577
5555   void GlContext::create(uint32_t _width, uint32_t _height)
5656   {
5757      BX_UNUSED(_width, _height);
58      XLockDisplay( (::Display*)g_bgfxX11Display);
5958
60      int major, minor;
61      bool version = glXQueryVersion( (::Display*)g_bgfxX11Display, &major, &minor);
62      BGFX_FATAL(version, Fatal::UnableToInitialize, "Failed to query GLX version");
63      BGFX_FATAL( (major == 1 && minor >= 2) || major > 1
64            , Fatal::UnableToInitialize
65            , "GLX version is not >=1.2 (%d.%d)."
66            , major
67            , minor
68            );
59      m_context = (GLXContext)g_bgfxGLX;
6960
70      int32_t screen = DefaultScreen( (::Display*)g_bgfxX11Display);
61      if (NULL == g_bgfxGLX)
62      {
63         XLockDisplay( (::Display*)g_bgfxX11Display);
7164
72      const char* extensions = glXQueryExtensionsString( (::Display*)g_bgfxX11Display, screen);
73      BX_TRACE("GLX extensions:");
74      dumpExtensions(extensions);
65         int major, minor;
66         bool version = glXQueryVersion( (::Display*)g_bgfxX11Display, &major, &minor);
67         BGFX_FATAL(version, Fatal::UnableToInitialize, "Failed to query GLX version");
68         BGFX_FATAL( (major == 1 && minor >= 2) || major > 1
69               , Fatal::UnableToInitialize
70               , "GLX version is not >=1.2 (%d.%d)."
71               , major
72               , minor
73               );
7574
76      const int attrsGlx[] =
77      {
78         GLX_RENDER_TYPE, GLX_RGBA_BIT,
79         GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT,
80         GLX_DOUBLEBUFFER, true,
81         GLX_RED_SIZE, 8,
82         GLX_BLUE_SIZE, 8,
83         GLX_GREEN_SIZE, 8,
84//         GLX_ALPHA_SIZE, 8,
85         GLX_DEPTH_SIZE, 24,
86         GLX_STENCIL_SIZE, 8,
87         0,
88      };
75         int32_t screen = DefaultScreen( (::Display*)g_bgfxX11Display);
8976
90      // Find suitable config
91      GLXFBConfig bestConfig = NULL;
77         const char* extensions = glXQueryExtensionsString( (::Display*)g_bgfxX11Display, screen);
78         BX_TRACE("GLX extensions:");
79         dumpExtensions(extensions);
9280
93      int numConfigs;
94      GLXFBConfig* configs = glXChooseFBConfig( (::Display*)g_bgfxX11Display, screen, attrsGlx, &numConfigs);
81         const int attrsGlx[] =
82         {
83            GLX_RENDER_TYPE, GLX_RGBA_BIT,
84            GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT,
85            GLX_DOUBLEBUFFER, true,
86            GLX_RED_SIZE, 8,
87            GLX_BLUE_SIZE, 8,
88            GLX_GREEN_SIZE, 8,
89            //         GLX_ALPHA_SIZE, 8,
90            GLX_DEPTH_SIZE, 24,
91            GLX_STENCIL_SIZE, 8,
92            0,
93         };
9594
96      BX_TRACE("glX num configs %d", numConfigs);
95         // Find suitable config
96         GLXFBConfig bestConfig = NULL;
9797
98      for (int ii = 0; ii < numConfigs; ++ii)
99      {
100         m_visualInfo = glXGetVisualFromFBConfig( (::Display*)g_bgfxX11Display, configs[ii]);
101         if (NULL != m_visualInfo)
98         int numConfigs;
99         GLXFBConfig* configs = glXChooseFBConfig( (::Display*)g_bgfxX11Display, screen, attrsGlx, &numConfigs);
100
101         BX_TRACE("glX num configs %d", numConfigs);
102
103         for (int ii = 0; ii < numConfigs; ++ii)
102104         {
103            BX_TRACE("---");
104            bool valid = true;
105            for (uint32_t attr = 6; attr < BX_COUNTOF(attrsGlx)-1 && attrsGlx[attr] != None; attr += 2)
105            m_visualInfo = glXGetVisualFromFBConfig( (::Display*)g_bgfxX11Display, configs[ii]);
106            if (NULL != m_visualInfo)
106107            {
107               int value;
108               glXGetFBConfigAttrib( (::Display*)g_bgfxX11Display, configs[ii], attrsGlx[attr], &value);
109               BX_TRACE("glX %d/%d %2d: %4x, %8x (%8x%s)"
110                     , ii
111                     , numConfigs
112                     , attr/2
113                     , attrsGlx[attr]
114                     , value
115                     , attrsGlx[attr + 1]
116                     , value < attrsGlx[attr + 1] ? " *" : ""
117                     );
108               BX_TRACE("---");
109               bool valid = true;
110               for (uint32_t attr = 6; attr < BX_COUNTOF(attrsGlx)-1 && attrsGlx[attr] != None; attr += 2)
111               {
112                  int value;
113                  glXGetFBConfigAttrib( (::Display*)g_bgfxX11Display, configs[ii], attrsGlx[attr], &value);
114                  BX_TRACE("glX %d/%d %2d: %4x, %8x (%8x%s)"
115                        , ii
116                        , numConfigs
117                        , attr/2
118                        , attrsGlx[attr]
119                        , value
120                        , attrsGlx[attr + 1]
121                        , value < attrsGlx[attr + 1] ? " *" : ""
122                        );
118123
119               if (value < attrsGlx[attr + 1])
120               {
121                  valid = false;
124                  if (value < attrsGlx[attr + 1])
125                  {
126                     valid = false;
122127#if !BGFX_CONFIG_DEBUG
123                  break;
128                     break;
124129#endif // BGFX_CONFIG_DEBUG
130                  }
125131               }
132
133               if (valid)
134               {
135                  bestConfig = configs[ii];
136                  BX_TRACE("Best config %d.", ii);
137                  break;
138               }
126139            }
127140
128            if (valid)
129            {
130               bestConfig = configs[ii];
131               BX_TRACE("Best config %d.", ii);
132               break;
133            }
141            XFree(m_visualInfo);
142            m_visualInfo = NULL;
134143         }
135144
136         XFree(m_visualInfo);
137         m_visualInfo = NULL;
138      }
145         XFree(configs);
146         BGFX_FATAL(m_visualInfo, Fatal::UnableToInitialize, "Failed to find a suitable X11 display configuration.");
139147
140      XFree(configs);
141      BGFX_FATAL(m_visualInfo, Fatal::UnableToInitialize, "Failed to find a suitable X11 display configuration.");
148         BX_TRACE("Create GL 2.1 context.");
149         m_context = glXCreateContext( (::Display*)g_bgfxX11Display, m_visualInfo, 0, GL_TRUE);
150         BGFX_FATAL(NULL != m_context, Fatal::UnableToInitialize, "Failed to create GL 2.1 context.");
142151
143      BX_TRACE("Create GL 2.1 context.");
144      m_context = glXCreateContext( (::Display*)g_bgfxX11Display, m_visualInfo, 0, GL_TRUE);
145      BGFX_FATAL(NULL != m_context, Fatal::UnableToInitialize, "Failed to create GL 2.1 context.");
146
147152#if BGFX_CONFIG_RENDERER_OPENGL >= 31
148      glXCreateContextAttribsARB = (PFNGLXCREATECONTEXTATTRIBSARBPROC)glXGetProcAddress( (const GLubyte*)"glXCreateContextAttribsARB");
153         glXCreateContextAttribsARB = (PFNGLXCREATECONTEXTATTRIBSARBPROC)glXGetProcAddress( (const GLubyte*)"glXCreateContextAttribsARB");
149154
150      if (NULL != glXCreateContextAttribsARB)
151      {
152         BX_TRACE("Create GL 3.1 context.");
153         const int contextAttrs[] =
155         if (NULL != glXCreateContextAttribsARB)
154156         {
155            GLX_CONTEXT_MAJOR_VERSION_ARB, 3,
156            GLX_CONTEXT_MINOR_VERSION_ARB, 1,
157            GLX_CONTEXT_PROFILE_MASK_ARB, GLX_CONTEXT_CORE_PROFILE_BIT_ARB,
158            0,
159         };
157            BX_TRACE("Create GL 3.1 context.");
158            const int contextAttrs[] =
159            {
160               GLX_CONTEXT_MAJOR_VERSION_ARB, 3,
161               GLX_CONTEXT_MINOR_VERSION_ARB, 1,
162               GLX_CONTEXT_PROFILE_MASK_ARB, GLX_CONTEXT_CORE_PROFILE_BIT_ARB,
163               0,
164            };
160165
161         GLXContext context = glXCreateContextAttribsARB( (::Display*)g_bgfxX11Display, bestConfig, 0, true, contextAttrs);
166            GLXContext context = glXCreateContextAttribsARB( (::Display*)g_bgfxX11Display, bestConfig, 0, true, contextAttrs);
162167
163         if (NULL != context)
164         {
165            glXDestroyContext( (::Display*)g_bgfxX11Display, m_context);
166            m_context = context;
168            if (NULL != context)
169            {
170               glXDestroyContext( (::Display*)g_bgfxX11Display, m_context);
171               m_context = context;
172            }
167173         }
168      }
169174#else
170      BX_UNUSED(bestConfig);
175         BX_UNUSED(bestConfig);
171176#endif // BGFX_CONFIG_RENDERER_OPENGL >= 31
172177
173      XUnlockDisplay( (::Display*)g_bgfxX11Display);
178         XUnlockDisplay( (::Display*)g_bgfxX11Display);
179      }
174180
175181      import();
176182
r245576r245577
210216   void GlContext::destroy()
211217   {
212218      glXMakeCurrent( (::Display*)g_bgfxX11Display, 0, 0);
213      glXDestroyContext( (::Display*)g_bgfxX11Display, m_context);
214      XFree(m_visualInfo);
219      if (NULL == g_bgfxGLX)
220      {
221         glXDestroyContext( (::Display*)g_bgfxX11Display, m_context);
222         XFree(m_visualInfo);
223      }
224      m_context    = NULL;
225      m_visualInfo = NULL;
215226   }
216227
217228   void GlContext::resize(uint32_t /*_width*/, uint32_t /*_height*/, bool _vsync)
r245576r245577
292303#   include "glimports.h"
293304   }
294305
295} // namespace bgfx
306} /* namespace gl */ } // namespace bgfx
296307
297308#   endif // BGFX_USE_GLX
298309
trunk/3rdparty/bgfx/src/glcontext_glx.h
r245576r245577
1111#   include <X11/Xlib.h>
1212#   include <GL/glx.h>
1313
14namespace bgfx
14namespace bgfx { namespace gl
1515{
1616   struct SwapChainGL;
1717
r245576r245577
4545      GLXContext m_context;
4646      XVisualInfo* m_visualInfo;
4747   };
48} // namespace bgfx
48} /* namespace gl */ } // namespace bgfx
4949
5050#endif // BGFX_USE_GLX
5151
trunk/3rdparty/bgfx/src/glcontext_nsgl.h
r245576r245577
88
99#if BX_PLATFORM_OSX
1010
11namespace bgfx
11namespace bgfx { namespace gl
1212{
1313   struct SwapChainGL;
1414
r245576r245577
3939      void* m_view;
4040      void* m_context;
4141   };
42} // namespace bgfx
42} /* namespace gl */ } // namespace bgfx
4343
4444#endif // BX_PLATFORM_OSX
4545
trunk/3rdparty/bgfx/src/glcontext_nsgl.mm
r245576r245577
1010#   include <Cocoa/Cocoa.h>
1111#   include <bx/os.h>
1212
13namespace bgfx
13namespace bgfx { namespace gl
1414{
1515
1616#   define GL_IMPORT(_optional, _proto, _func, _import) _proto _func
r245576r245577
3535      {
3636      }
3737   };
38   
38
3939   static void* s_opengl = NULL;
4040
4141   void GlContext::create(uint32_t _width, uint32_t _height)
r245576r245577
4646      BX_CHECK(NULL != s_opengl, "OpenGL dynamic library is not found!");
4747
4848      NSWindow* nsWindow = (NSWindow*)g_bgfxNSWindow;
49      m_context = g_bgfxNSGL;
4950
50      NSOpenGLPixelFormatAttribute profile =
51      if (NULL == g_bgfxNSGL)
52      {
53         NSOpenGLPixelFormatAttribute profile =
5154#if BGFX_CONFIG_RENDERER_OPENGL >= 31
52         NSOpenGLProfileVersion3_2Core
55            NSOpenGLProfileVersion3_2Core
5356#else
54         NSOpenGLProfileVersionLegacy
57            NSOpenGLProfileVersionLegacy
5558#endif // BGFX_CONFIG_RENDERER_OPENGL >= 31
56         ;
59            ;
5760
58      NSOpenGLPixelFormatAttribute pixelFormatAttributes[] = {
59         NSOpenGLPFAOpenGLProfile, profile,
60         NSOpenGLPFAColorSize,     24,
61         NSOpenGLPFAAlphaSize,     8,
62         NSOpenGLPFADepthSize,     24,
63         NSOpenGLPFAStencilSize,   8,
64         NSOpenGLPFADoubleBuffer,  true,
65         NSOpenGLPFAAccelerated,   true,
66         NSOpenGLPFANoRecovery,    true,
67         0,                        0,
68      };
61         NSOpenGLPixelFormatAttribute pixelFormatAttributes[] = {
62            NSOpenGLPFAOpenGLProfile, profile,
63            NSOpenGLPFAColorSize,     24,
64            NSOpenGLPFAAlphaSize,     8,
65            NSOpenGLPFADepthSize,     24,
66            NSOpenGLPFAStencilSize,   8,
67            NSOpenGLPFADoubleBuffer,  true,
68            NSOpenGLPFAAccelerated,   true,
69            NSOpenGLPFANoRecovery,    true,
70            0,                        0,
71         };
6972
70      NSOpenGLPixelFormat* pixelFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes:pixelFormatAttributes];
71      BGFX_FATAL(NULL != pixelFormat, Fatal::UnableToInitialize, "Failed to initialize pixel format.");
73         NSOpenGLPixelFormat* pixelFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes:pixelFormatAttributes];
74         BGFX_FATAL(NULL != pixelFormat, Fatal::UnableToInitialize, "Failed to initialize pixel format.");
7275
73      NSRect glViewRect = [[nsWindow contentView] bounds];
74      NSOpenGLView* glView = [[NSOpenGLView alloc] initWithFrame:glViewRect pixelFormat:pixelFormat];
75     
76      [pixelFormat release];
77      [nsWindow setContentView:glView];
78     
79      NSOpenGLContext* glContext = [glView openGLContext];
80      BGFX_FATAL(NULL != glContext, Fatal::UnableToInitialize, "Failed to initialize GL context.");
76         NSRect glViewRect = [[nsWindow contentView] bounds];
77         NSOpenGLView* glView = [[NSOpenGLView alloc] initWithFrame:glViewRect pixelFormat:pixelFormat];
8178
82      [glContext makeCurrentContext];
83      GLint interval = 0;
84      [glContext setValues:&interval forParameter:NSOpenGLCPSwapInterval];
85     
86      m_view    = glView;
87      m_context = glContext;
79         [pixelFormat release];
80         [nsWindow setContentView:glView];
8881
82         NSOpenGLContext* glContext = [glView openGLContext];
83         BGFX_FATAL(NULL != glContext, Fatal::UnableToInitialize, "Failed to initialize GL context.");
84
85         [glContext makeCurrentContext];
86         GLint interval = 0;
87         [glContext setValues:&interval forParameter:NSOpenGLCPSwapInterval];
88
89         m_view    = glView;
90         m_context = glContext;
91      }
92
8993      import();
9094   }
9195
9296   void GlContext::destroy()
9397   {
94      NSOpenGLView* glView = (NSOpenGLView*)m_view;
95      m_view = 0;
98      if (NULL == g_bgfxNSGL)
99      {
100         NSOpenGLView* glView = (NSOpenGLView*)m_view;
101         [glView release];
102      }
103
104      m_view    = 0;
96105      m_context = 0;
97      [glView release];
98
99106      bx::dlclose(s_opengl);
100107   }
101108
r245576r245577
165172#   include "glimports.h"
166173   }
167174
168} // namespace bgfx
175} /* namespace gl */ } // namespace bgfx
169176
170177#endif // BX_PLATFORM_OSX && (BGFX_CONFIG_RENDERER_OPENGLES2|BGFX_CONFIG_RENDERER_OPENGLES3|BGFX_CONFIG_RENDERER_OPENGL)
trunk/3rdparty/bgfx/src/glcontext_ppapi.cpp
r245576r245577
99#   include <bgfxplatform.h>
1010#   include "renderer_gl.h"
1111
12namespace bgfx
12namespace bgfx { namespace gl
1313{
1414#   define GL_IMPORT(_optional, _proto, _func, _import) _proto _func
1515#   include "glimports.h"
1616
1717   void naclSwapCompleteCb(void* /*_data*/, int32_t /*_result*/);
1818
19   PP_CompletionCallback naclSwapComplete =
19   PP_CompletionCallback naclSwapComplete =
2020   {
2121      naclSwapCompleteCb,
2222      NULL,
r245576r245577
6262      PostSwapBuffersFn m_postSwapBuffers;
6363      bool m_forceSwap;
6464   };
65   
65
6666   static Ppapi s_ppapi;
6767
6868   void naclSwapCompleteCb(void* /*_data*/, int32_t /*_result*/)
r245576r245577
9595      s_ppapi.m_instancedArrays->DrawElementsInstancedANGLE(s_ppapi.m_context, _mode, _count, _type, _indices, _primcount);
9696   }
9797
98   bool naclSetInterfaces(PP_Instance _instance, const PPB_Instance* _instInterface, const PPB_Graphics3D* _graphicsInterface, PostSwapBuffersFn _postSwapBuffers)
99   {
100      return s_ppapi.setInterfaces( _instance, _instInterface, _graphicsInterface, _postSwapBuffers);
101   }
102
10398   bool Ppapi::setInterfaces(PP_Instance _instance, const PPB_Instance* _instInterface, const PPB_Graphics3D* _graphicsInterface, PostSwapBuffersFn _postSwapBuffers)
10499   {
105100      BX_TRACE("PPAPI Interfaces");
r245576r245577
192187      return s_ppapi.isValid();
193188   }
194189
190} /* namespace gl */ } // namespace bgfx
191
192namespace bgfx
193{
194   bool naclSetInterfaces(PP_Instance _instance, const PPB_Instance* _instInterface, const PPB_Graphics3D* _graphicsInterface, PostSwapBuffersFn _postSwapBuffers)
195   {
196      return gl::s_ppapi.setInterfaces( _instance, _instInterface, _graphicsInterface, _postSwapBuffers);
197   }
195198} // namespace bgfx
196199
197200#endif // BX_PLATFORM_NACL && (BGFX_CONFIG_RENDERER_OPENGLES || BGFX_CONFIG_RENDERER_OPENGL)
trunk/3rdparty/bgfx/src/glcontext_ppapi.h
r245576r245577
1313#   include <ppapi/c/ppb_instance.h>
1414#   include <ppapi/c/ppb_graphics_3d.h>
1515
16namespace bgfx
16namespace bgfx { namespace gl
1717{
1818   struct SwapChainGL;
1919
r245576r245577
3636      void import();
3737      bool isValid() const;
3838   };
39} // namespace bgfx
39} /* namespace gl */ } // namespace bgfx
4040
4141#endif // BX_PLATFORM_NACL
4242
trunk/3rdparty/bgfx/src/glcontext_wgl.cpp
r245576r245577
1010
1111#   if BGFX_USE_WGL
1212
13namespace bgfx
13namespace bgfx { namespace gl
1414{
1515   PFNWGLGETPROCADDRESSPROC wglGetProcAddress;
1616   PFNWGLMAKECURRENTPROC wglMakeCurrent;
r245576r245577
376376#   include "glimports.h"
377377   }
378378
379} // namespace bgfx
379} } // namespace bgfx
380380
381381#   endif // BGFX_USE_WGL
382382#endif // (BGFX_CONFIG_RENDERER_OPENGLES|BGFX_CONFIG_RENDERER_OPENGL)
trunk/3rdparty/bgfx/src/glcontext_wgl.h
r245576r245577
1010
1111#include <wgl/wglext.h>
1212
13namespace bgfx
13namespace bgfx { namespace gl
1414{
1515typedef PROC (APIENTRYP PFNWGLGETPROCADDRESSPROC) (LPCSTR lpszProc);
1616typedef BOOL (APIENTRYP PFNWGLMAKECURRENTPROC) (HDC hdc, HGLRC hglrc);
r245576r245577
9393      HGLRC m_context;
9494      HDC m_hdc;
9595   };
96} // namespace bgfx
96} /* namespace gl */ } // namespace bgfx
9797
9898#endif // BGFX_USE_WGL
9999
trunk/3rdparty/bgfx/src/image.cpp
r245576r245577
12351235#define DDS_BC5U BX_MAKEFOURCC('B', 'C', '5', 'U')
12361236#define DDS_DX10 BX_MAKEFOURCC('D', 'X', '1', '0')
12371237
1238#define D3DFMT_A8R8G8B8       21
1239#define D3DFMT_R5G6B5         23
1240#define D3DFMT_A1R5G5B5       25
1241#define D3DFMT_A4R4G4B4       26
1242#define D3DFMT_A2B10G10R10    31
1243#define D3DFMT_G16R16         34
1244#define D3DFMT_A2R10G10B10    35
1245#define D3DFMT_A16B16G16R16   36
1246#define D3DFMT_A8L8           51
1247#define D3DFMT_R16F           111
1248#define D3DFMT_G16R16F        112
1249#define D3DFMT_A16B16G16R16F  113
1250#define D3DFMT_R32F           114
1251#define D3DFMT_G32R32F        115
1252#define D3DFMT_A32B32G32R32F  116
1238#define DDS_A8R8G8B8       21
1239#define DDS_R5G6B5         23
1240#define DDS_A1R5G5B5       25
1241#define DDS_A4R4G4B4       26
1242#define DDS_A2B10G10R10    31
1243#define DDS_G16R16         34
1244#define DDS_A2R10G10B10    35
1245#define DDS_A16B16G16R16   36
1246#define DDS_A8L8           51
1247#define DDS_R16F           111
1248#define DDS_G16R16F        112
1249#define DDS_A16B16G16R16F  113
1250#define DDS_R32F           114
1251#define DDS_G32R32F        115
1252#define DDS_A32B32G32R32F  116
12531253
1254#define DXGI_FORMAT_R32G32B32A32_FLOAT 2
1255#define DXGI_FORMAT_R32G32B32A32_UINT  3
1256#define DXGI_FORMAT_R16G16B16A16_FLOAT 10
1257#define DXGI_FORMAT_R16G16B16A16_UNORM 11
1258#define DXGI_FORMAT_R16G16B16A16_UINT  12
1259#define DXGI_FORMAT_R32G32_FLOAT       16
1260#define DXGI_FORMAT_R32G32_UINT        17
1261#define DXGI_FORMAT_R10G10B10A2_UNORM  24
1262#define DXGI_FORMAT_R16G16_FLOAT       34
1263#define DXGI_FORMAT_R16G16_UNORM       35
1264#define DXGI_FORMAT_R32_FLOAT          41
1265#define DXGI_FORMAT_R32_UINT           42
1266#define DXGI_FORMAT_R8G8_UNORM         49
1267#define DXGI_FORMAT_R16_FLOAT          54
1268#define DXGI_FORMAT_R16_UNORM          56
1269#define DXGI_FORMAT_R8_UNORM           61
1270#define DXGI_FORMAT_BC1_UNORM          71
1271#define DXGI_FORMAT_BC2_UNORM          74
1272#define DXGI_FORMAT_BC3_UNORM          77
1273#define DXGI_FORMAT_BC4_UNORM          80
1274#define DXGI_FORMAT_BC5_UNORM          83
1275#define DXGI_FORMAT_B5G6R5_UNORM       85
1276#define DXGI_FORMAT_B5G5R5A1_UNORM     86
1277#define DXGI_FORMAT_B8G8R8A8_UNORM     87
1278#define DXGI_FORMAT_BC6H_SF16          96
1279#define DXGI_FORMAT_BC7_UNORM          98
1280#define DXGI_FORMAT_B4G4R4A4_UNORM     115
1254#define DDS_FORMAT_R32G32B32A32_FLOAT 2
1255#define DDS_FORMAT_R32G32B32A32_UINT  3
1256#define DDS_FORMAT_R16G16B16A16_FLOAT 10
1257#define DDS_FORMAT_R16G16B16A16_UNORM 11
1258#define DDS_FORMAT_R16G16B16A16_UINT  12
1259#define DDS_FORMAT_R32G32_FLOAT       16
1260#define DDS_FORMAT_R32G32_UINT        17
1261#define DDS_FORMAT_R10G10B10A2_UNORM  24
1262#define DDS_FORMAT_R16G16_FLOAT       34
1263#define DDS_FORMAT_R16G16_UNORM       35
1264#define DDS_FORMAT_R32_FLOAT          41
1265#define DDS_FORMAT_R32_UINT           42
1266#define DDS_FORMAT_R8G8_UNORM         49
1267#define DDS_FORMAT_R16_FLOAT          54
1268#define DDS_FORMAT_R16_UNORM          56
1269#define DDS_FORMAT_R8_UNORM           61
1270#define DDS_FORMAT_BC1_UNORM          71
1271#define DDS_FORMAT_BC2_UNORM          74
1272#define DDS_FORMAT_BC3_UNORM          77
1273#define DDS_FORMAT_BC4_UNORM          80
1274#define DDS_FORMAT_BC5_UNORM          83
1275#define DDS_FORMAT_B5G6R5_UNORM       85
1276#define DDS_FORMAT_B5G5R5A1_UNORM     86
1277#define DDS_FORMAT_B8G8R8A8_UNORM     87
1278#define DDS_FORMAT_BC6H_SF16          96
1279#define DDS_FORMAT_BC7_UNORM          98
1280#define DDS_FORMAT_B4G4R4A4_UNORM     115
12811281
12821282#define DDSD_CAPS                   0x00000001
12831283#define DDSD_HEIGHT                 0x00000002
r245576r245577
13311331      { DDS_BC4U,                  TextureFormat::BC4     },
13321332      { DDS_ATI2,                  TextureFormat::BC5     },
13331333      { DDS_BC5U,                  TextureFormat::BC5     },
1334      { D3DFMT_A16B16G16R16,       TextureFormat::RGBA16  },
1335      { D3DFMT_A16B16G16R16F,      TextureFormat::RGBA16F },
1334      { DDS_A16B16G16R16,          TextureFormat::RGBA16  },
1335      { DDS_A16B16G16R16F,         TextureFormat::RGBA16F },
13361336      { DDPF_RGB|DDPF_ALPHAPIXELS, TextureFormat::BGRA8   },
13371337      { DDPF_INDEXED,              TextureFormat::R8      },
13381338      { DDPF_LUMINANCE,            TextureFormat::R8      },
13391339      { DDPF_ALPHA,                TextureFormat::R8      },
1340      { D3DFMT_R16F,               TextureFormat::R16F    },
1341      { D3DFMT_R32F,               TextureFormat::R32F    },
1342      { D3DFMT_A8L8,               TextureFormat::RG8     },
1343      { D3DFMT_G16R16,             TextureFormat::RG16    },
1344      { D3DFMT_G16R16F,            TextureFormat::RG16F   },
1345      { D3DFMT_G32R32F,            TextureFormat::RG32F   },
1346      { D3DFMT_A8R8G8B8,           TextureFormat::BGRA8   },
1347      { D3DFMT_A16B16G16R16,       TextureFormat::RGBA16  },
1348      { D3DFMT_A16B16G16R16F,      TextureFormat::RGBA16F },
1349      { D3DFMT_A32B32G32R32F,      TextureFormat::RGBA32F },
1350      { D3DFMT_R5G6B5,             TextureFormat::R5G6B5  },
1351      { D3DFMT_A4R4G4B4,           TextureFormat::RGBA4   },
1352      { D3DFMT_A1R5G5B5,           TextureFormat::RGB5A1  },
1353      { D3DFMT_A2B10G10R10,        TextureFormat::RGB10A2 },
1340      { DDS_R16F,                  TextureFormat::R16F    },
1341      { DDS_R32F,                  TextureFormat::R32F    },
1342      { DDS_A8L8,                  TextureFormat::RG8     },
1343      { DDS_G16R16,                TextureFormat::RG16    },
1344      { DDS_G16R16F,               TextureFormat::RG16F   },
1345      { DDS_G32R32F,               TextureFormat::RG32F   },
1346      { DDS_A8R8G8B8,              TextureFormat::BGRA8   },
1347      { DDS_A16B16G16R16,          TextureFormat::RGBA16  },
1348      { DDS_A16B16G16R16F,         TextureFormat::RGBA16F },
1349      { DDS_A32B32G32R32F,         TextureFormat::RGBA32F },
1350      { DDS_R5G6B5,                TextureFormat::R5G6B5  },
1351      { DDS_A4R4G4B4,              TextureFormat::RGBA4   },
1352      { DDS_A1R5G5B5,              TextureFormat::RGB5A1  },
1353      { DDS_A2B10G10R10,           TextureFormat::RGB10A2 },
13541354   };
13551355
13561356   static TranslateDdsFormat s_translateDxgiFormat[] =
13571357   {
1358      { DXGI_FORMAT_BC1_UNORM,          TextureFormat::BC1     },
1359      { DXGI_FORMAT_BC2_UNORM,          TextureFormat::BC2     },
1360      { DXGI_FORMAT_BC3_UNORM,          TextureFormat::BC3     },
1361      { DXGI_FORMAT_BC4_UNORM,          TextureFormat::BC4     },
1362      { DXGI_FORMAT_BC5_UNORM,          TextureFormat::BC5     },
1363      { DXGI_FORMAT_BC6H_SF16,          TextureFormat::BC6H    },
1364      { DXGI_FORMAT_BC7_UNORM,          TextureFormat::BC7     },
1358      { DDS_FORMAT_BC1_UNORM,          TextureFormat::BC1     },
1359      { DDS_FORMAT_BC2_UNORM,          TextureFormat::BC2     },
1360      { DDS_FORMAT_BC3_UNORM,          TextureFormat::BC3     },
1361      { DDS_FORMAT_BC4_UNORM,          TextureFormat::BC4     },
1362      { DDS_FORMAT_BC5_UNORM,          TextureFormat::BC5     },
1363      { DDS_FORMAT_BC6H_SF16,          TextureFormat::BC6H    },
1364      { DDS_FORMAT_BC7_UNORM,          TextureFormat::BC7     },
13651365
1366      { DXGI_FORMAT_R8_UNORM,           TextureFormat::R8      },
1367      { DXGI_FORMAT_R16_UNORM,          TextureFormat::R16     },
1368      { DXGI_FORMAT_R16_FLOAT,          TextureFormat::R16F    },
1369      { DXGI_FORMAT_R32_UINT,           TextureFormat::R32     },
1370      { DXGI_FORMAT_R32_FLOAT,          TextureFormat::R32F    },
1371      { DXGI_FORMAT_R8G8_UNORM,         TextureFormat::RG8     },
1372      { DXGI_FORMAT_R16G16_UNORM,       TextureFormat::RG16    },
1373      { DXGI_FORMAT_R16G16_FLOAT,       TextureFormat::RG16F   },
1374      { DXGI_FORMAT_R32G32_UINT,        TextureFormat::RG32    },
1375      { DXGI_FORMAT_R32G32_FLOAT,       TextureFormat::RG32F   },
1376      { DXGI_FORMAT_B8G8R8A8_UNORM,     TextureFormat::BGRA8   },
1377      { DXGI_FORMAT_R16G16B16A16_UNORM, TextureFormat::RGBA16  },
1378      { DXGI_FORMAT_R16G16B16A16_FLOAT, TextureFormat::RGBA16F },
1379      { DXGI_FORMAT_R32G32B32A32_UINT,  TextureFormat::RGBA32  },
1380      { DXGI_FORMAT_R32G32B32A32_FLOAT, TextureFormat::RGBA32F },
1381      { DXGI_FORMAT_B5G6R5_UNORM,       TextureFormat::R5G6B5  },
1382      { DXGI_FORMAT_B4G4R4A4_UNORM,     TextureFormat::RGBA4   },
1383      { DXGI_FORMAT_B5G5R5A1_UNORM,     TextureFormat::RGB5A1  },
1384      { DXGI_FORMAT_R10G10B10A2_UNORM,  TextureFormat::RGB10A2 },
1366      { DDS_FORMAT_R8_UNORM,           TextureFormat::R8      },
1367      { DDS_FORMAT_R16_UNORM,          TextureFormat::R16     },
1368      { DDS_FORMAT_R16_FLOAT,          TextureFormat::R16F    },
1369      { DDS_FORMAT_R32_UINT,           TextureFormat::R32     },
1370      { DDS_FORMAT_R32_FLOAT,          TextureFormat::R32F    },
1371      { DDS_FORMAT_R8G8_UNORM,         TextureFormat::RG8     },
1372      { DDS_FORMAT_R16G16_UNORM,       TextureFormat::RG16    },
1373      { DDS_FORMAT_R16G16_FLOAT,       TextureFormat::RG16F   },
1374      { DDS_FORMAT_R32G32_UINT,        TextureFormat::RG32    },
1375      { DDS_FORMAT_R32G32_FLOAT,       TextureFormat::RG32F   },
1376      { DDS_FORMAT_B8G8R8A8_UNORM,     TextureFormat::BGRA8   },
1377      { DDS_FORMAT_R16G16B16A16_UNORM, TextureFormat::RGBA16  },
1378      { DDS_FORMAT_R16G16B16A16_FLOAT, TextureFormat::RGBA16F },
1379      { DDS_FORMAT_R32G32B32A32_UINT,  TextureFormat::RGBA32  },
1380      { DDS_FORMAT_R32G32B32A32_FLOAT, TextureFormat::RGBA32F },
1381      { DDS_FORMAT_B5G6R5_UNORM,       TextureFormat::R5G6B5  },
1382      { DDS_FORMAT_B4G4R4A4_UNORM,     TextureFormat::RGBA4   },
1383      { DDS_FORMAT_B5G5R5A1_UNORM,     TextureFormat::RGB5A1  },
1384      { DDS_FORMAT_R10G10B10A2_UNORM,  TextureFormat::RGB10A2 },
13851385   };
13861386
13871387   struct TranslateDdsPixelFormat
trunk/3rdparty/bgfx/src/ovr.cpp
r245576r245577
123123      result = ovrHmd_ConfigureRendering(m_hmd
124124         , _config
125125         , 0
126         | ovrDistortionCap_Chromatic
126#if OVR_VERSION < OVR_VERSION_050
127         | ovrDistortionCap_Chromatic // permanently enabled >= v5.0
128#endif
127129         | ovrDistortionCap_Vignette
128130         | ovrDistortionCap_TimeWarp
129131         | ovrDistortionCap_Overdrive
trunk/3rdparty/bgfx/src/ovr.h
r245576r245577
33 * License: http://www.opensource.org/licenses/BSD-2-Clause
44 */
55
6#ifndef BGFX_OVR_H_HEADER_GUARD
7#define BGFX_OVR_H_HEADER_GUARD
8
69#include "bgfx_p.h"
710
811#if BGFX_CONFIG_USE_OVR
912
10#   include <OVR.h>
13#   include <OVR_Version.h>
1114
1215#   define OVR_VERSION_(_a, _b, _c) (_a * 10000 + _b * 100 + _c)
1316#   define OVR_VERSION     OVR_VERSION_(OVR_MAJOR_VERSION, OVR_MINOR_VERSION, OVR_BUILD_VERSION)
1417#   define OVR_VERSION_042 OVR_VERSION_(0, 4, 2)
1518#   define OVR_VERSION_043 OVR_VERSION_(0, 4, 3)
1619#   define OVR_VERSION_044 OVR_VERSION_(0, 4, 4)
20#   define OVR_VERSION_050 OVR_VERSION_(0, 5, 0)
1721
22#   if OVR_VERSION < OVR_VERSION_050
23#      include <OVR.h>
24#   else
25#      include <OVR_CAPI.h>
26#   endif // OVR_VERSION < OVR_VERSION_050
27
1828#   if BGFX_CONFIG_RENDERER_DIRECT3D9
1929#      define OVR_D3D_VERSION 9
20#      include <OVR_D3D.h>
30#      if OVR_VERSION < OVR_VERSION_050
31#         include <OVR_D3D.h>
32#      else
33#         include <OVR_CAPI_D3D.h>
34#      endif
2135#   endif // BGFX_CONFIG_RENDERER_DIRECT3D9
2236
2337#   if BGFX_CONFIG_RENDERER_DIRECT3D11
r245576r245577
2640#         undef OVR_D3D_VERSION
2741#      endif // OVR_CAPI_D3D_h
2842#      define OVR_D3D_VERSION 11
29#      include <OVR_D3D.h>
43#      if OVR_VERSION < OVR_VERSION_050
44#         include <OVR_D3D.h>
45#      else
46#         include <OVR_CAPI_D3D.h>
47#      endif
3048#   endif // BGFX_CONFIG_RENDERER_DIRECT3D11
3149
3250#   if BGFX_CONFIG_RENDERER_OPENGL
33#      include <OVR_GL.h>
51#      if OVR_VERSION < OVR_VERSION_050
52#         include <OVR_GL.h>
53#      else
54#         include <OVR_CAPI_GL.h>
55#      endif
3456#   endif // BGFX_CONFIG_RENDERER_OPENGL
3557
3658namespace bgfx
r245576r245577
146168} // namespace bgfx
147169
148170#endif // BGFX_CONFIG_USE_OVR
171
172#endif // BGFX_OVR_H_HEADER_GUARD
trunk/3rdparty/bgfx/src/renderdoc.h
r245576r245577
33 * License: http://www.opensource.org/licenses/BSD-2-Clause
44 */
55
6#ifndef BGFX_RENDERDOC_H_HEADER_GUARD
7#define BGFX_RENDERDOC_H_HEADER_GUARD
8
69namespace bgfx
710{
811   void* loadRenderDoc();
912   void unloadRenderDoc(void*);
1013
1114} // namespace bgfx
15
16#endif // BGFX_RENDERDOC_H_HEADER_GUARD
trunk/3rdparty/bgfx/src/renderer.h
r245576r245577
33 * License: http://www.opensource.org/licenses/BSD-2-Clause
44 */
55
6#ifndef BGFX_RENDERER_H_HEADER_GUARD
7#define BGFX_RENDERER_H_HEADER_GUARD
8
69#include "bgfx_p.h"
710
811namespace bgfx
r245576r245577
262265   };
263266
264267} // namespace bgfx
268
269#endif // BGFX_RENDERER_H_HEADER_GUARD
trunk/3rdparty/bgfx/src/renderer_d3d11.cpp
r245576r245577
88#if BGFX_CONFIG_RENDERER_DIRECT3D11
99#   include "renderer_d3d11.h"
1010
11namespace bgfx
11namespace bgfx { namespace d3d11
1212{
1313   static wchar_t s_viewNameW[BGFX_CONFIG_MAX_VIEWS][BGFX_CONFIG_MAX_VIEW_NAME];
1414
r245576r245577
513513         m_driverType = D3D_DRIVER_TYPE_HARDWARE;
514514
515515         IDXGIAdapter* adapter;
516         for (uint32_t ii = 0; DXGI_ERROR_NOT_FOUND != factory->EnumAdapters(ii, &adapter); ++ii)
516         for (uint32_t ii = 0
517            ; DXGI_ERROR_NOT_FOUND != factory->EnumAdapters(ii, &adapter) && ii < BX_COUNTOF(g_caps.gpu)
518            ; ++ii
519            )
517520         {
518521            DXGI_ADAPTER_DESC desc;
519522            hr = adapter->GetDesc(&desc);
r245576r245577
536539                  , desc.SharedSystemMemory
537540                  );
538541
539               if (BX_ENABLED(BGFX_CONFIG_DEBUG_PERFHUD)
540               &&  0 != strstr(description, "PerfHUD") )
542               g_caps.gpu[ii].vendorId = (uint16_t)desc.VendorId;
543               g_caps.gpu[ii].deviceId = (uint16_t)desc.DeviceId;
544               ++g_caps.numGPUs;
545
546               if (NULL == m_adapter)
541547               {
542                  m_adapter = adapter;
543                  m_driverType = D3D_DRIVER_TYPE_REFERENCE;
548                  if ( (BGFX_PCI_ID_NONE != g_caps.vendorId ||             0 != g_caps.deviceId)
549                  &&   (BGFX_PCI_ID_NONE == g_caps.vendorId || desc.VendorId == g_caps.vendorId)
550                  &&   (               0 == g_caps.deviceId || desc.DeviceId == g_caps.deviceId) )
551                  {
552                     m_adapter = adapter;
553                     m_adapter->AddRef();
554                     m_driverType = D3D_DRIVER_TYPE_UNKNOWN;
555                  }
556
557                  if (BX_ENABLED(BGFX_CONFIG_DEBUG_PERFHUD)
558                  &&  0 != strstr(description, "PerfHUD") )
559                  {
560                     m_adapter = adapter;
561                     m_driverType = D3D_DRIVER_TYPE_REFERENCE;
562                  }
544563               }
545564            }
546565
r245576r245577
594613         }
595614         BGFX_FATAL(SUCCEEDED(hr), Fatal::UnableToInitialize, "Unable to create Direct3D11 device.");
596615
616         if (NULL != m_adapter)
617         {
618            DX_RELEASE(m_adapter, 2);
619         }
620
597621         IDXGIDevice* device = NULL;
598622         hr = E_FAIL;
599623         for (uint32_t ii = 0; ii < BX_COUNTOF(s_deviceIIDs) && FAILED(hr); ++ii)
r245576r245577
616640
617641         hr = adapter->GetDesc(&m_adapterDesc);
618642         BGFX_FATAL(SUCCEEDED(hr), Fatal::UnableToInitialize, "Unable to create Direct3D11 device.");
643         g_caps.vendorId = (uint16_t)m_adapterDesc.VendorId;
644         g_caps.deviceId = (uint16_t)m_adapterDesc.DeviceId;
619645
620646#if BX_PLATFORM_WINRT
621647         hr = adapter->GetParent(__uuidof(IDXGIFactory2), (void**)&m_factory);
r245576r245577
673699
674700         m_numWindows = 1;
675701
702#if !defined(__MINGW32__)
676703         if (BX_ENABLED(BGFX_CONFIG_DEBUG) )
677704         {
678705            ID3D11InfoQueue* infoQueue;
r245576r245577
704731               setGraphicsDebuggerPresent(true);
705732            }
706733         }
734#endif // __MINGW__
707735
708736         UniformHandle handle = BGFX_INVALID_HANDLE;
709737         for (uint32_t ii = 0; ii < PredefinedUniform::Count; ++ii)
r245576r245577
734762            {
735763               D3D11_FEATURE_DATA_FORMAT_SUPPORT data; // D3D11_FEATURE_DATA_FORMAT_SUPPORT2
736764               data.InFormat = s_textureFormat[ii].m_fmt;
737               HRESULT hr = m_device->CheckFeatureSupport(D3D11_FEATURE_FORMAT_SUPPORT, &data, sizeof(data) );
765               hr = m_device->CheckFeatureSupport(D3D11_FEATURE_FORMAT_SUPPORT, &data, sizeof(data) );
738766               if (SUCCEEDED(hr) )
739767               {
740768                  support |= 0 != (data.OutFormatSupport & (0
r245576r245577
22992327
23002328   static RendererContextD3D11* s_renderD3D11;
23012329
2302   RendererContextI* rendererCreateD3D11()
2330   RendererContextI* rendererCreate()
23032331   {
23042332      s_renderD3D11 = BX_NEW(g_allocator, RendererContextD3D11);
23052333      s_renderD3D11->init();
23062334      return s_renderD3D11;
23072335   }
23082336
2309   void rendererDestroyD3D11()
2337   void rendererDestroy()
23102338   {
23112339      s_renderD3D11->shutdown();
23122340      BX_DELETE(g_allocator, s_renderD3D11);
r245576r245577
31233151      uint32_t statsNumPrimsRendered[BX_COUNTOF(s_primInfo)] = {};
31243152      uint32_t statsNumInstances[BX_COUNTOF(s_primInfo)] = {};
31253153      uint32_t statsNumIndices = 0;
3154      uint32_t statsKeyType[2] = {};
31263155
31273156      if (0 == (_render->m_debug&BGFX_DEBUG_IFH) )
31283157      {
r245576r245577
31353164         for (int32_t item = 0, restartItem = numItems; item < numItems || restartItem < numItems;)
31363165         {
31373166            const bool isCompute = key.decode(_render->m_sortKeys[item], _render->m_viewRemap);
3167            statsKeyType[isCompute]++;
3168
31383169            const bool viewChanged = 0
31393170               || key.m_view != view
31403171               || item == numItems
r245576r245577
37783809               );
37793810
37803811            double elapsedCpuMs = double(elapsed)*toMs;
3781            tvm.printf(10, pos++, 0x8e, "  Draw calls: %4d / CPU %3.4f [ms]"
3812            tvm.printf(10, pos++, 0x8e, "  Submitted: %4d (draw %4d, compute %4d) / CPU %3.4f [ms]"
37823813               , _render->m_num
3814               , statsKeyType[0]
3815               , statsKeyType[1]
37833816               , elapsedCpuMs
37843817               );
37853818            for (uint32_t ii = 0; ii < BX_COUNTOF(s_primName); ++ii)
r245576r245577
38393872         PIX_ENDEVENT();
38403873      }
38413874   }
3842} // namespace bgfx
3875} /* namespace d3d11 */ } // namespace bgfx
38433876
38443877#else
38453878
3846namespace bgfx
3879namespace bgfx { namespace d3d11
38473880{
3848   RendererContextI* rendererCreateD3D11()
3881   RendererContextI* rendererCreate()
38493882   {
38503883      return NULL;
38513884   }
38523885
3853   void rendererDestroyD3D11()
3886   void rendererDestroy()
38543887   {
38553888   }
3856} // namespace bgfx
3889} /* namespace d3d11 */ } // namespace bgfx
38573890
38583891#endif // BGFX_CONFIG_RENDERER_DIRECT3D11
trunk/3rdparty/bgfx/src/renderer_d3d11.h
r245576r245577
4949#   define D3D_FEATURE_LEVEL_11_1 D3D_FEATURE_LEVEL(0xb100)
5050#endif // D3D_FEATURE_LEVEL_11_1
5151
52#if defined(__MINGW32__)
5253// MinGW Linux/Wine missing defines...
53#ifndef D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT
54#   define D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT 8
55#endif // D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT
54#   ifndef D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT
55#      define D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT 8
56#   endif // D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT
5657
57#ifndef D3D11_PS_CS_UAV_REGISTER_COUNT
58#   define D3D11_PS_CS_UAV_REGISTER_COUNT 8
59#endif // D3D11_PS_CS_UAV_REGISTER_COUNT
58#   ifndef D3D11_PS_CS_UAV_REGISTER_COUNT
59#      define D3D11_PS_CS_UAV_REGISTER_COUNT 8
60#   endif // D3D11_PS_CS_UAV_REGISTER_COUNT
6061
61#ifndef D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
62#   define D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT 8
63#endif
62#   ifndef D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT
63#      define D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT 8
64#   endif
6465
65#ifndef D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
66#   define D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT 8
67#endif // D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
66#   ifndef D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
67#      define D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT 8
68#   endif // D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
6869
69#ifndef D3D11_APPEND_ALIGNED_ELEMENT
70#   define D3D11_APPEND_ALIGNED_ELEMENT UINT32_MAX
71#endif // D3D11_APPEND_ALIGNED_ELEMENT
70#   ifndef D3D11_APPEND_ALIGNED_ELEMENT
71#      define D3D11_APPEND_ALIGNED_ELEMENT UINT32_MAX
72#   endif // D3D11_APPEND_ALIGNED_ELEMENT
7273
73namespace bgfx
74#   ifndef D3D11_REQ_MAXANISOTROPY
75#      define   D3D11_REQ_MAXANISOTROPY   16
76#   endif // D3D11_REQ_MAXANISOTROPY
77
78#   ifndef D3D11_FEATURE_DATA_FORMAT_SUPPORT
79typedef struct D3D11_FEATURE_DATA_FORMAT_SUPPORT
7480{
81   DXGI_FORMAT InFormat;
82   UINT OutFormatSupport;
83} D3D11_FEATURE_DATA_FORMAT_SUPPORT;
84#   endif // D3D11_FEATURE_DATA_FORMAT_SUPPORT
85
86#   ifndef D3D11_FEATURE_DATA_FORMAT_SUPPORT2
87typedef struct D3D11_FEATURE_DATA_FORMAT_SUPPORT2
88{
89   DXGI_FORMAT InFormat;
90   UINT OutFormatSupport2;
91} D3D11_FEATURE_DATA_FORMAT_SUPPORT2;
92#   endif // D3D11_FEATURE_DATA_FORMAT_SUPPORT2
93#endif // __MINGW32__
94
95namespace bgfx { namespace d3d11
96{
7597   struct BufferD3D11
7698   {
7799      BufferD3D11()
r245576r245577
280302      uint8_t m_num;
281303   };
282304
283} // namespace bgfx
305} /*  namespace d3d11 */ } // namespace bgfx
284306
285307#endif // BGFX_RENDERER_D3D11_H_HEADER_GUARD
trunk/3rdparty/bgfx/src/renderer_d3d12.cpp
r245576r245577
99#   include "../../d3d12/src/renderer_d3d12.cpp"
1010#else
1111
12namespace bgfx
12namespace bgfx { namespace d3d12
1313{
14   RendererContextI* rendererCreateD3D12()
14   RendererContextI* rendererCreate()
1515   {
1616      return NULL;
1717   }
1818
19   void rendererDestroyD3D12()
19   void rendererDestroy()
2020   {
2121   }
22} // namespace bgfx
22} /* namespace d3d12 */ } // namespace bgfx
2323
2424#endif // BGFX_CONFIG_RENDERER_DIRECT3D12
trunk/3rdparty/bgfx/src/renderer_d3d9.cpp
r245576r245577
88#if BGFX_CONFIG_RENDERER_DIRECT3D9
99#   include "renderer_d3d9.h"
1010
11namespace bgfx
11namespace bgfx { namespace d3d9
1212{
1313   static wchar_t s_viewNameW[BGFX_CONFIG_MAX_VIEWS][BGFX_CONFIG_MAX_VIEW_NAME];
1414
r245576r245577
359359         m_adapter = D3DADAPTER_DEFAULT;
360360         m_deviceType = D3DDEVTYPE_HAL;
361361
362         uint32_t adapterCount = m_d3d9->GetAdapterCount();
363         for (uint32_t ii = 0; ii < adapterCount; ++ii)
362         uint8_t numGPUs = bx::uint32_min(BX_COUNTOF(g_caps.gpu), m_d3d9->GetAdapterCount() );
363         for (uint32_t ii = 0; ii < numGPUs; ++ii)
364364         {
365            D3DADAPTER_IDENTIFIER9 identifier;
366            HRESULT hr = m_d3d9->GetAdapterIdentifier(ii, 0, &identifier);
365            D3DADAPTER_IDENTIFIER9 desc;
366            HRESULT hr = m_d3d9->GetAdapterIdentifier(ii, 0, &desc);
367367            if (SUCCEEDED(hr) )
368            {
368            {         
369369               BX_TRACE("Adapter #%d", ii);
370               BX_TRACE("\tDriver: %s", identifier.Driver);
371               BX_TRACE("\tDescription: %s", identifier.Description);
372               BX_TRACE("\tDeviceName: %s", identifier.DeviceName);
370               BX_TRACE("\tDriver: %s", desc.Driver);
371               BX_TRACE("\tDescription: %s", desc.Description);
372               BX_TRACE("\tDeviceName: %s", desc.DeviceName);
373373               BX_TRACE("\tVendorId: 0x%08x, DeviceId: 0x%08x, SubSysId: 0x%08x, Revision: 0x%08x"
374                  , identifier.VendorId
375                  , identifier.DeviceId
376                  , identifier.SubSysId
377                  , identifier.Revision
374                  , desc.VendorId
375                  , desc.DeviceId
376                  , desc.SubSysId
377                  , desc.Revision
378378                  );
379379
380#if BGFX_CONFIG_DEBUG_PERFHUD
381               if (0 != strstr(identifier.Description, "PerfHUD") )
380               g_caps.gpu[ii].vendorId = (uint16_t)desc.VendorId;
381               g_caps.gpu[ii].deviceId = (uint16_t)desc.DeviceId;
382
383               if (D3DADAPTER_DEFAULT == m_adapter)
382384               {
383                  m_adapter = ii;
384                  m_deviceType = D3DDEVTYPE_REF;
385                  if ( (BGFX_PCI_ID_NONE != g_caps.vendorId ||             0 != g_caps.deviceId)
386                  &&   (BGFX_PCI_ID_NONE == g_caps.vendorId || desc.VendorId == g_caps.vendorId)
387                  &&   (               0 == g_caps.deviceId || desc.DeviceId == g_caps.deviceId) )
388                  {
389                     m_adapter = ii;
390                  }
391
392                  if (BX_ENABLED(BGFX_CONFIG_DEBUG_PERFHUD)
393                  &&  0 != strstr(desc.Description, "PerfHUD"))
394                  {
395                     m_adapter = ii;
396                     m_deviceType = D3DDEVTYPE_REF;
397                  }
385398               }
386#endif // BGFX_CONFIG_DEBUG_PERFHUD
387399            }
388400         }
389401
390402         DX_CHECK(m_d3d9->GetAdapterIdentifier(m_adapter, 0, &m_identifier) );
391         m_amd = m_identifier.VendorId == 0x1002;
392         m_nvidia = m_identifier.VendorId == 0x10de;
403         m_amd    = m_identifier.VendorId == BGFX_PCI_ID_AMD;
404         m_nvidia = m_identifier.VendorId == BGFX_PCI_ID_NVIDIA;
405         g_caps.vendorId = (uint16_t)m_identifier.VendorId;
406         g_caps.deviceId = (uint16_t)m_identifier.DeviceId;
393407
394408         uint32_t behaviorFlags[] =
395409         {
r245576r245577
17311745
17321746   static RendererContextD3D9* s_renderD3D9;
17331747
1734   RendererContextI* rendererCreateD3D9()
1748   RendererContextI* rendererCreate()
17351749   {
17361750      s_renderD3D9 = BX_NEW(g_allocator, RendererContextD3D9);
17371751      s_renderD3D9->init();
17381752      return s_renderD3D9;
17391753   }
17401754
1741   void rendererDestroyD3D9()
1755   void rendererDestroy()
17421756   {
17431757      s_renderD3D9->shutdown();
17441758      BX_DELETE(g_allocator, s_renderD3D9);
r245576r245577
22152229            if (NULL != _rect)
22162230            {
22172231               RECT rect;
2218               rect.left = _rect->m_x;
2219               rect.top = _rect->m_y;
2220               rect.right = rect.left + _rect->m_width;
2221               rect.bottom = rect.top + _rect->m_height;
2232               rect.left   = _rect->m_x;
2233               rect.top    = _rect->m_y;
2234               rect.right  = rect.left + _rect->m_width;
2235               rect.bottom = rect.top  + _rect->m_height;
22222236               DX_CHECK(m_texture2d->LockRect(_lod, &lockedRect, &rect, 0) );
22232237            }
22242238            else
r245576r245577
24942508
24952509      if (convert)
24962510      {
2497         uint8_t* temp = (uint8_t*)BX_ALLOC(g_allocator, rectpitch*_rect.m_height);
2511         temp = (uint8_t*)BX_ALLOC(g_allocator, rectpitch*_rect.m_height);
24982512         imageDecodeToBgra8(temp, data, _rect.m_width, _rect.m_height, srcpitch, m_requestedFormat);
24992513         data = temp;
25002514      }
r245576r245577
28642878      FrameBufferHandle fbh = BGFX_INVALID_HANDLE;
28652879      uint32_t blendFactor = 0;
28662880
2867      const uint64_t pt = _render->m_debug&BGFX_DEBUG_WIREFRAME ? BGFX_STATE_PT_LINES : 0;
2868      uint8_t primIndex = uint8_t(pt>>BGFX_STATE_PT_SHIFT);
2881      uint8_t primIndex;
2882      {
2883         const uint64_t pt = _render->m_debug&BGFX_DEBUG_WIREFRAME ? BGFX_STATE_PT_LINES : 0;
2884         primIndex = uint8_t(pt>>BGFX_STATE_PT_SHIFT);
2885      }
28692886      PrimInfo prim = s_primInfo[primIndex];
28702887
28712888      bool viewHasScissor = false;
r245576r245577
28762893      uint32_t statsNumPrimsRendered[BX_COUNTOF(s_primInfo)] = {};
28772894      uint32_t statsNumInstances[BX_COUNTOF(s_primInfo)] = {};
28782895      uint32_t statsNumIndices = 0;
2896      uint32_t statsKeyType[2] = {};
28792897
28802898      invalidateSamplerState();
28812899
r245576r245577
28842902         for (uint32_t item = 0, numItems = _render->m_num; item < numItems; ++item)
28852903         {
28862904            const bool isCompute = key.decode(_render->m_sortKeys[item], _render->m_viewRemap);
2905            statsKeyType[isCompute]++;
28872906
28882907            if (isCompute)
28892908            {
r245576r245577
34143433               );
34153434
34163435            double elapsedCpuMs = double(elapsed)*toMs;
3417            tvm.printf(10, pos++, 0x8e, "  Draw calls: %4d / CPU %3.4f [ms]"
3436            tvm.printf(10, pos++, 0x8e, "  Submitted: %4d (draw %4d, compute %4d) / CPU %3.4f [ms]"
34183437               , _render->m_num
3438               , statsKeyType[0]
3439               , statsKeyType[1]
34193440               , elapsedCpuMs
34203441               );
34213442            for (uint32_t ii = 0; ii < BX_COUNTOF(s_primName); ++ii)
r245576r245577
34603481
34613482      device->EndScene();
34623483   }
3463} // namespace bgfx
3484} /* namespace d3d9 */ } // namespace bgfx
34643485
34653486#else
34663487
3467namespace bgfx
3488namespace bgfx { namespace d3d9
34683489{
3469   RendererContextI* rendererCreateD3D9()
3490   RendererContextI* rendererCreate()
34703491   {
34713492      return NULL;
34723493   }
34733494
3474   void rendererDestroyD3D9()
3495   void rendererDestroy()
34753496   {
34763497   }
3477} // namespace bgfx
3498} /* namespace d3d9 */ } // namespace bgfx
34783499
34793500#endif // BGFX_CONFIG_RENDERER_DIRECT3D9
trunk/3rdparty/bgfx/src/renderer_d3d9.h
r245576r245577
4141#include "renderer.h"
4242#include "renderer_d3d.h"
4343
44namespace bgfx
44namespace bgfx { namespace d3d9
4545{
4646#   if defined(D3D_DISABLE_9EX)
4747#      define D3DFMT_S8_LOCKABLE D3DFORMAT( 85)
r245576r245577
386386      bool m_needResolve;
387387   };
388388
389} // namespace bgfx
389} /* namespace d3d9 */ } // namespace bgfx
390390
391391#endif // BGFX_RENDERER_D3D9_H_HEADER_GUARD
trunk/3rdparty/bgfx/src/renderer_gl.cpp
r245576r245577
1010#   include <bx/timer.h>
1111#   include <bx/uint32_t.h>
1212
13namespace bgfx
13namespace bgfx { namespace gl
1414{
1515   static char s_viewName[BGFX_CONFIG_MAX_VIEWS][BGFX_CONFIG_MAX_VIEW_NAME];
1616
r245576r245577
237237   };
238238   BX_STATIC_ASSERT(TextureFormat::Count == BX_COUNTOF(s_textureFormat) );
239239
240   static bool s_textureFilter[TextureFormat::Count+1];
241
240242   static GLenum s_rboFormat[] =
241243   {
242244      GL_ZERO,               // BC1
r245576r245577
358360         ANGLE_texture_compression_dxt1,
359361         ANGLE_texture_compression_dxt3,
360362         ANGLE_texture_compression_dxt5,
363         ANGLE_timer_query,
361364         ANGLE_translated_shader_source,
362365
363366         APPLE_texture_format_BGRA8888,
r245576r245577
417420         EXT_blend_color,
418421         EXT_blend_minmax,
419422         EXT_blend_subtract,
423         EXT_color_buffer_half_float,
424         EXT_color_buffer_float,
420425         EXT_compressed_ETC1_RGB8_sub_texture,
421426         EXT_debug_label,
422427         EXT_debug_marker,
423428         EXT_discard_framebuffer,
429         EXT_disjoint_timer_query,
424430         EXT_draw_buffers,
425431         EXT_frag_depth,
426432         EXT_framebuffer_blit,
r245576r245577
491497         OES_vertex_half_float,
492498         OES_vertex_type_10_10_10_2,
493499
500         WEBGL_color_buffer_float,
494501         WEBGL_compressed_texture_etc1,
495502         WEBGL_compressed_texture_s3tc,
496503         WEBGL_compressed_texture_pvrtc,
497504         WEBGL_depth_texture,
505         WEBGL_draw_buffers,
498506
499507         WEBKIT_EXT_texture_filter_anisotropic,
500508         WEBKIT_WEBGL_compressed_texture_s3tc,
r245576r245577
508516      bool m_initialize;
509517   };
510518
511   static Extension s_extension[Extension::Count] =
519   // Extension registry
520   //
521   // ANGLE:
522   // https://github.com/google/angle/tree/master/extensions
523   //
524   // CHROMIUM:
525   // https://chromium.googlesource.com/chromium/src.git/+/refs/heads/git-svn/gpu/GLES2/extensions/CHROMIUM
526   //
527   // EGL:
528   // https://www.khronos.org/registry/egl/extensions/
529   //
530   // GL:
531   // https://www.opengl.org/registry/
532   //
533   // GLES:
534   // https://www.khronos.org/registry/gles/extensions/
535   //
536   // WEBGL:
537   // https://www.khronos.org/registry/webgl/extensions/
538   //
539   static Extension s_extension[] =
512540   {
513541      { "AMD_conservative_depth",                false,                             true  },
514542
r245576r245577
519547      { "ANGLE_texture_compression_dxt1",        false,                             true  },
520548      { "ANGLE_texture_compression_dxt3",        false,                             true  },
521549      { "ANGLE_texture_compression_dxt5",        false,                             true  },
550      { "ANGLE_timer_query",                     false,                             true  },
522551      { "ANGLE_translated_shader_source",        false,                             true  },
523552
524553      { "APPLE_texture_format_BGRA8888",         false,                             true  },
r245576r245577
578607      { "EXT_blend_color",                       BGFX_CONFIG_RENDERER_OPENGL >= 31, true  },
579608      { "EXT_blend_minmax",                      BGFX_CONFIG_RENDERER_OPENGL >= 14, true  },
580609      { "EXT_blend_subtract",                    BGFX_CONFIG_RENDERER_OPENGL >= 14, true  },
610      { "EXT_color_buffer_half_float",           false,                             true  }, // GLES2 extension.
611      { "EXT_color_buffer_float",                false,                             true  }, // GLES2 extension.
581612      { "EXT_compressed_ETC1_RGB8_sub_texture",  false,                             true  }, // GLES2 extension.
582613      { "EXT_debug_label",                       false,                             true  },
583614      { "EXT_debug_marker",                      false,                             true  },
584615      { "EXT_discard_framebuffer",               false,                             true  }, // GLES2 extension.
616      { "EXT_disjoint_timer_query",              false,                             true  }, // GLES2 extension.
585617      { "EXT_draw_buffers",                      false,                             true  }, // GLES2 extension.
586618      { "EXT_frag_depth",                        false,                             true  }, // GLES2 extension.
587619      { "EXT_framebuffer_blit",                  BGFX_CONFIG_RENDERER_OPENGL >= 30, true  },
r245576r245577
605637      { "EXT_texture_storage",                   false,                             true  },
606638      { "EXT_texture_swizzle",                   false,                             true  },
607639      { "EXT_texture_type_2_10_10_10_REV",       false,                             true  },
608      { "EXT_timer_query",                       false,                            true  },
640      { "EXT_timer_query",                       BGFX_CONFIG_RENDERER_OPENGL >= 33, true  },
609641      { "EXT_unpack_subimage",                   false,                             true  },
610642
611643      { "GOOGLE_depth_texture",                  false,                             true  },
r245576r245577
652684      { "OES_vertex_half_float",                 false,                             true  },
653685      { "OES_vertex_type_10_10_10_2",            false,                             true  },
654686
687      { "WEBGL_color_buffer_float",              false,                             true  },
655688      { "WEBGL_compressed_texture_etc1",         false,                             true  },
656689      { "WEBGL_compressed_texture_s3tc",         false,                             true  },
657690      { "WEBGL_compressed_texture_pvrtc",        false,                             true  },
658691      { "WEBGL_depth_texture",                   false,                             true  },
692      { "WEBGL_draw_buffers",                    false,                             true  },
659693
660694      { "WEBKIT_EXT_texture_filter_anisotropic", false,                             true  },
661695      { "WEBKIT_WEBGL_compressed_texture_s3tc",  false,                             true  },
662696      { "WEBKIT_WEBGL_depth_texture",            false,                             true  },
663697   };
698   BX_STATIC_ASSERT(Extension::Count == BX_COUNTOF(s_extension) );
664699
665700   static const char* s_ARB_shader_texture_lod[] =
666701   {
r245576r245577
915950      return 0 == err;
916951   }
917952
953   static void getFilters(uint32_t _flags, bool _hasMips, GLenum& _magFilter, GLenum& _minFilter)
954   {
955      const uint32_t mag = (_flags&BGFX_TEXTURE_MAG_MASK)>>BGFX_TEXTURE_MAG_SHIFT;
956      const uint32_t min = (_flags&BGFX_TEXTURE_MIN_MASK)>>BGFX_TEXTURE_MIN_SHIFT;
957      const uint32_t mip = (_flags&BGFX_TEXTURE_MIP_MASK)>>BGFX_TEXTURE_MIP_SHIFT;
958      _magFilter = s_textureFilterMag[mag];
959      _minFilter = s_textureFilterMin[min][_hasMips ? mip+1 : 0];
960   }
961
918962   struct RendererContextGL : public RendererContextI
919963   {
920964      RendererContextGL()
r245576r245577
933977         , m_programBinarySupport(false)
934978         , m_textureSwizzleSupport(false)
935979         , m_depthTextureSupport(false)
980         , m_timerQuerySupport(false)
936981         , m_flip(false)
937982         , m_hash( (BX_PLATFORM_WINDOWS<<1) | BX_ARCH_64BIT)
938983         , m_backBufferFbo(0)
r245576r245577
10941139            }
10951140         }
10961141
1142         // Allow all texture filters.
1143         memset(s_textureFilter, true, BX_COUNTOF(s_textureFilter) );
1144
10971145         bool bc123Supported = 0
10981146            || s_extension[Extension::EXT_texture_compression_s3tc        ].m_supported
10991147            || s_extension[Extension::MOZ_WEBGL_compressed_texture_s3tc   ].m_supported
r245576r245577
11861234            {
11871235               setTextureFormat(TextureFormat::RGBA16F, GL_RGBA, GL_RGBA, GL_HALF_FLOAT);
11881236
1237               if (s_extension[Extension::OES_texture_half_float].m_supported
1238               ||  s_extension[Extension::OES_texture_float     ].m_supported)
1239               {
1240                  // https://www.khronos.org/registry/gles/extensions/OES/OES_texture_float.txt
1241                  // When half/float is available via extensions texture will be marked as
1242                  // incomplete if it uses anything other than nearest filter.
1243                  const bool linear16F = s_extension[Extension::OES_texture_half_float_linear].m_supported;
1244                  const bool linear32F = s_extension[Extension::OES_texture_float_linear     ].m_supported;
1245
1246                  s_textureFilter[TextureFormat::R16F]    = linear16F;
1247                  s_textureFilter[TextureFormat::RG16F]   = linear16F;
1248                  s_textureFilter[TextureFormat::RGBA16F] = linear16F;
1249                  s_textureFilter[TextureFormat::R32F]    = linear32F;
1250                  s_textureFilter[TextureFormat::RG32F]   = linear32F;
1251                  s_textureFilter[TextureFormat::RGBA32F] = linear32F;
1252               }
1253
11891254               if (BX_ENABLED(BX_PLATFORM_IOS) )
11901255               {
11911256                  setTextureFormat(TextureFormat::D16,   GL_DEPTH_COMPONENT, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT);
r245576r245577
12941359
12951360         if (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGL)
12961361         ||  BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGLES >= 30)
1297         ||  s_extension[Extension::EXT_draw_buffers].m_supported)
1362         ||  s_extension[Extension::EXT_draw_buffers  ].m_supported
1363         ||  s_extension[Extension::WEBGL_draw_buffers].m_supported)
12981364         {
12991365            g_caps.maxFBAttachments = bx::uint32_min(glGet(GL_MAX_COLOR_ATTACHMENTS), BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS);
13001366         }
r245576r245577
13061372
13071373         if (BX_ENABLED(BX_PLATFORM_NACL) )
13081374         {
1309            m_vaoSupport &= NULL != glGenVertexArrays
1375            m_vaoSupport &= true
1376               && NULL != glGenVertexArrays
13101377               && NULL != glDeleteVertexArrays
13111378               && NULL != glBindVertexArray
13121379               ;
r245576r245577
13461413            || s_extension[Extension::WEBKIT_WEBGL_depth_texture].m_supported
13471414            ;
13481415
1416         m_timerQuerySupport = 0
1417            || s_extension[Extension::ANGLE_timer_query       ].m_supported
1418            || s_extension[Extension::ARB_timer_query         ].m_supported
1419            || s_extension[Extension::EXT_disjoint_timer_query].m_supported
1420            || s_extension[Extension::EXT_timer_query         ].m_supported
1421            ;
1422
1423         m_timerQuerySupport &= NULL != glGetQueryObjectui64v;
1424
13491425         g_caps.supported |= m_depthTextureSupport
13501426            ? BGFX_CAPS_TEXTURE_COMPARE_LEQUAL
13511427            : 0
r245576r245577
14551531            glInvalidateFramebuffer = stubInvalidateFramebuffer;
14561532         }
14571533
1458         if (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGL) )
1534         if (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGL)
1535         &&  m_timerQuerySupport)
14591536         {
14601537            m_queries.create();
14611538         }
r245576r245577
14851562
14861563         invalidateCache();
14871564
1488         if (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGL) )
1565         if (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGL)
1566         &&  m_timerQuerySupport)
14891567         {
14901568            m_queries.destroy();
14911569         }
r245576r245577
20472125               {
20482126                  sampler = m_samplerStateCache.add(_flags);
20492127
2050                  GL_CHECK(glSamplerParameteri(sampler, GL_TEXTURE_WRAP_S, s_textureAddress[(_flags&BGFX_TEXTURE_U_MASK)>>BGFX_TEXTURE_U_SHIFT]) );
2051                  GL_CHECK(glSamplerParameteri(sampler, GL_TEXTURE_WRAP_T, s_textureAddress[(_flags&BGFX_TEXTURE_V_MASK)>>BGFX_TEXTURE_V_SHIFT]) );
2052                  GL_CHECK(glSamplerParameteri(sampler, GL_TEXTURE_WRAP_R, s_textureAddress[(_flags&BGFX_TEXTURE_W_MASK)>>BGFX_TEXTURE_W_SHIFT]) );
2128                  GL_CHECK(glSamplerParameteri(sampler
2129                     , GL_TEXTURE_WRAP_S
2130                     , s_textureAddress[(_flags&BGFX_TEXTURE_U_MASK)>>BGFX_TEXTURE_U_SHIFT]
2131                     ) );
2132                  GL_CHECK(glSamplerParameteri(sampler
2133                     , GL_TEXTURE_WRAP_T
2134                     , s_textureAddress[(_flags&BGFX_TEXTURE_V_MASK)>>BGFX_TEXTURE_V_SHIFT]
2135                     ) );
2136                  GL_CHECK(glSamplerParameteri(sampler
2137                     , GL_TEXTURE_WRAP_R
2138                     , s_textureAddress[(_flags&BGFX_TEXTURE_W_MASK)>>BGFX_TEXTURE_W_SHIFT]
2139                     ) );
20532140
2054                  const uint32_t mag = (_flags&BGFX_TEXTURE_MAG_MASK)>>BGFX_TEXTURE_MAG_SHIFT;
2055                  const uint32_t min = (_flags&BGFX_TEXTURE_MIN_MASK)>>BGFX_TEXTURE_MIN_SHIFT;
2056                  const uint32_t mip = (_flags&BGFX_TEXTURE_MIP_MASK)>>BGFX_TEXTURE_MIP_SHIFT;
2057                  GLenum minFilter = s_textureFilterMin[min][1 < _numMips ? mip+1 : 0];
2058                  GL_CHECK(glSamplerParameteri(sampler, GL_TEXTURE_MAG_FILTER, s_textureFilterMag[mag]) );
2141                  GLenum minFilter;
2142                  GLenum magFilter;
2143                  getFilters(_flags, 1 < _numMips, magFilter, minFilter);
2144                  GL_CHECK(glSamplerParameteri(sampler, GL_TEXTURE_MAG_FILTER, magFilter) );
20592145                  GL_CHECK(glSamplerParameteri(sampler, GL_TEXTURE_MIN_FILTER, minFilter) );
2146
20602147                  if (0 != (_flags & (BGFX_TEXTURE_MIN_ANISOTROPIC|BGFX_TEXTURE_MAG_ANISOTROPIC) )
20612148                  &&  0.0f < m_maxAnisotropy)
20622149                  {
r245576r245577
25572644      bool m_programBinarySupport;
25582645      bool m_textureSwizzleSupport;
25592646      bool m_depthTextureSupport;
2647      bool m_timerQuerySupport;
25602648      bool m_flip;
25612649
25622650      uint64_t m_hash;
r245576r245577
25792667
25802668   RendererContextGL* s_renderGL;
25812669
2582   RendererContextI* rendererCreateGL()
2670   RendererContextI* rendererCreate()
25832671   {
25842672      s_renderGL = BX_NEW(g_allocator, RendererContextGL);
25852673      s_renderGL->init();
25862674      return s_renderGL;
25872675   }
25882676
2589   void rendererDestroyGL()
2677   void rendererDestroy()
25902678   {
25912679      s_renderGL->shutdown();
25922680      BX_DELETE(g_allocator, s_renderGL);
r245576r245577
26622750         GLENUM(GL_RENDERBUFFER);
26632751
26642752         GLENUM(GL_INVALID_ENUM);
2753         GLENUM(GL_INVALID_FRAMEBUFFER_OPERATION);
26652754         GLENUM(GL_INVALID_VALUE);
26662755         GLENUM(GL_INVALID_OPERATION);
26672756         GLENUM(GL_OUT_OF_MEMORY);
r245576r245577
28612950      m_numPredefined = 0;
28622951       m_numSamplers = 0;
28632952
2864      struct VariableInfo
2865      {
2866         GLenum type;
2867         GLint  loc;
2868         GLint  num;
2869      };
2870      VariableInfo vi;
2871      GLenum props[] = { GL_TYPE, GL_LOCATION, GL_ARRAY_SIZE };
2872
28732953      const bool piqSupported = s_extension[Extension::ARB_program_interface_query].m_supported;
28742954
28752955      BX_TRACE("Uniforms (%d):", activeUniforms);
28762956      for (int32_t ii = 0; ii < activeUniforms; ++ii)
28772957      {
2958         struct VariableInfo
2959         {
2960            GLenum type;
2961            GLint  loc;
2962            GLint  num;
2963         };
2964         VariableInfo vi;
2965         GLenum props[] ={ GL_TYPE, GL_LOCATION, GL_ARRAY_SIZE };
2966
28782967         GLenum gltype;
28792968         GLint num;
28802969         GLint loc;
r245576r245577
32023291         BX_CHECK(0 != m_id, "Failed to generate texture id.");
32033292         GL_CHECK(glBindTexture(_target, m_id) );
32043293
3205         setSamplerState(_flags);
3206
32073294         const TextureFormatInfo& tfi = s_textureFormat[_format];
3208         m_fmt = tfi.m_fmt;
3295         m_fmt = tfi.m_fmt;
32093296         m_type = tfi.m_type;
32103297
32113298         const bool compressed = isCompressed(TextureFormat::Enum(_format) );
r245576r245577
32143301         if (decompress)
32153302         {
32163303            m_textureFormat = (uint8_t)TextureFormat::BGRA8;
3217            const TextureFormatInfo& tfi = s_textureFormat[TextureFormat::BGRA8];
3218            m_fmt = tfi.m_fmt;
3219            m_type = tfi.m_type;
3304            const TextureFormatInfo& tfiBgra8 = s_textureFormat[TextureFormat::BGRA8];
3305            m_fmt  = tfiBgra8.m_fmt;
3306            m_type = tfiBgra8.m_type;
32203307         }
32213308
3309         setSamplerState(_flags);
3310
32223311         if (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGL)
32233312         &&  TextureFormat::BGRA8 == m_textureFormat
32243313         &&  GL_RGBA == m_fmt
r245576r245577
35833672
35843673   void TextureGL::setSamplerState(uint32_t _flags)
35853674   {
3675      if (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGLES < 30)
3676      &&  !s_textureFilter[m_textureFormat])
3677      {
3678         // Force point sampling when texture format doesn't support linear sampling.
3679         _flags &= 0
3680            | BGFX_TEXTURE_MIN_MASK
3681            | BGFX_TEXTURE_MAG_MASK
3682            | BGFX_TEXTURE_MIP_MASK
3683            ;
3684         _flags |= 0
3685            | BGFX_TEXTURE_MIN_POINT
3686            | BGFX_TEXTURE_MAG_POINT
3687            | BGFX_TEXTURE_MIP_POINT
3688            ;
3689      }
3690
35863691      const uint32_t flags = (0 != (BGFX_SAMPLER_DEFAULT_FLAGS & _flags) ? m_flags : _flags) & BGFX_TEXTURE_SAMPLER_BITS_MASK;
35873692      if (flags != m_currentFlags)
35883693      {
r245576r245577
36033708            GL_CHECK(glTexParameteri(target, GL_TEXTURE_WRAP_R, s_textureAddress[(flags&BGFX_TEXTURE_W_MASK)>>BGFX_TEXTURE_W_SHIFT]) );
36043709         }
36053710
3606         const uint32_t mag = (flags&BGFX_TEXTURE_MAG_MASK)>>BGFX_TEXTURE_MAG_SHIFT;
3607         const uint32_t min = (flags&BGFX_TEXTURE_MIN_MASK)>>BGFX_TEXTURE_MIN_SHIFT;
3608         const uint32_t mip = (flags&BGFX_TEXTURE_MIP_MASK)>>BGFX_TEXTURE_MIP_SHIFT;
3609         const GLenum minFilter = s_textureFilterMin[min][1 < numMips ? mip+1 : 0];
3610         GL_CHECK(glTexParameteri(target, GL_TEXTURE_MAG_FILTER, s_textureFilterMag[mag]) );
3711         GLenum magFilter;
3712         GLenum minFilter;
3713         getFilters(flags, 1 < numMips, magFilter, minFilter);
3714         GL_CHECK(glTexParameteri(target, GL_TEXTURE_MAG_FILTER, magFilter) );
36113715         GL_CHECK(glTexParameteri(target, GL_TEXTURE_MIN_FILTER, minFilter) );
36123716         if (0 != (flags & (BGFX_TEXTURE_MIN_ANISOTROPIC|BGFX_TEXTURE_MAG_ANISOTROPIC) )
36133717         &&  0.0f < s_renderGL->m_maxAnisotropy)
r245576r245577
37943898
37953899               if (usesFragData)
37963900               {
3797                  BX_WARN(s_extension[Extension::EXT_draw_buffers].m_supported, "EXT_draw_buffers is used but not supported by GLES2 driver.");
3901                  BX_WARN(s_extension[Extension::EXT_draw_buffers  ].m_supported
3902                     ||  s_extension[Extension::WEBGL_draw_buffers].m_supported
3903                     , "EXT_draw_buffers is used but not supported by GLES2 driver."
3904                     );
37983905                  writeString(&writer
37993906                     , "#extension GL_EXT_draw_buffers : enable\n"
38003907                     );
r245576r245577
39954102                  {
39964103                     for (uint32_t ii = 0, num = g_caps.maxFBAttachments; ii < num; ++ii)
39974104                     {
3998                        char temp[16];
3999                        bx::snprintf(temp, BX_COUNTOF(temp), "gl_FragData[%d]", ii);
4000                        fragData = bx::uint32_max(fragData, NULL == strstr(code, temp) ? 0 : ii+1);
4105                        char tmpFragData[16];
4106                        bx::snprintf(tmpFragData, BX_COUNTOF(tmpFragData), "gl_FragData[%d]", ii);
4107                        fragData = bx::uint32_max(fragData, NULL == strstr(code, tmpFragData) ? 0 : ii+1);
40014108                     }
40024109
40034110                     BGFX_FATAL(0 != fragData, Fatal::InvalidShader, "Unable to find and patch gl_FragData!");
r245576r245577
41974304         GL_CHECK(glGenFramebuffers(1, &m_fbo[1]) );
41984305         GL_CHECK(glBindFramebuffer(GL_FRAMEBUFFER, m_fbo[1]) );
41994306
4200         for (uint32_t ii = 0, colorIdx = 0; ii < _num; ++ii)
4307         colorIdx = 0;
4308         for (uint32_t ii = 0; ii < _num; ++ii)
42014309         {
42024310            TextureHandle handle = _handles[ii];
42034311            if (isValid(handle) )
r245576r245577
43454453      int64_t captureElapsed = 0;
43464454
43474455      if (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGL)
4348      && (_render->m_debug & (BGFX_DEBUG_IFH|BGFX_DEBUG_STATS) ) )
4456      && (_render->m_debug & (BGFX_DEBUG_IFH|BGFX_DEBUG_STATS) )
4457      &&  m_timerQuerySupport)
43494458      {
43504459         m_queries.begin(0, GL_TIME_ELAPSED);
43514460      }
r245576r245577
43904499               ;
43914500      uint32_t blendFactor = 0;
43924501
4393      const uint64_t pt = _render->m_debug&BGFX_DEBUG_WIREFRAME ? BGFX_STATE_PT_LINES : 0;
4394      uint8_t primIndex = uint8_t(pt>>BGFX_STATE_PT_SHIFT);
4502      uint8_t primIndex;
4503      {
4504         const uint64_t pt = _render->m_debug&BGFX_DEBUG_WIREFRAME ? BGFX_STATE_PT_LINES : 0;
4505         primIndex = uint8_t(pt>>BGFX_STATE_PT_SHIFT);
4506      }
43954507      PrimInfo prim = s_primInfo[primIndex];
43964508
43974509      uint32_t baseVertex = 0;
r245576r245577
44104522      uint32_t statsNumPrimsRendered[BX_COUNTOF(s_primInfo)] = {};
44114523      uint32_t statsNumInstances[BX_COUNTOF(s_primInfo)] = {};
44124524      uint32_t statsNumIndices = 0;
4525      uint32_t statsKeyType[2] = {};
44134526
44144527      if (0 == (_render->m_debug&BGFX_DEBUG_IFH) )
44154528      {
r245576r245577
44244537         for (int32_t item = 0, restartItem = numItems; item < numItems || restartItem < numItems;)
44254538         {
44264539            const bool isCompute   = key.decode(_render->m_sortKeys[item], _render->m_viewRemap);
4540            statsKeyType[isCompute]++;
4541
44274542            const bool viewChanged = 0
44284543               || key.m_view != view
44294544               || item == numItems
r245576r245577
47834898                        && blendIndependentSupported
47844899                        ;
47854900
4786                     const uint32_t blend    = uint32_t( (newFlags&BGFX_STATE_BLEND_MASK)>>BGFX_STATE_BLEND_SHIFT);
4787                     const uint32_t equation = uint32_t( (newFlags&BGFX_STATE_BLEND_EQUATION_MASK)>>BGFX_STATE_BLEND_EQUATION_SHIFT);
4901                     const uint32_t blend  = uint32_t( (newFlags&BGFX_STATE_BLEND_MASK)>>BGFX_STATE_BLEND_SHIFT);
4902                     const uint32_t srcRGB = (blend    )&0xf;
4903                     const uint32_t dstRGB = (blend>> 4)&0xf;
4904                     const uint32_t srcA   = (blend>> 8)&0xf;
4905                     const uint32_t dstA   = (blend>>12)&0xf;
47884906
4789                     const uint32_t srcRGB  = (blend    )&0xf;
4790                     const uint32_t dstRGB  = (blend>> 4)&0xf;
4791                     const uint32_t srcA    = (blend>> 8)&0xf;
4792                     const uint32_t dstA    = (blend>>12)&0xf;
4907                     const uint32_t equ    = uint32_t((newFlags&BGFX_STATE_BLEND_EQUATION_MASK)>>BGFX_STATE_BLEND_EQUATION_SHIFT);
4908                     const uint32_t equRGB = (equ   )&0x7;
4909                     const uint32_t equA   = (equ>>3)&0x7;
47934910
4794                     const uint32_t equRGB = (equation   )&0x7;
4795                     const uint32_t equA   = (equation>>3)&0x7;
4796
47974911                     const uint32_t numRt = getNumRt();
47984912
47994913                     if (!BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGL)
r245576r245577
49745088                        currentVao = id;
49755089                        GL_CHECK(glBindVertexArray(id) );
49765090
4977                        ProgramGL& program = m_program[programIdx];
49785091                        program.add(hash);
49795092
49805093                        if (isValid(draw.m_vertexBuffer) )
r245576r245577
50725185                        baseVertex = draw.m_startVertex;
50735186                        const VertexBufferGL& vb = m_vertexBuffers[draw.m_vertexBuffer.idx];
50745187                        uint16_t decl = !isValid(vb.m_decl) ? draw.m_vertexDecl.idx : vb.m_decl.idx;
5075                        const ProgramGL& program = m_program[programIdx];
50765188                        program.bindAttributes(m_vertexDecls[decl], draw.m_startVertex);
50775189
50785190                        if (isValid(draw.m_instanceDataBuffer) )
r245576r245577
51785290      if (_render->m_debug & (BGFX_DEBUG_IFH|BGFX_DEBUG_STATS) )
51795291      {
51805292         double elapsedGpuMs = 0.0;
5181#if BGFX_CONFIG_RENDERER_OPENGL
5182         m_queries.end(GL_TIME_ELAPSED);
5183         uint64_t elapsedGl = m_queries.getResult(0);
5184         elapsedGpuMs = double(elapsedGl)/1e6;
5185#endif // BGFX_CONFIG_RENDERER_OPENGL
5293         uint64_t elapsedGl  = 0;
5294         if (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGL)
5295         &&  m_timerQuerySupport)
5296         {
5297            m_queries.end(GL_TIME_ELAPSED);
5298            elapsedGl    = m_queries.getResult(0);
5299            elapsedGpuMs = double(elapsedGl)/1e6;
5300         }
51865301
51875302         TextVideoMem& tvm = m_textVideoMem;
51885303
r245576r245577
52255340               );
52265341
52275342            double elapsedCpuMs = double(elapsed)*toMs;
5228            tvm.printf(10, pos++, 0x8e, " Draw calls: %4d / CPU %3.4f [ms] %c GPU %3.4f [ms]"
5343            tvm.printf(10, pos++, 0x8e, "   Submitted: %4d (draw %4d, compute %4d) / CPU %3.4f [ms] %c GPU %3.4f [ms]"
52295344               , _render->m_num
5345               , statsKeyType[0]
5346               , statsKeyType[1]
52305347               , elapsedCpuMs
52315348               , elapsedCpuMs > elapsedGpuMs ? '>' : '<'
52325349               , elapsedGpuMs
52335350               );
52345351            for (uint32_t ii = 0; ii < BX_COUNTOF(s_primInfo); ++ii)
52355352            {
5236               tvm.printf(10, pos++, 0x8e, "   %8s: %7d (#inst: %5d), submitted: %7d"
5353               tvm.printf(10, pos++, 0x8e, "   %9s: %7d (#inst: %5d), submitted: %7d"
52375354                  , s_primName[ii]
52385355                  , statsNumPrimsRendered[ii]
52395356                  , statsNumInstances[ii]
r245576r245577
52465363               tvm.printf(tvm.m_width-27, 0, 0x1f, " [F11 - RenderDoc capture] ");
52475364            }
52485365
5249            tvm.printf(10, pos++, 0x8e, "    Indices: %7d", statsNumIndices);
5250            tvm.printf(10, pos++, 0x8e, "   DVB size: %7d", _render->m_vboffset);
5251            tvm.printf(10, pos++, 0x8e, "   DIB size: %7d", _render->m_iboffset);
5366            tvm.printf(10, pos++, 0x8e, "     Indices: %7d", statsNumIndices);
5367            tvm.printf(10, pos++, 0x8e, "    DVB size: %7d", _render->m_vboffset);
5368            tvm.printf(10, pos++, 0x8e, "    DIB size: %7d", _render->m_iboffset);
52525369
52535370            pos++;
52545371            tvm.printf(10, pos++, 0x8e, " State cache:     ");
r245576r245577
53545471
53555472      GL_CHECK(glFrameTerminatorGREMEDY() );
53565473   }
5357} // namespace bgfx
5474} } // namespace bgfx
53585475
53595476#else
53605477
5361namespace bgfx
5478namespace bgfx { namespace gl
53625479{
5363   RendererContextI* rendererCreateGL()
5480   RendererContextI* rendererCreate()
53645481   {
53655482      return NULL;
53665483   }
53675484
5368   void rendererDestroyGL()
5485   void rendererDestroy()
53695486   {
53705487   }
5371} // namespace bgfx
5488} /* namespace gl */ } // namespace bgfx
53725489
53735490#endif // (BGFX_CONFIG_RENDERER_OPENGLES || BGFX_CONFIG_RENDERER_OPENGL)
53745491
trunk/3rdparty/bgfx/src/renderer_gl.h
r245576r245577
611611namespace bgfx
612612{
613613   class ConstantBuffer;
614} // namespace bgfx
615
616namespace bgfx { namespace gl
617{
614618   void dumpExtensions(const char* _extensions);
615619
616620   const char* glEnumName(GLenum _enum);
r245576r245577
619623            BX_MACRO_BLOCK_BEGIN \
620624               /*BX_TRACE(#_call);*/ \
621625               _call; \
622               GLenum err = glGetError(); \
623               _check(0 == err, #_call "; GL error 0x%x: %s", err, glEnumName(err) ); \
624               BX_UNUSED(err); \
626               GLenum gl_err = glGetError(); \
627               _check(0 == gl_err, #_call "; GL error 0x%x: %s", gl_err, glEnumName(gl_err) ); \
628               BX_UNUSED(gl_err); \
625629            BX_MACRO_BLOCK_END
626630
627631#define IGNORE_GL_ERROR_CHECK(...) BX_NOOP()
r245576r245577
10011005      GLuint m_queries[64];
10021006   };
10031007
1004} // namespace bgfx
1008} /* namespace gl */ } // namespace bgfx
10051009
10061010#endif // BGFX_RENDERER_GL_H_HEADER_GUARD
trunk/3rdparty/bgfx/src/renderer_null.cpp
r245576r245577
77
88#if BGFX_CONFIG_RENDERER_NULL
99
10namespace bgfx
10namespace bgfx { namespace noop
1111{
1212   struct RendererContextNULL : public RendererContextI
1313   {
r245576r245577
168168
169169   static RendererContextNULL* s_renderNULL;
170170
171   RendererContextI* rendererCreateNULL()
171   RendererContextI* rendererCreate()
172172   {
173173      s_renderNULL = BX_NEW(g_allocator, RendererContextNULL);
174174      return s_renderNULL;
175175   }
176176
177   void rendererDestroyNULL()
177   void rendererDestroy()
178178   {
179179      BX_DELETE(g_allocator, s_renderNULL);
180180      s_renderNULL = NULL;
181181   }
182} // namespace bgfx
182} /* namespace noop */ } // namespace bgfx
183183
184184#else
185185
186namespace bgfx
186namespace bgfx { namespace noop
187187{
188   RendererContextI* rendererCreateNULL()
188   RendererContextI* rendererCreate()
189189   {
190190      return NULL;
191191   }
192192
193   void rendererDestroyNULL()
193   void rendererDestroy()
194194   {
195195   }
196} // namespace bgfx
196} /* namespace noop */ } // namespace bgfx
197197
198198#endif // BGFX_CONFIG_RENDERER_NULL
trunk/3rdparty/bgfx/src/renderer_vk.cpp
r245576r245577
88#   include "../../vk/src/renderer_vk.cpp"
99#else
1010
11namespace bgfx
11namespace bgfx { namespace vk
1212{
13   RendererContextI* rendererCreateVK()
13   RendererContextI* rendererCreate()
1414   {
1515      return NULL;
1616   }
1717
18   void rendererDestroyVK()
18   void rendererDestroy()
1919   {
2020   }
21} // namespace bgfx
21} /* namespace vk */ } // namespace bgfx
2222
2323#endif // BGFX_CONFIG_RENDERER_VULKAN
trunk/3rdparty/bgfx/tools/geometryc/geometryc.cpp
r245576r245577
504504            Triangle triangle;
505505            memset(&triangle, 0, sizeof(Triangle) );
506506
507            const int numNormals   = (int)normals.size();
508            const int numTexcoords = (int)texcoords.size();
509            const int numPositions = (int)positions.size();
507510            for (uint32_t edge = 0, numEdges = argc-1; edge < numEdges; ++edge)
508511            {
509512               Index3 index;
510               index.m_texcoord = -1;
511               index.m_normal = -1;
513               index.m_texcoord = 0;
514               index.m_normal = 0;
512515               index.m_vertexIndex = -1;
513516
514517               char* vertex = argv[edge+1];
r245576r245577
521524                  if (NULL != normal)
522525                  {
523526                     *normal++ = '\0';
524                     index.m_normal = atoi(normal)-1;
527                     const int nn = atoi(normal);
528                     index.m_normal = (nn < 0) ? nn+numNormals : nn-1;
525529                  }
526530
527                  index.m_texcoord = atoi(texcoord)-1;
531                  const int tex = atoi(texcoord);
532                  index.m_texcoord = (tex < 0) ? tex+numTexcoords : tex-1;
528533               }
529534
530               index.m_position = atoi(vertex)-1;
535               const int pos = atoi(vertex);
536               index.m_position = (pos < 0) ? pos+numPositions : pos-1;
531537
532538               uint64_t hash0 = index.m_position;
533539               uint64_t hash1 = uint64_t(index.m_texcoord)<<20;
r245576r245577
710716   bool hasTexcoord;
711717   {
712718      Index3Map::const_iterator it = indexMap.begin();
713      hasNormal = -1 != it->second.m_normal;
714      hasTexcoord = -1 != it->second.m_texcoord;
719      hasNormal   = 0 != it->second.m_normal;
720      hasTexcoord = 0 != it->second.m_texcoord;
715721
716722      if (!hasTexcoord
717723      &&  texcoords.size() == positions.size() )
trunk/3rdparty/bgfx/tools/shaderc/shaderc.cpp
r245576r245577
845845   preprocessor.setDefaultDefine("BGFX_SHADER_TYPE_VERTEX");
846846
847847   char glslDefine[128];
848   bx::snprintf(glslDefine, BX_COUNTOF(glslDefine), "BGFX_SHADER_LANGUAGE_GLSL=%d", glsl);
848   bx::snprintf(glslDefine, BX_COUNTOF(glslDefine), "BGFX_SHADER_LANGUAGE_GLSL=%d", essl ? 1 : glsl);
849849
850850   if (0 == bx::stricmp(platform, "android") )
851851   {
r245576r245577
972972
973973            const char* name      = parse = bx::strws(bx::strword(parse) );
974974            const char* column    = parse = bx::strws(bx::strword(parse) );
975            const char* semantics = parse = bx::strws(bx::strnws (parse) );
975            const char* semantics = parse = bx::strws((*parse == ':' ? ++parse : parse));
976976            const char* assign    = parse = bx::strws(bx::strword(parse) );
977            const char* init      = parse = bx::strws(bx::strnws (parse) );
977            const char* init      = parse = bx::strws((*parse == '=' ? ++parse : parse));
978978
979979            if (type < eol
980980            &&  name < eol
r245576r245577
11551155         }
11561156         else
11571157         {
1158            if (0 != glsl)
1158            if (0 != glsl
1159            ||  0 != essl)
11591160            {
11601161            }
11611162            else
r245576r245577
12691270                  bx::write(writer, BGFX_CHUNK_MAGIC_CSH);
12701271                  bx::write(writer, outputHash);
12711272
1272                  if (0 != glsl)
1273                  if (0 != glsl
1274                  ||  0 != essl)
12731275                  {
12741276                     std::string code;
12751277
r245576r245577
13381340         }
13391341         else
13401342         {
1341            if (0 != glsl)
1343            if (0 != glsl
1344            ||  0 != essl)
13421345            {
13431346               if (120 == glsl
1344               ||  essl)
1347               ||  0   != essl)
13451348               {
13461349                  preprocessor.writef(
13471350                     "#define ivec2 vec2\n"
r245576r245577
17001703                     bx::write(writer, outputHash);
17011704                  }
17021705
1703                  if (0 != glsl)
1706                  if (0 != glsl
1707                  ||  0 != essl)
17041708                  {
17051709                     std::string code;
17061710
trunk/3rdparty/bgfx/tools/shaderc/shaderc_dx11.cpp
r245576r245577
88#if SHADERC_CONFIG_DIRECT3D11
99
1010#include <d3dcompiler.h>
11#include <d3d11shader.h>
1112
13#ifndef D3D_SVF_USED
14#   define D3D_SVF_USED 2
15#endif // D3D_SVF_USED
16
17static const GUID GUID_ID3D11ShaderReflection = { 0x0a233719, 0x3960, 0x4578, { 0x9d, 0x7c, 0x20, 0x3b, 0x8b, 0x1d, 0x9c, 0xc1 } };
18
1219struct RemapInputSemantic
1320{
1421   bgfx::Attrib::Enum m_attr;
r245576r245577
202209   ID3D11ShaderReflection* reflect = NULL;
203210   hr = D3DReflect(code->GetBufferPointer()
204211      , code->GetBufferSize()
205      , IID_ID3D11ShaderReflection
212      , GUID_ID3D11ShaderReflection
206213      , (void**)&reflect
207214      );
208215   if (FAILED(hr) )
r245576r245577
370377      ID3DBlob* stripped;
371378      hr = D3DStripShader(code->GetBufferPointer()
372379         , code->GetBufferSize()
373         , D3DCOMPILER_STRIP_REFLECTION_DATA   
380         , D3DCOMPILER_STRIP_REFLECTION_DATA
374381         | D3DCOMPILER_STRIP_TEST_BLOBS
375382         , &stripped
376383         );
r245576r245577
437444   return false;
438445}
439446
440#endif // SHADERC_CONFIG_DIRECT3D11
No newline at end of file
447#endif // SHADERC_CONFIG_DIRECT3D11
trunk/3rdparty/bx/include/bx/handlealloc.h
r245576r245577
7171         uint16_t* sparse = &m_handles[MaxHandlesT];
7272         uint16_t index = sparse[_handle];
7373
74         return (index < m_numHandles && m_handles[index] == _handle);
74         return index < m_numHandles
75            && m_handles[index] == _handle
76            ;
7577      }
7678
7779      void free(uint16_t _handle)
trunk/3rdparty/bx/include/bx/platform.h
r245576r245577
218218            BX_STRINGIZE(__clang_minor__) "." \
219219            BX_STRINGIZE(__clang_patchlevel__)
220220#elif BX_COMPILER_MSVC
221#   if BX_COMPILER_MSVC >= 1800
221#   if BX_COMPILER_MSVC >= 1900
222#      define BX_COMPILER_NAME "MSVC 14.0"
223#   elif BX_COMPILER_MSVC >= 1800
222224#      define BX_COMPILER_NAME "MSVC 12.0"
223225#   elif BX_COMPILER_MSVC >= 1700
224226#      define BX_COMPILER_NAME "MSVC 11.0"
trunk/3rdparty/bx/include/bx/radixsort.h
r245576r245577
3030         memset(histogram, 0, sizeof(uint16_t)*BX_RADIXSORT_HISTOGRAM_SIZE);
3131
3232         bool sorted = true;
33         uint32_t key = keys[0];
34         uint32_t prevKey = key;
35         for (uint32_t ii = 0; ii < _size; ++ii, prevKey = key)
3633         {
37            key = keys[ii];
38            uint16_t index = (key>>shift)&BX_RADIXSORT_BIT_MASK;
39            ++histogram[index];
40            sorted &= prevKey <= key;
34            uint32_t key = keys[0];
35            uint32_t prevKey = key;
36            for (uint32_t ii = 0; ii < _size; ++ii, prevKey = key)
37            {
38               key = keys[ii];
39               uint16_t index = (key>>shift)&BX_RADIXSORT_BIT_MASK;
40               ++histogram[index];
41               sorted &= prevKey <= key;
42            }
4143         }
4244
4345         if (sorted)
r245576r245577
101103         memset(histogram, 0, sizeof(uint16_t)*BX_RADIXSORT_HISTOGRAM_SIZE);
102104
103105         bool sorted = true;
104         uint64_t key = keys[0];
105         uint64_t prevKey = key;
106         for (uint32_t ii = 0; ii < _size; ++ii, prevKey = key)
107106         {
108            key = keys[ii];
109            uint16_t index = (key>>shift)&BX_RADIXSORT_BIT_MASK;
110            ++histogram[index];
111            sorted &= prevKey <= key;
107            uint64_t key = keys[0];
108            uint64_t prevKey = key;
109            for (uint32_t ii = 0; ii < _size; ++ii, prevKey = key)
110            {
111               key = keys[ii];
112               uint16_t index = (key>>shift)&BX_RADIXSORT_BIT_MASK;
113               ++histogram[index];
114               sorted &= prevKey <= key;
115            }
112116         }
113117
114118         if (sorted)
trunk/3rdparty/bx/scripts/toolchain.lua
r245576r245577
1919         { "asmjs",         "Emscripten/asm.js"      },
2020         { "freebsd",       "FreeBSD"                },
2121         { "linux-gcc",     "Linux (GCC compiler)"   },
22         { "linux-gcc-5",   "Linux (GCC-5 compiler)" },
2223         { "linux-clang",   "Linux (Clang compiler)" },
2324         { "ios-arm",       "iOS - ARM"              },
2425         { "ios-simulator", "iOS - Simulator"        },
r245576r245577
4041      allowed = {
4142         { "vs2012-clang",  "Clang 3.6"         },
4243         { "vs2013-clang",  "Clang 3.6"         },
43         { "vs2012-xp",       "Visual Studio 2012 targeting XP" },
44         { "vs2013-xp",       "Visual Studio 2013 targeting XP" },
44         { "vs2012-xp",     "Visual Studio 2012 targeting XP" },
45         { "vs2013-xp",     "Visual Studio 2013 targeting XP" },
46         { "vs2015-xp",     "Visual Studio 2015 targeting XP" },
4547         { "winphone8",     "Windows Phone 8.0" },
4648         { "winphone81",    "Windows Phone 8.1" },
4749      },
r245576r245577
110112         premake.gcc.cxx = "$(ANDROID_NDK_ARM)/bin/arm-linux-androideabi-g++"
111113         premake.gcc.ar  = "$(ANDROID_NDK_ARM)/bin/arm-linux-androideabi-ar"
112114         location (path.join(_buildDir, "projects", _ACTION .. "-android-arm"))
113      end
114115
115      if "android-mips" == _OPTIONS["gcc"] then
116      elseif "android-mips" == _OPTIONS["gcc"] then
116117
117118         if not os.getenv("ANDROID_NDK_MIPS") or not os.getenv("ANDROID_NDK_ROOT") then
118119            print("Set ANDROID_NDK_MIPS and ANDROID_NDK_ROOT envrionment variables.")
r245576r245577
122123         premake.gcc.cxx = "$(ANDROID_NDK_MIPS)/bin/mipsel-linux-android-g++"
123124         premake.gcc.ar  = "$(ANDROID_NDK_MIPS)/bin/mipsel-linux-android-ar"
124125         location (path.join(_buildDir, "projects", _ACTION .. "-android-mips"))
125      end
126126
127      if "android-x86" == _OPTIONS["gcc"] then
127      elseif "android-x86" == _OPTIONS["gcc"] then
128128
129129         if not os.getenv("ANDROID_NDK_X86") or not os.getenv("ANDROID_NDK_ROOT") then
130130            print("Set ANDROID_NDK_X86 and ANDROID_NDK_ROOT envrionment variables.")
r245576r245577
134134         premake.gcc.cxx = "$(ANDROID_NDK_X86)/bin/i686-linux-android-g++"
135135         premake.gcc.ar  = "$(ANDROID_NDK_X86)/bin/i686-linux-android-ar"
136136         location (path.join(_buildDir, "projects", _ACTION .. "-android-x86"))
137      end
138137
139      if "asmjs" == _OPTIONS["gcc"] then
138      elseif "asmjs" == _OPTIONS["gcc"] then
140139
141140         if not os.getenv("EMSCRIPTEN") then
142141            print("Set EMSCRIPTEN enviroment variables.")
r245576r245577
147146         premake.gcc.ar   = "$(EMSCRIPTEN)/emar"
148147         premake.gcc.llvm = true
149148         location (path.join(_buildDir, "projects", _ACTION .. "-asmjs"))
150      end
151149
152      if "freebsd" == _OPTIONS["gcc"] then
150      elseif "freebsd" == _OPTIONS["gcc"] then
153151         location (path.join(_buildDir, "projects", _ACTION .. "-freebsd"))
154      end
155152
156      if "ios-arm" == _OPTIONS["gcc"] then
153      elseif "ios-arm" == _OPTIONS["gcc"] then
157154         premake.gcc.cc  = "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang"
158155         premake.gcc.cxx = "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++"
159156         premake.gcc.ar  = "ar"
160157         location (path.join(_buildDir, "projects", _ACTION .. "-ios-arm"))
161      end
162158
163      if "ios-simulator" == _OPTIONS["gcc"] then
159      elseif "ios-simulator" == _OPTIONS["gcc"] then
164160         premake.gcc.cc  = "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang"
165161         premake.gcc.cxx = "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++"
166162         premake.gcc.ar  = "ar"
167163         location (path.join(_buildDir, "projects", _ACTION .. "-ios-simulator"))
168      end
169164
170      if "linux-gcc" == _OPTIONS["gcc"] then
165      elseif "linux-gcc" == _OPTIONS["gcc"] then
171166         location (path.join(_buildDir, "projects", _ACTION .. "-linux"))
172      end
173167
174      if "linux-clang" == _OPTIONS["gcc"] then
168      elseif "linux-gcc-5" == _OPTIONS["gcc"] then
169         premake.gcc.cc  = "gcc-5"
170         premake.gcc.cxx = "g++-5"
171         premake.gcc.ar  = "ar"
172         location (path.join(_buildDir, "projects", _ACTION .. "-linux"))
173
174      elseif "linux-clang" == _OPTIONS["gcc"] then
175175         premake.gcc.cc  = "clang"
176176         premake.gcc.cxx = "clang++"
177177         premake.gcc.ar  = "ar"
178178         location (path.join(_buildDir, "projects", _ACTION .. "-linux-clang"))
179      end
180179
181      if "mingw-gcc" == _OPTIONS["gcc"] then
180      elseif "mingw-gcc" == _OPTIONS["gcc"] then
182181         premake.gcc.cc  = "$(MINGW)/bin/x86_64-w64-mingw32-gcc"
183182         premake.gcc.cxx = "$(MINGW)/bin/x86_64-w64-mingw32-g++"
184183         premake.gcc.ar  = "$(MINGW)/bin/ar"
185184         location (path.join(_buildDir, "projects", _ACTION .. "-mingw-gcc"))
186      end
187185
188      if "mingw-clang" == _OPTIONS["gcc"] then
186      elseif "mingw-clang" == _OPTIONS["gcc"] then
189187         premake.gcc.cc   = "$(CLANG)/bin/clang"
190188         premake.gcc.cxx  = "$(CLANG)/bin/clang++"
191189         premake.gcc.ar   = "$(MINGW)/bin/ar"
192190--         premake.gcc.ar   = "$(CLANG)/bin/llvm-ar"
193191--         premake.gcc.llvm = true
194192         location (path.join(_buildDir, "projects", _ACTION .. "-mingw-clang"))
195      end
196193
197      if "nacl" == _OPTIONS["gcc"] then
194      elseif "nacl" == _OPTIONS["gcc"] then
198195
199196         if not os.getenv("NACL_SDK_ROOT") then
200197            print("Set NACL_SDK_ROOT enviroment variables.")
r245576r245577
211208         premake.gcc.cxx = naclToolchain .. "g++"
212209         premake.gcc.ar  = naclToolchain .. "ar"
213210         location (path.join(_buildDir, "projects", _ACTION .. "-nacl"))
214      end
215211
216      if "nacl-arm" == _OPTIONS["gcc"] then
212      elseif "nacl-arm" == _OPTIONS["gcc"] then
217213
218214         if not os.getenv("NACL_SDK_ROOT") then
219215            print("Set NACL_SDK_ROOT enviroment variables.")
r245576r245577
230226         premake.gcc.cxx = naclToolchain .. "g++"
231227         premake.gcc.ar  = naclToolchain .. "ar"
232228         location (path.join(_buildDir, "projects", _ACTION .. "-nacl-arm"))
233      end
234229
235      if "osx" == _OPTIONS["gcc"] then
230      elseif "osx" == _OPTIONS["gcc"] then
231
236232         if os.is("linux") then
237233            local osxToolchain = "x86_64-apple-darwin13-"
238234            premake.gcc.cc  = osxToolchain .. "clang"
r245576r245577
240236            premake.gcc.ar  = osxToolchain .. "ar"
241237         end
242238         location (path.join(_buildDir, "projects", _ACTION .. "-osx"))
243      end
244239
245      if "pnacl" == _OPTIONS["gcc"] then
240      elseif "pnacl" == _OPTIONS["gcc"] then
246241
247242         if not os.getenv("NACL_SDK_ROOT") then
248243            print("Set NACL_SDK_ROOT enviroment variables.")
r245576r245577
259254         premake.gcc.cxx = naclToolchain .. "clang++"
260255         premake.gcc.ar  = naclToolchain .. "ar"
261256         location (path.join(_buildDir, "projects", _ACTION .. "-pnacl"))
262      end
263257
264      if "qnx-arm" == _OPTIONS["gcc"] then
258      elseif "qnx-arm" == _OPTIONS["gcc"] then
265259
266260         if not os.getenv("QNX_HOST") then
267261            print("Set QNX_HOST enviroment variables.")
r245576r245577
271265         premake.gcc.cxx = "$(QNX_HOST)/usr/bin/arm-unknown-nto-qnx8.0.0eabi-g++"
272266         premake.gcc.ar  = "$(QNX_HOST)/usr/bin/arm-unknown-nto-qnx8.0.0eabi-ar"
273267         location (path.join(_buildDir, "projects", _ACTION .. "-qnx-arm"))
274      end
275268
276      if "rpi" == _OPTIONS["gcc"] then
269      elseif "rpi" == _OPTIONS["gcc"] then
277270         location (path.join(_buildDir, "projects", _ACTION .. "-rpi"))
278271      end
279272   elseif _ACTION == "vs2012" or _ACTION == "vs2013" or _ACTION == "vs2015" then
r245576r245577
281274      if (_ACTION .. "-clang") == _OPTIONS["vs"] then
282275         premake.vstudio.toolset = ("LLVM-" .. _ACTION)
283276         location (path.join(_buildDir, "projects", _ACTION .. "-clang"))
284      end
285277
286      if "winphone8" == _OPTIONS["vs"] then
278      elseif "winphone8" == _OPTIONS["vs"] then
287279         premake.vstudio.toolset = "v110_wp80"
288280         location (path.join(_buildDir, "projects", _ACTION .. "-winphone8"))
289      end
290281
291      if "winphone81" == _OPTIONS["vs"] then
282      elseif "winphone81" == _OPTIONS["vs"] then
292283         premake.vstudio.toolset = "v120_wp81"
293284         platforms { "ARM" }
294285         location (path.join(_buildDir, "projects", _ACTION .. "-winphone81"))
295      end
296286
297      if ("vs2012-xp") == _OPTIONS["vs"] then
287      elseif ("vs2012-xp") == _OPTIONS["vs"] then
298288         premake.vstudio.toolset = ("v110_xp")
299289         location (path.join(_buildDir, "projects", _ACTION .. "-xp"))
300      end
301290
302      if ("vs2013-xp") == _OPTIONS["vs"] then
291      elseif ("vs2013-xp") == _OPTIONS["vs"] then
303292         premake.vstudio.toolset = ("v120_xp")
304293         location (path.join(_buildDir, "projects", _ACTION .. "-xp"))
294
295      elseif ("vs2015-xp") == _OPTIONS["vs"] then
296         premake.vstudio.toolset = ("v140_xp")
297         location (path.join(_buildDir, "projects", _ACTION .. "-xp"))
305298      end
306299
307300   elseif _ACTION == "xcode4" then
r245576r245577
309302      if "osx" == _OPTIONS["xcode"] then
310303         premake.xcode.toolset = "macosx"
311304         location (path.join(_buildDir, "projects", _ACTION .. "-osx"))
312      end
313      if "ios" == _OPTIONS["xcode"] then
305
306      elseif "ios" == _OPTIONS["xcode"] then
314307         premake.xcode.toolset = "iphoneos"
315308         location (path.join(_buildDir, "projects", _ACTION .. "-ios"))
316309      end
r245576r245577
479472      }
480473      buildoptions { "-m64" }
481474
482   configuration { "linux-gcc and not linux-clang" }
475   configuration { "linux-clang" }
476
477   configuration { "linux-gcc-5" }
483478      buildoptions {
479--         "-fno-omit-frame-pointer",
480--         "-fsanitize=address",
481--         "-fsanitize=undefined",
482--         "-fsanitize=float-divide-by-zero",
483--         "-fsanitize=float-cast-overflow",
484      }
485      links {
486--         "asan",
487--         "ubsan",
488      }
489
490   configuration { "linux-g*" }
491      buildoptions {
484492         "-mfpmath=sse", -- force SSE to get 32-bit and 64-bit builds deterministic.
485493      }
486494
487   configuration { "linux-clang" }
488
489495   configuration { "linux-*" }
490496      buildoptions {
491497         "-msse2",
r245576r245577
494500      }
495501      buildoptions_cpp {
496502         "-std=c++0x",
497      }     
503      }
498504      links {
499505         "rt",
500506         "dl",
r245576r245577
503509         "-Wl,--gc-sections",
504510      }
505511
506   configuration { "linux-gcc", "x32" }
512   configuration { "linux-g*", "x32" }
507513      targetdir (path.join(_buildDir, "linux32_gcc/bin"))
508514      objdir (path.join(_buildDir, "linux32_gcc/obj"))
509515      libdirs { path.join(_libDir, "lib/linux32_gcc") }
r245576r245577
511517         "-m32",
512518      }
513519
514   configuration { "linux-gcc", "x64" }
520   configuration { "linux-g*", "x64" }
515521      targetdir (path.join(_buildDir, "linux64_gcc/bin"))
516522      objdir (path.join(_buildDir, "linux64_gcc/obj"))
517523      libdirs { path.join(_libDir, "lib/linux64_gcc") }
r245576r245577
558564      }
559565      buildoptions {
560566         "-fPIC",
561         "-std=c++0x",
562567         "-no-canonical-prefixes",
563568         "-Wa,--noexecstack",
564569         "-fstack-protector",
r245576r245577
567572         "-Wunused-value",
568573         "-Wundef",
569574      }
575      buildoptions_cpp {
576         "-std=c++0x",
577      }
570578      linkoptions {
571579         "-no-canonical-prefixes",
572580         "-Wl,--no-undefined",
r245576r245577
670678
671679   configuration { "nacl or nacl-arm or pnacl" }
672680      buildoptions {
673         "-std=c++0x",
674681         "-U__STRICT_ANSI__", -- strcasecmp, setenv, unsetenv,...
675682         "-fno-stack-protector",
676683         "-fdiagnostics-show-option",
r245576r245577
679686         "-Wunused-value",
680687         "-Wundef",
681688      }
689      buildoptions_cpp {
690         "-std=c++0x",
691      }
682692      includedirs {
683693         "$(NACL_SDK_ROOT)/include",
684694         path.join(bxDir, "include/compat/nacl"),
r245576r245577
756766   configuration { "osx", "x32" }
757767      targetdir (path.join(_buildDir, "osx32_clang/bin"))
758768      objdir (path.join(_buildDir, "osx32_clang/obj"))
759      libdirs { path.join(_libDir, "lib/osx32_clang") }
769      --libdirs { path.join(_libDir, "lib/osx32_clang") }
760770      buildoptions {
761771         "-m32",
762772      }
r245576r245577
764774   configuration { "osx", "x64" }
765775      targetdir (path.join(_buildDir, "osx64_clang/bin"))
766776      objdir (path.join(_buildDir, "osx64_clang/obj"))
767      libdirs { path.join(_libDir, "lib/osx64_clang") }
777      --libdirs { path.join(_libDir, "lib/osx64_clang") }
768778      buildoptions {
769779         "-m64",
770780      }
r245576r245577
831841      libdirs { path.join(_libDir, "lib/qnx-arm") }
832842--      includedirs { path.join(bxDir, "include/compat/qnx") }
833843      buildoptions {
834         "-std=c++0x",
835844         "-Wno-psabi", -- note: the mangling of 'va_list' has changed in GCC 4.4.0
836845         "-Wunused-value",
837846         "-Wundef",
838847      }
848      buildoptions_cpp {
849         "-std=c++0x",
850      }
839851
840852   configuration { "rpi" }
841853      targetdir (path.join(_buildDir, "rpi/bin"))
trunk/3rdparty/bx/tests/unordered_map_nonpod.cpp
r245576r245577
2929#include <tinystl/allocator.h>
3030#include <tinystl/unordered_map.h>
3131
32struct Foo { int bar; };
33
3234TEST(uomap_nonpod_compiles) {
33   struct Foo { int bar; };
3435
3536   // verify this compiles
3637   typedef tinystl::unordered_map<int, Foo> map;
3738   map m;
38}
No newline at end of file
39}
trunk/3rdparty/bx/tools/bin/darwin/genie
r245576r245577
Previous 199869 Revisions Next


© 1997-2024 The MAME Team