| [/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/3rdparty/bgfx/examples/24-nbody/nbody.cpp
| r245576 | r245577 | |
| 117 | 117 | , 0 |
| 118 | 118 | ); |
| 119 | 119 | |
| 120 | | // Imgui. |
| 121 | | imguiCreate(); |
| 120 | const bgfx::Caps* caps = bgfx::getCaps(); |
| 121 | const bool computeSupported = !!(caps->supported & BGFX_CAPS_COMPUTE); |
| 122 | 122 | |
| 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(); |
| 127 | 127 | |
| 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(); |
| 134 | 132 | |
| 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 | ); |
| 140 | 139 | |
| 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 | ); |
| 143 | 145 | |
| 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"); |
| 149 | 148 | |
| 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(); |
| 152 | 154 | |
| 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; |
| 157 | 157 | |
| 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); |
| 159 | 162 | |
| 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); |
| 164 | 164 | |
| 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); |
| 167 | 169 | |
| 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); |
| 172 | 172 | |
| 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); |
| 179 | 177 | |
| 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); |
| 181 | 184 | |
| 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; |
| 191 | 186 | |
| 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); |
| 194 | 196 | |
| 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); |
| 199 | 199 | |
| 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."); |
| 225 | 204 | |
| 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(); |
| 232 | 230 | |
| 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); |
| 237 | 250 | 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); |
| 240 | 252 | |
| 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); |
| 247 | 255 | |
| 248 | | bx::xchg(currPositionBuffer0, currPositionBuffer1); |
| 249 | | bx::xchg(prevPositionBuffer0, prevPositionBuffer1); |
| 256 | // Update camera. |
| 257 | cameraUpdate(deltaTime, mouseState); |
| 258 | cameraGetViewMtx(view); |
| 250 | 259 | |
| 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); |
| 252 | 267 | |
| 253 | | // Update camera. |
| 254 | | cameraUpdate(deltaTime, mouseState); |
| 255 | | cameraGetViewMtx(view); |
| 268 | float tmp[16]; |
| 269 | bx::mtxMul(tmp, view, viewHead); |
| 256 | 270 | |
| 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); |
| 264 | 273 | |
| 265 | | float tmp[16]; |
| 266 | | bx::mtxMul(tmp, view, viewHead); |
| 274 | bgfx::setViewTransform(0, tmp, proj); |
| 267 | 275 | |
| 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); |
| 270 | 287 | |
| 271 | | bgfx::setViewTransform(0, tmp, proj); |
| 288 | // Set view 0 default viewport. |
| 289 | bgfx::setViewRect(0, 0, 0, width, height); |
| 290 | } |
| 272 | 291 | |
| 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(); |
| 278 | 313 | } |
| 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) ) |
| 280 | 335 | { |
| 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() ) ); |
| 284 | 338 | |
| 285 | | // Set view 0 default viewport. |
| 286 | 339 | bgfx::setViewRect(0, 0, 0, width, height); |
| 287 | | } |
| 288 | 340 | |
| 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."); |
| 291 | 344 | |
| 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. "); |
| 296 | 347 | |
| 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 | } |
| 310 | 351 | } |
| 311 | 352 | |
| 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 | | |
| 326 | 353 | // Shutdown bgfx. |
| 327 | 354 | bgfx::shutdown(); |
| 328 | 355 | |
trunk/3rdparty/bgfx/src/bgfx.cpp
| r245576 | r245577 | |
| 19 | 19 | # define BGFX_CHECK_RENDER_THREAD() |
| 20 | 20 | #endif // BGFX_CONFIG_MULTITHREADED && !BX_PLATFORM_OSX && !BX_PLATFORM_IOS |
| 21 | 21 | |
| 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 | | |
| 30 | 22 | #if BX_PLATFORM_ANDROID |
| 31 | 23 | ::ANativeWindow* g_bgfxAndroidWindow = NULL; |
| 32 | 24 | |
| r245576 | r245577 | |
| 44 | 36 | #elif BX_PLATFORM_LINUX |
| 45 | 37 | void* g_bgfxX11Display; |
| 46 | 38 | uint32_t g_bgfxX11Window; |
| 39 | void* g_bgfxGLX; |
| 47 | 40 | |
| 48 | | void x11SetDisplayWindow(void* _display, uint32_t _window) |
| 41 | void x11SetDisplayWindow(void* _display, uint32_t _window, void* _glx) |
| 49 | 42 | { |
| 50 | 43 | g_bgfxX11Display = _display; |
| 51 | 44 | g_bgfxX11Window = _window; |
| 45 | g_bgfxGLX = _glx; |
| 52 | 46 | } |
| 53 | 47 | #elif BX_PLATFORM_OSX |
| 54 | 48 | void* g_bgfxNSWindow = NULL; |
| 49 | void* g_bgfxNSGL = NULL; |
| 55 | 50 | |
| 56 | | void osxSetNSWindow(void* _window) |
| 51 | void osxSetNSWindow(void* _window, void* _nsgl) |
| 57 | 52 | { |
| 58 | 53 | g_bgfxNSWindow = _window; |
| 54 | g_bgfxNSGL = _nsgl; |
| 59 | 55 | } |
| 60 | 56 | #elif BX_PLATFORM_WINDOWS |
| 61 | 57 | ::HWND g_bgfxHwnd = NULL; |
| r245576 | r245577 | |
| 892 | 888 | |
| 893 | 889 | static void dumpCaps() |
| 894 | 890 | { |
| 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 | ); |
| 896 | 896 | for (uint32_t ii = 0; ii < BX_COUNTOF(s_capsFlags); ++ii) |
| 897 | 897 | { |
| 898 | 898 | if (0 != (g_caps.supported & s_capsFlags[ii].m_flag) ) |
| r245576 | r245577 | |
| 1332 | 1332 | typedef RendererContextI* (*RendererCreateFn)(); |
| 1333 | 1333 | typedef void (*RendererDestroyFn)(); |
| 1334 | 1334 | |
| 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 | } |
| 1337 | 1341 | |
| 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); |
| 1340 | 1348 | |
| 1341 | | extern RendererContextI* rendererCreateD3D9(); |
| 1342 | | extern void rendererDestroyD3D9(); |
| 1349 | #undef BGFX_RENDERER_CONTEXT |
| 1343 | 1350 | |
| 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 | | |
| 1353 | 1351 | struct RendererCreator |
| 1354 | 1352 | { |
| 1355 | 1353 | RendererCreateFn createFn; |
| r245576 | r245577 | |
| 1360 | 1358 | |
| 1361 | 1359 | static const RendererCreator s_rendererCreator[] = |
| 1362 | 1360 | { |
| 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 |
| 1370 | 1368 | }; |
| 1371 | 1369 | BX_STATIC_ASSERT(BX_COUNTOF(s_rendererCreator) == RendererType::Count); |
| 1372 | 1370 | |
| r245576 | r245577 | |
| 1983 | 1981 | return s_rendererCreator[_type].name; |
| 1984 | 1982 | } |
| 1985 | 1983 | |
| 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) |
| 1987 | 1985 | { |
| 1988 | 1986 | BX_CHECK(NULL == s_ctx, "bgfx is already initialized."); |
| 1989 | 1987 | BX_TRACE("Init..."); |
| r245576 | r245577 | |
| 1995 | 1993 | g_caps.maxViews = BGFX_CONFIG_MAX_VIEWS; |
| 1996 | 1994 | g_caps.maxDrawCalls = BGFX_CONFIG_MAX_DRAW_CALLS; |
| 1997 | 1995 | g_caps.maxFBAttachments = 1; |
| 1996 | g_caps.vendorId = _vendorId; |
| 1997 | g_caps.deviceId = _deviceId; |
| 1998 | 1998 | |
| 1999 | 1999 | if (NULL != _allocator) |
| 2000 | 2000 | { |
| r245576 | r245577 | |
| 2770 | 2770 | void setUniform(UniformHandle _handle, const void* _value, uint16_t _num) |
| 2771 | 2771 | { |
| 2772 | 2772 | BGFX_CHECK_MAIN_THREAD(); |
| 2773 | | BGFX_CHECK_HANDLE(_handle, BGFX_CONFIG_MAX_UNIFORMS); |
| 2774 | 2773 | s_ctx->setUniform(_handle, _value, _num); |
| 2775 | 2774 | } |
| 2776 | 2775 | |
| 2777 | 2776 | void setIndexBuffer(IndexBufferHandle _handle, uint32_t _firstIndex, uint32_t _numIndices) |
| 2778 | 2777 | { |
| 2779 | 2778 | BGFX_CHECK_MAIN_THREAD(); |
| 2780 | | BGFX_CHECK_HANDLE(_handle, BGFX_CONFIG_MAX_INDEX_BUFFERS); |
| 2781 | 2779 | s_ctx->setIndexBuffer(_handle, _firstIndex, _numIndices); |
| 2782 | 2780 | } |
| 2783 | 2781 | |
| 2784 | 2782 | void setIndexBuffer(DynamicIndexBufferHandle _handle, uint32_t _firstIndex, uint32_t _numIndices) |
| 2785 | 2783 | { |
| 2786 | 2784 | BGFX_CHECK_MAIN_THREAD(); |
| 2787 | | BGFX_CHECK_HANDLE(_handle, BGFX_CONFIG_MAX_DYNAMIC_INDEX_BUFFERS); |
| 2788 | 2785 | s_ctx->setIndexBuffer(_handle, _firstIndex, _numIndices); |
| 2789 | 2786 | } |
| 2790 | 2787 | |
| r245576 | r245577 | |
| 2809 | 2806 | void setVertexBuffer(VertexBufferHandle _handle, uint32_t _startVertex, uint32_t _numVertices) |
| 2810 | 2807 | { |
| 2811 | 2808 | BGFX_CHECK_MAIN_THREAD(); |
| 2812 | | BGFX_CHECK_HANDLE(_handle, BGFX_CONFIG_MAX_VERTEX_BUFFERS); |
| 2813 | 2809 | s_ctx->setVertexBuffer(_handle, _startVertex, _numVertices); |
| 2814 | 2810 | } |
| 2815 | 2811 | |
| 2816 | 2812 | void setVertexBuffer(DynamicVertexBufferHandle _handle, uint32_t _numVertices) |
| 2817 | 2813 | { |
| 2818 | 2814 | BGFX_CHECK_MAIN_THREAD(); |
| 2819 | | BGFX_CHECK_HANDLE(_handle, BGFX_CONFIG_MAX_DYNAMIC_VERTEX_BUFFERS); |
| 2820 | 2815 | s_ctx->setVertexBuffer(_handle, _numVertices); |
| 2821 | 2816 | } |
| 2822 | 2817 | |
| r245576 | r245577 | |
| 2842 | 2837 | void setInstanceDataBuffer(VertexBufferHandle _handle, uint32_t _startVertex, uint32_t _num) |
| 2843 | 2838 | { |
| 2844 | 2839 | BGFX_CHECK_MAIN_THREAD(); |
| 2845 | | BGFX_CHECK_HANDLE(_handle, BGFX_CONFIG_MAX_VERTEX_BUFFERS); |
| 2846 | 2840 | s_ctx->setInstanceDataBuffer(_handle, _startVertex, _num); |
| 2847 | 2841 | } |
| 2848 | 2842 | |
| 2849 | 2843 | void setInstanceDataBuffer(DynamicVertexBufferHandle _handle, uint32_t _startVertex, uint32_t _num) |
| 2850 | 2844 | { |
| 2851 | 2845 | BGFX_CHECK_MAIN_THREAD(); |
| 2852 | | BGFX_CHECK_HANDLE(_handle, BGFX_CONFIG_MAX_DYNAMIC_VERTEX_BUFFERS); |
| 2853 | 2846 | s_ctx->setInstanceDataBuffer(_handle, _startVertex, _num); |
| 2854 | 2847 | } |
| 2855 | 2848 | |
| 2856 | 2849 | void setProgram(ProgramHandle _handle) |
| 2857 | 2850 | { |
| 2858 | 2851 | BGFX_CHECK_MAIN_THREAD(); |
| 2859 | | BGFX_CHECK_HANDLE(_handle, BGFX_CONFIG_MAX_PROGRAMS); |
| 2860 | 2852 | s_ctx->setProgram(_handle); |
| 2861 | 2853 | } |
| 2862 | 2854 | |
| r245576 | r245577 | |
| 2881 | 2873 | void setBuffer(uint8_t _stage, IndexBufferHandle _handle, Access::Enum _access) |
| 2882 | 2874 | { |
| 2883 | 2875 | BGFX_CHECK_MAIN_THREAD(); |
| 2884 | | BGFX_CHECK_HANDLE(_handle, BGFX_CONFIG_MAX_INDEX_BUFFERS); |
| 2885 | 2876 | s_ctx->setBuffer(_stage, _handle, _access); |
| 2886 | 2877 | } |
| 2887 | 2878 | |
| 2888 | 2879 | void setBuffer(uint8_t _stage, VertexBufferHandle _handle, Access::Enum _access) |
| 2889 | 2880 | { |
| 2890 | 2881 | BGFX_CHECK_MAIN_THREAD(); |
| 2891 | | BGFX_CHECK_HANDLE(_handle, BGFX_CONFIG_MAX_VERTEX_BUFFERS); |
| 2892 | 2882 | s_ctx->setBuffer(_stage, _handle, _access); |
| 2893 | 2883 | } |
| 2894 | 2884 | |
| 2895 | 2885 | void setBuffer(uint8_t _stage, DynamicIndexBufferHandle _handle, Access::Enum _access) |
| 2896 | 2886 | { |
| 2897 | 2887 | BGFX_CHECK_MAIN_THREAD(); |
| 2898 | | BGFX_CHECK_HANDLE(_handle, BGFX_CONFIG_MAX_DYNAMIC_INDEX_BUFFERS); |
| 2899 | 2888 | s_ctx->setBuffer(_stage, _handle, _access); |
| 2900 | 2889 | } |
| 2901 | 2890 | |
| 2902 | 2891 | void setBuffer(uint8_t _stage, DynamicVertexBufferHandle _handle, Access::Enum _access) |
| 2903 | 2892 | { |
| 2904 | 2893 | BGFX_CHECK_MAIN_THREAD(); |
| 2905 | | BGFX_CHECK_HANDLE(_handle, BGFX_CONFIG_MAX_DYNAMIC_VERTEX_BUFFERS); |
| 2906 | 2894 | s_ctx->setBuffer(_stage, _handle, _access); |
| 2907 | 2895 | } |
| 2908 | 2896 | |
| r245576 | r245577 | |
| 3030 | 3018 | return bgfx::getRendererName(bgfx::RendererType::Enum(_type) ); |
| 3031 | 3019 | } |
| 3032 | 3020 | |
| 3033 | | BGFX_C_API void bgfx_init(bgfx_renderer_type_t _type, struct bgfx_callback_interface* _callback, struct bgfx_reallocator_interface* _allocator) |
| 3021 | BGFX_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) |
| 3034 | 3022 | { |
| 3035 | 3023 | return bgfx::init(bgfx::RendererType::Enum(_type) |
| 3024 | , _vendorId |
| 3025 | , _deviceId |
| 3036 | 3026 | , reinterpret_cast<bgfx::CallbackI*>(_callback) |
| 3037 | 3027 | , reinterpret_cast<bx::ReallocatorI*>(_allocator) |
| 3038 | 3028 | ); |
trunk/3rdparty/bgfx/src/bgfx_p.h
| r245576 | r245577 | |
| 29 | 29 | #include <string.h> |
| 30 | 30 | #include <alloca.h> |
| 31 | 31 | |
| 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 | |
| 32 | 52 | namespace bgfx |
| 33 | 53 | { |
| 34 | 54 | #if BX_COMPILER_CLANG_ANALYZER |
| r245576 | r245577 | |
| 204 | 224 | #elif BX_PLATFORM_LINUX |
| 205 | 225 | extern void* g_bgfxX11Display; |
| 206 | 226 | extern uint32_t g_bgfxX11Window; |
| 227 | extern void* g_bgfxGLX; |
| 207 | 228 | #elif BX_PLATFORM_OSX |
| 208 | 229 | extern void* g_bgfxNSWindow; |
| 230 | extern void* g_bgfxNSGL; |
| 209 | 231 | #elif BX_PLATFORM_WINDOWS |
| 210 | 232 | extern ::HWND g_bgfxHwnd; |
| 211 | 233 | #elif BX_PLATFORM_WINRT |
| r245576 | r245577 | |
| 1418 | 1440 | { |
| 1419 | 1441 | Binding& sampler = m_draw.m_bind[_stage]; |
| 1420 | 1442 | 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 | ; |
| 1422 | 1447 | |
| 1423 | 1448 | if (isValid(_sampler) |
| 1424 | 1449 | && (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGL) || BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGLES) ) ) |
| r245576 | r245577 | |
| 1989 | 2014 | |
| 1990 | 2015 | BGFX_API_FUNC(void destroyIndexBuffer(IndexBufferHandle _handle) ) |
| 1991 | 2016 | { |
| 2017 | BGFX_CHECK_HANDLE("destroyIndexBuffer", m_indexBufferHandle, _handle); |
| 2018 | |
| 1992 | 2019 | CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::DestroyIndexBuffer); |
| 1993 | 2020 | cmdbuf.write(_handle); |
| 1994 | 2021 | m_submit->free(_handle); |
| r245576 | r245577 | |
| 2034 | 2061 | |
| 2035 | 2062 | BGFX_API_FUNC(void destroyVertexBuffer(VertexBufferHandle _handle) ) |
| 2036 | 2063 | { |
| 2064 | BGFX_CHECK_HANDLE("destroyVertexBuffer", m_vertexBufferHandle, _handle); |
| 2065 | |
| 2037 | 2066 | CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::DestroyVertexBuffer); |
| 2038 | 2067 | cmdbuf.write(_handle); |
| 2039 | 2068 | m_submit->free(_handle); |
| r245576 | r245577 | |
| 2135 | 2164 | |
| 2136 | 2165 | BGFX_API_FUNC(void updateDynamicIndexBuffer(DynamicIndexBufferHandle _handle, const Memory* _mem) ) |
| 2137 | 2166 | { |
| 2167 | BGFX_CHECK_HANDLE("updateDynamicIndexBuffer", m_dynamicIndexBufferHandle, _handle); |
| 2168 | |
| 2138 | 2169 | DynamicIndexBuffer& dib = m_dynamicIndexBuffers[_handle.idx]; |
| 2139 | 2170 | BX_CHECK(0 == (dib.m_flags & BGFX_BUFFER_COMPUTE_READ_WRITE), "Can't update GPU buffer from CPU."); |
| 2140 | 2171 | |
| r245576 | r245577 | |
| 2166 | 2197 | |
| 2167 | 2198 | BGFX_API_FUNC(void destroyDynamicIndexBuffer(DynamicIndexBufferHandle _handle) ) |
| 2168 | 2199 | { |
| 2200 | BGFX_CHECK_HANDLE("destroyDynamicIndexBuffer", m_dynamicIndexBufferHandle, _handle); |
| 2201 | |
| 2169 | 2202 | m_freeDynamicIndexBufferHandle[m_numFreeDynamicIndexBufferHandles++] = _handle; |
| 2170 | 2203 | } |
| 2171 | 2204 | |
| r245576 | r245577 | |
| 2279 | 2312 | |
| 2280 | 2313 | BGFX_API_FUNC(void updateDynamicVertexBuffer(DynamicVertexBufferHandle _handle, const Memory* _mem) ) |
| 2281 | 2314 | { |
| 2315 | BGFX_CHECK_HANDLE("updateDynamicVertexBuffer", m_dynamicVertexBufferHandle, _handle); |
| 2316 | |
| 2282 | 2317 | DynamicVertexBuffer& dvb = m_dynamicVertexBuffers[_handle.idx]; |
| 2283 | 2318 | BX_CHECK(0 == (dvb.m_flags & BGFX_BUFFER_COMPUTE_READ_WRITE), "Can't update GPU buffer from CPU."); |
| 2284 | 2319 | |
| r245576 | r245577 | |
| 2311 | 2346 | |
| 2312 | 2347 | BGFX_API_FUNC(void destroyDynamicVertexBuffer(DynamicVertexBufferHandle _handle) ) |
| 2313 | 2348 | { |
| 2349 | BGFX_CHECK_HANDLE("destroyDynamicVertexBuffer", m_dynamicVertexBufferHandle, _handle); |
| 2350 | |
| 2314 | 2351 | m_freeDynamicVertexBufferHandle[m_numFreeDynamicVertexBufferHandles++] = _handle; |
| 2315 | 2352 | } |
| 2316 | 2353 | |
| r245576 | r245577 | |
| 2593 | 2630 | |
| 2594 | 2631 | BGFX_API_FUNC(void destroyShader(ShaderHandle _handle) ) |
| 2595 | 2632 | { |
| 2633 | BGFX_CHECK_HANDLE("destroyShader", m_shaderHandle, _handle); |
| 2634 | |
| 2596 | 2635 | if (!isValid(_handle) ) |
| 2597 | 2636 | { |
| 2598 | 2637 | BX_WARN(false, "Passing invalid shader handle to bgfx::destroyShader."); |
| r245576 | r245577 | |
| 2704 | 2743 | |
| 2705 | 2744 | BGFX_API_FUNC(void destroyProgram(ProgramHandle _handle) ) |
| 2706 | 2745 | { |
| 2746 | BGFX_CHECK_HANDLE("destroyProgram", m_programHandle, _handle); |
| 2747 | |
| 2707 | 2748 | CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::DestroyProgram); |
| 2708 | 2749 | cmdbuf.write(_handle); |
| 2709 | 2750 | m_submit->free(_handle); |
| r245576 | r245577 | |
| 2769 | 2810 | |
| 2770 | 2811 | BGFX_API_FUNC(void destroyTexture(TextureHandle _handle) ) |
| 2771 | 2812 | { |
| 2813 | BGFX_CHECK_HANDLE("destroyTexture", m_textureHandle, _handle); |
| 2814 | |
| 2772 | 2815 | if (!isValid(_handle) ) |
| 2773 | 2816 | { |
| 2774 | 2817 | BX_WARN(false, "Passing invalid texture handle to bgfx::destroyTexture"); |
| r245576 | r245577 | |
| 2832 | 2875 | for (uint32_t ii = 0; ii < _num; ++ii) |
| 2833 | 2876 | { |
| 2834 | 2877 | TextureHandle texHandle = _handles[ii]; |
| 2878 | BGFX_CHECK_HANDLE("createFrameBuffer texture handle", m_textureHandle, texHandle); |
| 2835 | 2879 | |
| 2836 | 2880 | cmdbuf.write(texHandle); |
| 2837 | 2881 | |
| r245576 | r245577 | |
| 2868 | 2912 | |
| 2869 | 2913 | BGFX_API_FUNC(void destroyFrameBuffer(FrameBufferHandle _handle) ) |
| 2870 | 2914 | { |
| 2915 | BGFX_CHECK_HANDLE("destroyFrameBuffer", m_frameBufferHandle, _handle); |
| 2916 | |
| 2871 | 2917 | CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::DestroyFrameBuffer); |
| 2872 | 2918 | cmdbuf.write(_handle); |
| 2873 | 2919 | m_submit->free(_handle); |
| r245576 | r245577 | |
| 2951 | 2997 | |
| 2952 | 2998 | BGFX_API_FUNC(void destroyUniform(UniformHandle _handle) ) |
| 2953 | 2999 | { |
| 3000 | BGFX_CHECK_HANDLE("destroyUniform", m_uniformHandle, _handle); |
| 3001 | |
| 2954 | 3002 | UniformRef& uniform = m_uniformRef[_handle.idx]; |
| 2955 | 3003 | BX_CHECK(uniform.m_refCount > 0, "Destroying already destroyed uniform %d.", _handle.idx); |
| 2956 | 3004 | int32_t refs = --uniform.m_refCount; |
| r245576 | r245577 | |
| 3054 | 3102 | |
| 3055 | 3103 | BGFX_API_FUNC(void setViewFrameBuffer(uint8_t _id, FrameBufferHandle _handle) ) |
| 3056 | 3104 | { |
| 3105 | BGFX_CHECK_HANDLE_INVALID_OK("setViewFrameBuffer", m_frameBufferHandle, _handle); |
| 3057 | 3106 | m_fb[_id] = _handle; |
| 3058 | 3107 | } |
| 3059 | 3108 | |
| r245576 | r245577 | |
| 3091 | 3140 | |
| 3092 | 3141 | BGFX_API_FUNC(void setViewRemap(uint8_t _id, uint8_t _num, const void* _remap) ) |
| 3093 | 3142 | { |
| 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; |
| 3095 | 3144 | if (NULL == _remap) |
| 3096 | 3145 | { |
| 3097 | 3146 | for (uint32_t ii = 0; ii < num; ++ii) |
| r245576 | r245577 | |
| 3148 | 3197 | |
| 3149 | 3198 | BGFX_API_FUNC(void setUniform(UniformHandle _handle, const void* _value, uint16_t _num) ) |
| 3150 | 3199 | { |
| 3200 | BGFX_CHECK_HANDLE("setUniform", m_uniformHandle, _handle); |
| 3151 | 3201 | UniformRef& uniform = m_uniformRef[_handle.idx]; |
| 3152 | 3202 | BX_CHECK(uniform.m_num >= _num, "Truncated uniform update. %d (max: %d)", _num, uniform.m_num); |
| 3153 | 3203 | m_submit->writeUniform(uniform.m_type, _handle, _value, bx::uint16_min(uniform.m_num, _num) ); |
| r245576 | r245577 | |
| 3155 | 3205 | |
| 3156 | 3206 | BGFX_API_FUNC(void setIndexBuffer(IndexBufferHandle _handle, uint32_t _firstIndex, uint32_t _numIndices) ) |
| 3157 | 3207 | { |
| 3208 | BGFX_CHECK_HANDLE("setIndexBuffer", m_indexBufferHandle, _handle); |
| 3158 | 3209 | m_submit->setIndexBuffer(_handle, _firstIndex, _numIndices); |
| 3159 | 3210 | } |
| 3160 | 3211 | |
| 3161 | 3212 | BGFX_API_FUNC(void setIndexBuffer(DynamicIndexBufferHandle _handle, uint32_t _firstIndex, uint32_t _numIndices) ) |
| 3162 | 3213 | { |
| 3214 | BGFX_CHECK_HANDLE("setIndexBuffer", m_dynamicIndexBufferHandle, _handle); |
| 3163 | 3215 | m_submit->setIndexBuffer(m_dynamicIndexBuffers[_handle.idx], _firstIndex, _numIndices); |
| 3164 | 3216 | } |
| 3165 | 3217 | |
| r245576 | r245577 | |
| 3170 | 3222 | |
| 3171 | 3223 | BGFX_API_FUNC(void setVertexBuffer(VertexBufferHandle _handle, uint32_t _startVertex, uint32_t _numVertices) ) |
| 3172 | 3224 | { |
| 3225 | BGFX_CHECK_HANDLE("setVertexBuffer", m_vertexBufferHandle, _handle); |
| 3173 | 3226 | m_submit->setVertexBuffer(_handle, _startVertex, _numVertices); |
| 3174 | 3227 | } |
| 3175 | 3228 | |
| 3176 | 3229 | BGFX_API_FUNC(void setVertexBuffer(DynamicVertexBufferHandle _handle, uint32_t _numVertices) ) |
| 3177 | 3230 | { |
| 3231 | BGFX_CHECK_HANDLE("setVertexBuffer", m_dynamicVertexBufferHandle, _handle); |
| 3178 | 3232 | m_submit->setVertexBuffer(m_dynamicVertexBuffers[_handle.idx], _numVertices); |
| 3179 | 3233 | } |
| 3180 | 3234 | |
| r245576 | r245577 | |
| 3192 | 3246 | |
| 3193 | 3247 | BGFX_API_FUNC(void setInstanceDataBuffer(VertexBufferHandle _handle, uint32_t _startVertex, uint32_t _num) ) |
| 3194 | 3248 | { |
| 3249 | BGFX_CHECK_HANDLE("setInstanceDataBuffer", m_vertexBufferHandle, _handle); |
| 3195 | 3250 | const VertexBuffer& vb = m_vertexBuffers[_handle.idx]; |
| 3196 | 3251 | m_submit->setInstanceDataBuffer(_handle, _startVertex, _num, vb.m_stride); |
| 3197 | 3252 | } |
| 3198 | 3253 | |
| 3199 | 3254 | BGFX_API_FUNC(void setInstanceDataBuffer(DynamicVertexBufferHandle _handle, uint32_t _startVertex, uint32_t _num) ) |
| 3200 | 3255 | { |
| 3256 | BGFX_CHECK_HANDLE("setInstanceDataBuffer", m_dynamicVertexBufferHandle, _handle); |
| 3201 | 3257 | const DynamicVertexBuffer& dvb = m_dynamicVertexBuffers[_handle.idx]; |
| 3202 | 3258 | m_submit->setInstanceDataBuffer(dvb.m_handle |
| 3203 | 3259 | , dvb.m_startVertex + _startVertex |
| r245576 | r245577 | |
| 3208 | 3264 | |
| 3209 | 3265 | BGFX_API_FUNC(void setProgram(ProgramHandle _handle) ) |
| 3210 | 3266 | { |
| 3267 | BGFX_CHECK_HANDLE("setProgram", m_programHandle, _handle); |
| 3211 | 3268 | m_submit->setProgram(_handle); |
| 3212 | 3269 | } |
| 3213 | 3270 | |
| 3214 | 3271 | BGFX_API_FUNC(void setTexture(uint8_t _stage, UniformHandle _sampler, TextureHandle _handle, uint32_t _flags) ) |
| 3215 | 3272 | { |
| 3273 | BGFX_CHECK_HANDLE_INVALID_OK("setTexture/TextureHandle", m_textureHandle, _handle); |
| 3216 | 3274 | m_submit->setTexture(_stage, _sampler, _handle, _flags); |
| 3217 | 3275 | } |
| 3218 | 3276 | |
| 3219 | 3277 | BGFX_API_FUNC(void setTexture(uint8_t _stage, UniformHandle _sampler, FrameBufferHandle _handle, uint8_t _attachment, uint32_t _flags) ) |
| 3220 | 3278 | { |
| 3279 | BGFX_CHECK_HANDLE_INVALID_OK("setTexture/FrameBufferHandle", m_frameBufferHandle, _handle); |
| 3221 | 3280 | BX_CHECK(_attachment < g_caps.maxFBAttachments, "Frame buffer attachment index %d is invalid.", _attachment); |
| 3222 | 3281 | TextureHandle textureHandle = BGFX_INVALID_HANDLE; |
| 3223 | 3282 | if (isValid(_handle) ) |
| r245576 | r245577 | |
| 3238 | 3297 | |
| 3239 | 3298 | BGFX_API_FUNC(void setBuffer(uint8_t _stage, IndexBufferHandle _handle, Access::Enum _access) ) |
| 3240 | 3299 | { |
| 3300 | BGFX_CHECK_HANDLE("setBuffer", m_indexBufferHandle, _handle); |
| 3241 | 3301 | m_submit->setBuffer(_stage, _handle, _access); |
| 3242 | 3302 | } |
| 3243 | 3303 | |
| 3244 | 3304 | BGFX_API_FUNC(void setBuffer(uint8_t _stage, VertexBufferHandle _handle, Access::Enum _access) ) |
| 3245 | 3305 | { |
| 3306 | BGFX_CHECK_HANDLE("setBuffer", m_vertexBufferHandle, _handle); |
| 3246 | 3307 | m_submit->setBuffer(_stage, _handle, _access); |
| 3247 | 3308 | } |
| 3248 | 3309 | |
| 3249 | 3310 | BGFX_API_FUNC(void setBuffer(uint8_t _stage, DynamicIndexBufferHandle _handle, Access::Enum _access) ) |
| 3250 | 3311 | { |
| 3312 | BGFX_CHECK_HANDLE("setBuffer", m_dynamicIndexBufferHandle, _handle); |
| 3251 | 3313 | const DynamicIndexBuffer& dib = m_dynamicIndexBuffers[_handle.idx]; |
| 3252 | 3314 | m_submit->setBuffer(_stage, dib.m_handle, _access); |
| 3253 | 3315 | } |
| 3254 | 3316 | |
| 3255 | 3317 | BGFX_API_FUNC(void setBuffer(uint8_t _stage, DynamicVertexBufferHandle _handle, Access::Enum _access) ) |
| 3256 | 3318 | { |
| 3319 | BGFX_CHECK_HANDLE("setBuffer", m_dynamicVertexBufferHandle, _handle); |
| 3257 | 3320 | const DynamicVertexBuffer& dvb = m_dynamicVertexBuffers[_handle.idx]; |
| 3258 | 3321 | m_submit->setBuffer(_stage, dvb.m_handle, _access); |
| 3259 | 3322 | } |
trunk/3rdparty/bgfx/src/glcontext_glx.cpp
| r245576 | r245577 | |
| 12 | 12 | # define GLX_GLXEXT_PROTOTYPES |
| 13 | 13 | # include <glx/glxext.h> |
| 14 | 14 | |
| 15 | | namespace bgfx |
| 15 | namespace bgfx { namespace gl |
| 16 | 16 | { |
| 17 | 17 | typedef int (*PFNGLXSWAPINTERVALMESAPROC)(uint32_t _interval); |
| 18 | 18 | |
| r245576 | r245577 | |
| 55 | 55 | void GlContext::create(uint32_t _width, uint32_t _height) |
| 56 | 56 | { |
| 57 | 57 | BX_UNUSED(_width, _height); |
| 58 | | XLockDisplay( (::Display*)g_bgfxX11Display); |
| 59 | 58 | |
| 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; |
| 69 | 60 | |
| 70 | | int32_t screen = DefaultScreen( (::Display*)g_bgfxX11Display); |
| 61 | if (NULL == g_bgfxGLX) |
| 62 | { |
| 63 | XLockDisplay( (::Display*)g_bgfxX11Display); |
| 71 | 64 | |
| 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 | ); |
| 75 | 74 | |
| 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); |
| 89 | 76 | |
| 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); |
| 92 | 80 | |
| 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 | }; |
| 95 | 94 | |
| 96 | | BX_TRACE("glX num configs %d", numConfigs); |
| 95 | // Find suitable config |
| 96 | GLXFBConfig bestConfig = NULL; |
| 97 | 97 | |
| 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) |
| 102 | 104 | { |
| 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) |
| 106 | 107 | { |
| 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 | ); |
| 118 | 123 | |
| 119 | | if (value < attrsGlx[attr + 1]) |
| 120 | | { |
| 121 | | valid = false; |
| 124 | if (value < attrsGlx[attr + 1]) |
| 125 | { |
| 126 | valid = false; |
| 122 | 127 | #if !BGFX_CONFIG_DEBUG |
| 123 | | break; |
| 128 | break; |
| 124 | 129 | #endif // BGFX_CONFIG_DEBUG |
| 130 | } |
| 125 | 131 | } |
| 132 | |
| 133 | if (valid) |
| 134 | { |
| 135 | bestConfig = configs[ii]; |
| 136 | BX_TRACE("Best config %d.", ii); |
| 137 | break; |
| 138 | } |
| 126 | 139 | } |
| 127 | 140 | |
| 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; |
| 134 | 143 | } |
| 135 | 144 | |
| 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."); |
| 139 | 147 | |
| 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."); |
| 142 | 151 | |
| 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 | | |
| 147 | 152 | #if BGFX_CONFIG_RENDERER_OPENGL >= 31 |
| 148 | | glXCreateContextAttribsARB = (PFNGLXCREATECONTEXTATTRIBSARBPROC)glXGetProcAddress( (const GLubyte*)"glXCreateContextAttribsARB"); |
| 153 | glXCreateContextAttribsARB = (PFNGLXCREATECONTEXTATTRIBSARBPROC)glXGetProcAddress( (const GLubyte*)"glXCreateContextAttribsARB"); |
| 149 | 154 | |
| 150 | | if (NULL != glXCreateContextAttribsARB) |
| 151 | | { |
| 152 | | BX_TRACE("Create GL 3.1 context."); |
| 153 | | const int contextAttrs[] = |
| 155 | if (NULL != glXCreateContextAttribsARB) |
| 154 | 156 | { |
| 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 | }; |
| 160 | 165 | |
| 161 | | GLXContext context = glXCreateContextAttribsARB( (::Display*)g_bgfxX11Display, bestConfig, 0, true, contextAttrs); |
| 166 | GLXContext context = glXCreateContextAttribsARB( (::Display*)g_bgfxX11Display, bestConfig, 0, true, contextAttrs); |
| 162 | 167 | |
| 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 | } |
| 167 | 173 | } |
| 168 | | } |
| 169 | 174 | #else |
| 170 | | BX_UNUSED(bestConfig); |
| 175 | BX_UNUSED(bestConfig); |
| 171 | 176 | #endif // BGFX_CONFIG_RENDERER_OPENGL >= 31 |
| 172 | 177 | |
| 173 | | XUnlockDisplay( (::Display*)g_bgfxX11Display); |
| 178 | XUnlockDisplay( (::Display*)g_bgfxX11Display); |
| 179 | } |
| 174 | 180 | |
| 175 | 181 | import(); |
| 176 | 182 | |
| r245576 | r245577 | |
| 210 | 216 | void GlContext::destroy() |
| 211 | 217 | { |
| 212 | 218 | 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; |
| 215 | 226 | } |
| 216 | 227 | |
| 217 | 228 | void GlContext::resize(uint32_t /*_width*/, uint32_t /*_height*/, bool _vsync) |
| r245576 | r245577 | |
| 292 | 303 | # include "glimports.h" |
| 293 | 304 | } |
| 294 | 305 | |
| 295 | | } // namespace bgfx |
| 306 | } /* namespace gl */ } // namespace bgfx |
| 296 | 307 | |
| 297 | 308 | # endif // BGFX_USE_GLX |
| 298 | 309 | |
trunk/3rdparty/bgfx/src/image.cpp
| r245576 | r245577 | |
| 1235 | 1235 | #define DDS_BC5U BX_MAKEFOURCC('B', 'C', '5', 'U') |
| 1236 | 1236 | #define DDS_DX10 BX_MAKEFOURCC('D', 'X', '1', '0') |
| 1237 | 1237 | |
| 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 |
| 1253 | 1253 | |
| 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 |
| 1281 | 1281 | |
| 1282 | 1282 | #define DDSD_CAPS 0x00000001 |
| 1283 | 1283 | #define DDSD_HEIGHT 0x00000002 |
| r245576 | r245577 | |
| 1331 | 1331 | { DDS_BC4U, TextureFormat::BC4 }, |
| 1332 | 1332 | { DDS_ATI2, TextureFormat::BC5 }, |
| 1333 | 1333 | { DDS_BC5U, TextureFormat::BC5 }, |
| 1334 | | { D3DFMT_A16B16G16R16, TextureFormat::RGBA16 }, |
| 1335 | | { D3DFMT_A16B16G16R16F, TextureFormat::RGBA16F }, |
| 1334 | { DDS_A16B16G16R16, TextureFormat::RGBA16 }, |
| 1335 | { DDS_A16B16G16R16F, TextureFormat::RGBA16F }, |
| 1336 | 1336 | { DDPF_RGB|DDPF_ALPHAPIXELS, TextureFormat::BGRA8 }, |
| 1337 | 1337 | { DDPF_INDEXED, TextureFormat::R8 }, |
| 1338 | 1338 | { DDPF_LUMINANCE, TextureFormat::R8 }, |
| 1339 | 1339 | { 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 }, |
| 1354 | 1354 | }; |
| 1355 | 1355 | |
| 1356 | 1356 | static TranslateDdsFormat s_translateDxgiFormat[] = |
| 1357 | 1357 | { |
| 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 }, |
| 1365 | 1365 | |
| 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 }, |
| 1385 | 1385 | }; |
| 1386 | 1386 | |
| 1387 | 1387 | struct TranslateDdsPixelFormat |
trunk/3rdparty/bgfx/src/renderer_d3d9.cpp
| r245576 | r245577 | |
| 8 | 8 | #if BGFX_CONFIG_RENDERER_DIRECT3D9 |
| 9 | 9 | # include "renderer_d3d9.h" |
| 10 | 10 | |
| 11 | | namespace bgfx |
| 11 | namespace bgfx { namespace d3d9 |
| 12 | 12 | { |
| 13 | 13 | static wchar_t s_viewNameW[BGFX_CONFIG_MAX_VIEWS][BGFX_CONFIG_MAX_VIEW_NAME]; |
| 14 | 14 | |
| r245576 | r245577 | |
| 359 | 359 | m_adapter = D3DADAPTER_DEFAULT; |
| 360 | 360 | m_deviceType = D3DDEVTYPE_HAL; |
| 361 | 361 | |
| 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) |
| 364 | 364 | { |
| 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); |
| 367 | 367 | if (SUCCEEDED(hr) ) |
| 368 | | { |
| 368 | { |
| 369 | 369 | 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); |
| 373 | 373 | 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 |
| 378 | 378 | ); |
| 379 | 379 | |
| 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) |
| 382 | 384 | { |
| 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 | } |
| 385 | 398 | } |
| 386 | | #endif // BGFX_CONFIG_DEBUG_PERFHUD |
| 387 | 399 | } |
| 388 | 400 | } |
| 389 | 401 | |
| 390 | 402 | 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; |
| 393 | 407 | |
| 394 | 408 | uint32_t behaviorFlags[] = |
| 395 | 409 | { |
| r245576 | r245577 | |
| 1731 | 1745 | |
| 1732 | 1746 | static RendererContextD3D9* s_renderD3D9; |
| 1733 | 1747 | |
| 1734 | | RendererContextI* rendererCreateD3D9() |
| 1748 | RendererContextI* rendererCreate() |
| 1735 | 1749 | { |
| 1736 | 1750 | s_renderD3D9 = BX_NEW(g_allocator, RendererContextD3D9); |
| 1737 | 1751 | s_renderD3D9->init(); |
| 1738 | 1752 | return s_renderD3D9; |
| 1739 | 1753 | } |
| 1740 | 1754 | |
| 1741 | | void rendererDestroyD3D9() |
| 1755 | void rendererDestroy() |
| 1742 | 1756 | { |
| 1743 | 1757 | s_renderD3D9->shutdown(); |
| 1744 | 1758 | BX_DELETE(g_allocator, s_renderD3D9); |
| r245576 | r245577 | |
| 2215 | 2229 | if (NULL != _rect) |
| 2216 | 2230 | { |
| 2217 | 2231 | 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; |
| 2222 | 2236 | DX_CHECK(m_texture2d->LockRect(_lod, &lockedRect, &rect, 0) ); |
| 2223 | 2237 | } |
| 2224 | 2238 | else |
| r245576 | r245577 | |
| 2494 | 2508 | |
| 2495 | 2509 | if (convert) |
| 2496 | 2510 | { |
| 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); |
| 2498 | 2512 | imageDecodeToBgra8(temp, data, _rect.m_width, _rect.m_height, srcpitch, m_requestedFormat); |
| 2499 | 2513 | data = temp; |
| 2500 | 2514 | } |
| r245576 | r245577 | |
| 2864 | 2878 | FrameBufferHandle fbh = BGFX_INVALID_HANDLE; |
| 2865 | 2879 | uint32_t blendFactor = 0; |
| 2866 | 2880 | |
| 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 | } |
| 2869 | 2886 | PrimInfo prim = s_primInfo[primIndex]; |
| 2870 | 2887 | |
| 2871 | 2888 | bool viewHasScissor = false; |
| r245576 | r245577 | |
| 2876 | 2893 | uint32_t statsNumPrimsRendered[BX_COUNTOF(s_primInfo)] = {}; |
| 2877 | 2894 | uint32_t statsNumInstances[BX_COUNTOF(s_primInfo)] = {}; |
| 2878 | 2895 | uint32_t statsNumIndices = 0; |
| 2896 | uint32_t statsKeyType[2] = {}; |
| 2879 | 2897 | |
| 2880 | 2898 | invalidateSamplerState(); |
| 2881 | 2899 | |
| r245576 | r245577 | |
| 2884 | 2902 | for (uint32_t item = 0, numItems = _render->m_num; item < numItems; ++item) |
| 2885 | 2903 | { |
| 2886 | 2904 | const bool isCompute = key.decode(_render->m_sortKeys[item], _render->m_viewRemap); |
| 2905 | statsKeyType[isCompute]++; |
| 2887 | 2906 | |
| 2888 | 2907 | if (isCompute) |
| 2889 | 2908 | { |
| r245576 | r245577 | |
| 3414 | 3433 | ); |
| 3415 | 3434 | |
| 3416 | 3435 | 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]" |
| 3418 | 3437 | , _render->m_num |
| 3438 | , statsKeyType[0] |
| 3439 | , statsKeyType[1] |
| 3419 | 3440 | , elapsedCpuMs |
| 3420 | 3441 | ); |
| 3421 | 3442 | for (uint32_t ii = 0; ii < BX_COUNTOF(s_primName); ++ii) |
| r245576 | r245577 | |
| 3460 | 3481 | |
| 3461 | 3482 | device->EndScene(); |
| 3462 | 3483 | } |
| 3463 | | } // namespace bgfx |
| 3484 | } /* namespace d3d9 */ } // namespace bgfx |
| 3464 | 3485 | |
| 3465 | 3486 | #else |
| 3466 | 3487 | |
| 3467 | | namespace bgfx |
| 3488 | namespace bgfx { namespace d3d9 |
| 3468 | 3489 | { |
| 3469 | | RendererContextI* rendererCreateD3D9() |
| 3490 | RendererContextI* rendererCreate() |
| 3470 | 3491 | { |
| 3471 | 3492 | return NULL; |
| 3472 | 3493 | } |
| 3473 | 3494 | |
| 3474 | | void rendererDestroyD3D9() |
| 3495 | void rendererDestroy() |
| 3475 | 3496 | { |
| 3476 | 3497 | } |
| 3477 | | } // namespace bgfx |
| 3498 | } /* namespace d3d9 */ } // namespace bgfx |
| 3478 | 3499 | |
| 3479 | 3500 | #endif // BGFX_CONFIG_RENDERER_DIRECT3D9 |
trunk/3rdparty/bgfx/src/renderer_gl.cpp
| r245576 | r245577 | |
| 10 | 10 | # include <bx/timer.h> |
| 11 | 11 | # include <bx/uint32_t.h> |
| 12 | 12 | |
| 13 | | namespace bgfx |
| 13 | namespace bgfx { namespace gl |
| 14 | 14 | { |
| 15 | 15 | static char s_viewName[BGFX_CONFIG_MAX_VIEWS][BGFX_CONFIG_MAX_VIEW_NAME]; |
| 16 | 16 | |
| r245576 | r245577 | |
| 237 | 237 | }; |
| 238 | 238 | BX_STATIC_ASSERT(TextureFormat::Count == BX_COUNTOF(s_textureFormat) ); |
| 239 | 239 | |
| 240 | static bool s_textureFilter[TextureFormat::Count+1]; |
| 241 | |
| 240 | 242 | static GLenum s_rboFormat[] = |
| 241 | 243 | { |
| 242 | 244 | GL_ZERO, // BC1 |
| r245576 | r245577 | |
| 358 | 360 | ANGLE_texture_compression_dxt1, |
| 359 | 361 | ANGLE_texture_compression_dxt3, |
| 360 | 362 | ANGLE_texture_compression_dxt5, |
| 363 | ANGLE_timer_query, |
| 361 | 364 | ANGLE_translated_shader_source, |
| 362 | 365 | |
| 363 | 366 | APPLE_texture_format_BGRA8888, |
| r245576 | r245577 | |
| 417 | 420 | EXT_blend_color, |
| 418 | 421 | EXT_blend_minmax, |
| 419 | 422 | EXT_blend_subtract, |
| 423 | EXT_color_buffer_half_float, |
| 424 | EXT_color_buffer_float, |
| 420 | 425 | EXT_compressed_ETC1_RGB8_sub_texture, |
| 421 | 426 | EXT_debug_label, |
| 422 | 427 | EXT_debug_marker, |
| 423 | 428 | EXT_discard_framebuffer, |
| 429 | EXT_disjoint_timer_query, |
| 424 | 430 | EXT_draw_buffers, |
| 425 | 431 | EXT_frag_depth, |
| 426 | 432 | EXT_framebuffer_blit, |
| r245576 | r245577 | |
| 491 | 497 | OES_vertex_half_float, |
| 492 | 498 | OES_vertex_type_10_10_10_2, |
| 493 | 499 | |
| 500 | WEBGL_color_buffer_float, |
| 494 | 501 | WEBGL_compressed_texture_etc1, |
| 495 | 502 | WEBGL_compressed_texture_s3tc, |
| 496 | 503 | WEBGL_compressed_texture_pvrtc, |
| 497 | 504 | WEBGL_depth_texture, |
| 505 | WEBGL_draw_buffers, |
| 498 | 506 | |
| 499 | 507 | WEBKIT_EXT_texture_filter_anisotropic, |
| 500 | 508 | WEBKIT_WEBGL_compressed_texture_s3tc, |
| r245576 | r245577 | |
| 508 | 516 | bool m_initialize; |
| 509 | 517 | }; |
| 510 | 518 | |
| 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[] = |
| 512 | 540 | { |
| 513 | 541 | { "AMD_conservative_depth", false, true }, |
| 514 | 542 | |
| r245576 | r245577 | |
| 519 | 547 | { "ANGLE_texture_compression_dxt1", false, true }, |
| 520 | 548 | { "ANGLE_texture_compression_dxt3", false, true }, |
| 521 | 549 | { "ANGLE_texture_compression_dxt5", false, true }, |
| 550 | { "ANGLE_timer_query", false, true }, |
| 522 | 551 | { "ANGLE_translated_shader_source", false, true }, |
| 523 | 552 | |
| 524 | 553 | { "APPLE_texture_format_BGRA8888", false, true }, |
| r245576 | r245577 | |
| 578 | 607 | { "EXT_blend_color", BGFX_CONFIG_RENDERER_OPENGL >= 31, true }, |
| 579 | 608 | { "EXT_blend_minmax", BGFX_CONFIG_RENDERER_OPENGL >= 14, true }, |
| 580 | 609 | { "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. |
| 581 | 612 | { "EXT_compressed_ETC1_RGB8_sub_texture", false, true }, // GLES2 extension. |
| 582 | 613 | { "EXT_debug_label", false, true }, |
| 583 | 614 | { "EXT_debug_marker", false, true }, |
| 584 | 615 | { "EXT_discard_framebuffer", false, true }, // GLES2 extension. |
| 616 | { "EXT_disjoint_timer_query", false, true }, // GLES2 extension. |
| 585 | 617 | { "EXT_draw_buffers", false, true }, // GLES2 extension. |
| 586 | 618 | { "EXT_frag_depth", false, true }, // GLES2 extension. |
| 587 | 619 | { "EXT_framebuffer_blit", BGFX_CONFIG_RENDERER_OPENGL >= 30, true }, |
| r245576 | r245577 | |
| 605 | 637 | { "EXT_texture_storage", false, true }, |
| 606 | 638 | { "EXT_texture_swizzle", false, true }, |
| 607 | 639 | { "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 }, |
| 609 | 641 | { "EXT_unpack_subimage", false, true }, |
| 610 | 642 | |
| 611 | 643 | { "GOOGLE_depth_texture", false, true }, |
| r245576 | r245577 | |
| 652 | 684 | { "OES_vertex_half_float", false, true }, |
| 653 | 685 | { "OES_vertex_type_10_10_10_2", false, true }, |
| 654 | 686 | |
| 687 | { "WEBGL_color_buffer_float", false, true }, |
| 655 | 688 | { "WEBGL_compressed_texture_etc1", false, true }, |
| 656 | 689 | { "WEBGL_compressed_texture_s3tc", false, true }, |
| 657 | 690 | { "WEBGL_compressed_texture_pvrtc", false, true }, |
| 658 | 691 | { "WEBGL_depth_texture", false, true }, |
| 692 | { "WEBGL_draw_buffers", false, true }, |
| 659 | 693 | |
| 660 | 694 | { "WEBKIT_EXT_texture_filter_anisotropic", false, true }, |
| 661 | 695 | { "WEBKIT_WEBGL_compressed_texture_s3tc", false, true }, |
| 662 | 696 | { "WEBKIT_WEBGL_depth_texture", false, true }, |
| 663 | 697 | }; |
| 698 | BX_STATIC_ASSERT(Extension::Count == BX_COUNTOF(s_extension) ); |
| 664 | 699 | |
| 665 | 700 | static const char* s_ARB_shader_texture_lod[] = |
| 666 | 701 | { |
| r245576 | r245577 | |
| 915 | 950 | return 0 == err; |
| 916 | 951 | } |
| 917 | 952 | |
| 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 | |
| 918 | 962 | struct RendererContextGL : public RendererContextI |
| 919 | 963 | { |
| 920 | 964 | RendererContextGL() |
| r245576 | r245577 | |
| 933 | 977 | , m_programBinarySupport(false) |
| 934 | 978 | , m_textureSwizzleSupport(false) |
| 935 | 979 | , m_depthTextureSupport(false) |
| 980 | , m_timerQuerySupport(false) |
| 936 | 981 | , m_flip(false) |
| 937 | 982 | , m_hash( (BX_PLATFORM_WINDOWS<<1) | BX_ARCH_64BIT) |
| 938 | 983 | , m_backBufferFbo(0) |
| r245576 | r245577 | |
| 1094 | 1139 | } |
| 1095 | 1140 | } |
| 1096 | 1141 | |
| 1142 | // Allow all texture filters. |
| 1143 | memset(s_textureFilter, true, BX_COUNTOF(s_textureFilter) ); |
| 1144 | |
| 1097 | 1145 | bool bc123Supported = 0 |
| 1098 | 1146 | || s_extension[Extension::EXT_texture_compression_s3tc ].m_supported |
| 1099 | 1147 | || s_extension[Extension::MOZ_WEBGL_compressed_texture_s3tc ].m_supported |
| r245576 | r245577 | |
| 1186 | 1234 | { |
| 1187 | 1235 | setTextureFormat(TextureFormat::RGBA16F, GL_RGBA, GL_RGBA, GL_HALF_FLOAT); |
| 1188 | 1236 | |
| 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 | |
| 1189 | 1254 | if (BX_ENABLED(BX_PLATFORM_IOS) ) |
| 1190 | 1255 | { |
| 1191 | 1256 | setTextureFormat(TextureFormat::D16, GL_DEPTH_COMPONENT, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT); |
| r245576 | r245577 | |
| 1294 | 1359 | |
| 1295 | 1360 | if (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGL) |
| 1296 | 1361 | || 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) |
| 1298 | 1364 | { |
| 1299 | 1365 | g_caps.maxFBAttachments = bx::uint32_min(glGet(GL_MAX_COLOR_ATTACHMENTS), BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS); |
| 1300 | 1366 | } |
| r245576 | r245577 | |
| 1306 | 1372 | |
| 1307 | 1373 | if (BX_ENABLED(BX_PLATFORM_NACL) ) |
| 1308 | 1374 | { |
| 1309 | | m_vaoSupport &= NULL != glGenVertexArrays |
| 1375 | m_vaoSupport &= true |
| 1376 | && NULL != glGenVertexArrays |
| 1310 | 1377 | && NULL != glDeleteVertexArrays |
| 1311 | 1378 | && NULL != glBindVertexArray |
| 1312 | 1379 | ; |
| r245576 | r245577 | |
| 1346 | 1413 | || s_extension[Extension::WEBKIT_WEBGL_depth_texture].m_supported |
| 1347 | 1414 | ; |
| 1348 | 1415 | |
| 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 | |
| 1349 | 1425 | g_caps.supported |= m_depthTextureSupport |
| 1350 | 1426 | ? BGFX_CAPS_TEXTURE_COMPARE_LEQUAL |
| 1351 | 1427 | : 0 |
| r245576 | r245577 | |
| 1455 | 1531 | glInvalidateFramebuffer = stubInvalidateFramebuffer; |
| 1456 | 1532 | } |
| 1457 | 1533 | |
| 1458 | | if (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGL) ) |
| 1534 | if (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGL) |
| 1535 | && m_timerQuerySupport) |
| 1459 | 1536 | { |
| 1460 | 1537 | m_queries.create(); |
| 1461 | 1538 | } |
| r245576 | r245577 | |
| 1485 | 1562 | |
| 1486 | 1563 | invalidateCache(); |
| 1487 | 1564 | |
| 1488 | | if (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGL) ) |
| 1565 | if (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGL) |
| 1566 | && m_timerQuerySupport) |
| 1489 | 1567 | { |
| 1490 | 1568 | m_queries.destroy(); |
| 1491 | 1569 | } |
| r245576 | r245577 | |
| 2047 | 2125 | { |
| 2048 | 2126 | sampler = m_samplerStateCache.add(_flags); |
| 2049 | 2127 | |
| 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 | ) ); |
| 2053 | 2140 | |
| 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) ); |
| 2059 | 2145 | GL_CHECK(glSamplerParameteri(sampler, GL_TEXTURE_MIN_FILTER, minFilter) ); |
| 2146 | |
| 2060 | 2147 | if (0 != (_flags & (BGFX_TEXTURE_MIN_ANISOTROPIC|BGFX_TEXTURE_MAG_ANISOTROPIC) ) |
| 2061 | 2148 | && 0.0f < m_maxAnisotropy) |
| 2062 | 2149 | { |
| r245576 | r245577 | |
| 2557 | 2644 | bool m_programBinarySupport; |
| 2558 | 2645 | bool m_textureSwizzleSupport; |
| 2559 | 2646 | bool m_depthTextureSupport; |
| 2647 | bool m_timerQuerySupport; |
| 2560 | 2648 | bool m_flip; |
| 2561 | 2649 | |
| 2562 | 2650 | uint64_t m_hash; |
| r245576 | r245577 | |
| 2579 | 2667 | |
| 2580 | 2668 | RendererContextGL* s_renderGL; |
| 2581 | 2669 | |
| 2582 | | RendererContextI* rendererCreateGL() |
| 2670 | RendererContextI* rendererCreate() |
| 2583 | 2671 | { |
| 2584 | 2672 | s_renderGL = BX_NEW(g_allocator, RendererContextGL); |
| 2585 | 2673 | s_renderGL->init(); |
| 2586 | 2674 | return s_renderGL; |
| 2587 | 2675 | } |
| 2588 | 2676 | |
| 2589 | | void rendererDestroyGL() |
| 2677 | void rendererDestroy() |
| 2590 | 2678 | { |
| 2591 | 2679 | s_renderGL->shutdown(); |
| 2592 | 2680 | BX_DELETE(g_allocator, s_renderGL); |
| r245576 | r245577 | |
| 2662 | 2750 | GLENUM(GL_RENDERBUFFER); |
| 2663 | 2751 | |
| 2664 | 2752 | GLENUM(GL_INVALID_ENUM); |
| 2753 | GLENUM(GL_INVALID_FRAMEBUFFER_OPERATION); |
| 2665 | 2754 | GLENUM(GL_INVALID_VALUE); |
| 2666 | 2755 | GLENUM(GL_INVALID_OPERATION); |
| 2667 | 2756 | GLENUM(GL_OUT_OF_MEMORY); |
| r245576 | r245577 | |
| 2861 | 2950 | m_numPredefined = 0; |
| 2862 | 2951 | m_numSamplers = 0; |
| 2863 | 2952 | |
| 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 | | |
| 2873 | 2953 | const bool piqSupported = s_extension[Extension::ARB_program_interface_query].m_supported; |
| 2874 | 2954 | |
| 2875 | 2955 | BX_TRACE("Uniforms (%d):", activeUniforms); |
| 2876 | 2956 | for (int32_t ii = 0; ii < activeUniforms; ++ii) |
| 2877 | 2957 | { |
| 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 | |
| 2878 | 2967 | GLenum gltype; |
| 2879 | 2968 | GLint num; |
| 2880 | 2969 | GLint loc; |
| r245576 | r245577 | |
| 3202 | 3291 | BX_CHECK(0 != m_id, "Failed to generate texture id."); |
| 3203 | 3292 | GL_CHECK(glBindTexture(_target, m_id) ); |
| 3204 | 3293 | |
| 3205 | | setSamplerState(_flags); |
| 3206 | | |
| 3207 | 3294 | const TextureFormatInfo& tfi = s_textureFormat[_format]; |
| 3208 | | m_fmt = tfi.m_fmt; |
| 3295 | m_fmt = tfi.m_fmt; |
| 3209 | 3296 | m_type = tfi.m_type; |
| 3210 | 3297 | |
| 3211 | 3298 | const bool compressed = isCompressed(TextureFormat::Enum(_format) ); |
| r245576 | r245577 | |
| 3214 | 3301 | if (decompress) |
| 3215 | 3302 | { |
| 3216 | 3303 | 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; |
| 3220 | 3307 | } |
| 3221 | 3308 | |
| 3309 | setSamplerState(_flags); |
| 3310 | |
| 3222 | 3311 | if (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGL) |
| 3223 | 3312 | && TextureFormat::BGRA8 == m_textureFormat |
| 3224 | 3313 | && GL_RGBA == m_fmt |
| r245576 | r245577 | |
| 3583 | 3672 | |
| 3584 | 3673 | void TextureGL::setSamplerState(uint32_t _flags) |
| 3585 | 3674 | { |
| 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 | |
| 3586 | 3691 | const uint32_t flags = (0 != (BGFX_SAMPLER_DEFAULT_FLAGS & _flags) ? m_flags : _flags) & BGFX_TEXTURE_SAMPLER_BITS_MASK; |
| 3587 | 3692 | if (flags != m_currentFlags) |
| 3588 | 3693 | { |
| r245576 | r245577 | |
| 3603 | 3708 | GL_CHECK(glTexParameteri(target, GL_TEXTURE_WRAP_R, s_textureAddress[(flags&BGFX_TEXTURE_W_MASK)>>BGFX_TEXTURE_W_SHIFT]) ); |
| 3604 | 3709 | } |
| 3605 | 3710 | |
| 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) ); |
| 3611 | 3715 | GL_CHECK(glTexParameteri(target, GL_TEXTURE_MIN_FILTER, minFilter) ); |
| 3612 | 3716 | if (0 != (flags & (BGFX_TEXTURE_MIN_ANISOTROPIC|BGFX_TEXTURE_MAG_ANISOTROPIC) ) |
| 3613 | 3717 | && 0.0f < s_renderGL->m_maxAnisotropy) |
| r245576 | r245577 | |
| 3794 | 3898 | |
| 3795 | 3899 | if (usesFragData) |
| 3796 | 3900 | { |
| 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 | ); |
| 3798 | 3905 | writeString(&writer |
| 3799 | 3906 | , "#extension GL_EXT_draw_buffers : enable\n" |
| 3800 | 3907 | ); |
| r245576 | r245577 | |
| 3995 | 4102 | { |
| 3996 | 4103 | for (uint32_t ii = 0, num = g_caps.maxFBAttachments; ii < num; ++ii) |
| 3997 | 4104 | { |
| 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); |
| 4001 | 4108 | } |
| 4002 | 4109 | |
| 4003 | 4110 | BGFX_FATAL(0 != fragData, Fatal::InvalidShader, "Unable to find and patch gl_FragData!"); |
| r245576 | r245577 | |
| 4197 | 4304 | GL_CHECK(glGenFramebuffers(1, &m_fbo[1]) ); |
| 4198 | 4305 | GL_CHECK(glBindFramebuffer(GL_FRAMEBUFFER, m_fbo[1]) ); |
| 4199 | 4306 | |
| 4200 | | for (uint32_t ii = 0, colorIdx = 0; ii < _num; ++ii) |
| 4307 | colorIdx = 0; |
| 4308 | for (uint32_t ii = 0; ii < _num; ++ii) |
| 4201 | 4309 | { |
| 4202 | 4310 | TextureHandle handle = _handles[ii]; |
| 4203 | 4311 | if (isValid(handle) ) |
| r245576 | r245577 | |
| 4345 | 4453 | int64_t captureElapsed = 0; |
| 4346 | 4454 | |
| 4347 | 4455 | 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) |
| 4349 | 4458 | { |
| 4350 | 4459 | m_queries.begin(0, GL_TIME_ELAPSED); |
| 4351 | 4460 | } |
| r245576 | r245577 | |
| 4390 | 4499 | ; |
| 4391 | 4500 | uint32_t blendFactor = 0; |
| 4392 | 4501 | |
| 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 | } |
| 4395 | 4507 | PrimInfo prim = s_primInfo[primIndex]; |
| 4396 | 4508 | |
| 4397 | 4509 | uint32_t baseVertex = 0; |
| r245576 | r245577 | |
| 4410 | 4522 | uint32_t statsNumPrimsRendered[BX_COUNTOF(s_primInfo)] = {}; |
| 4411 | 4523 | uint32_t statsNumInstances[BX_COUNTOF(s_primInfo)] = {}; |
| 4412 | 4524 | uint32_t statsNumIndices = 0; |
| 4525 | uint32_t statsKeyType[2] = {}; |
| 4413 | 4526 | |
| 4414 | 4527 | if (0 == (_render->m_debug&BGFX_DEBUG_IFH) ) |
| 4415 | 4528 | { |
| r245576 | r245577 | |
| 4424 | 4537 | for (int32_t item = 0, restartItem = numItems; item < numItems || restartItem < numItems;) |
| 4425 | 4538 | { |
| 4426 | 4539 | const bool isCompute = key.decode(_render->m_sortKeys[item], _render->m_viewRemap); |
| 4540 | statsKeyType[isCompute]++; |
| 4541 | |
| 4427 | 4542 | const bool viewChanged = 0 |
| 4428 | 4543 | || key.m_view != view |
| 4429 | 4544 | || item == numItems |
| r245576 | r245577 | |
| 4783 | 4898 | && blendIndependentSupported |
| 4784 | 4899 | ; |
| 4785 | 4900 | |
| 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; |
| 4788 | 4906 | |
| 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; |
| 4793 | 4910 | |
| 4794 | | const uint32_t equRGB = (equation )&0x7; |
| 4795 | | const uint32_t equA = (equation>>3)&0x7; |
| 4796 | | |
| 4797 | 4911 | const uint32_t numRt = getNumRt(); |
| 4798 | 4912 | |
| 4799 | 4913 | if (!BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGL) |
| r245576 | r245577 | |
| 4974 | 5088 | currentVao = id; |
| 4975 | 5089 | GL_CHECK(glBindVertexArray(id) ); |
| 4976 | 5090 | |
| 4977 | | ProgramGL& program = m_program[programIdx]; |
| 4978 | 5091 | program.add(hash); |
| 4979 | 5092 | |
| 4980 | 5093 | if (isValid(draw.m_vertexBuffer) ) |
| r245576 | r245577 | |
| 5072 | 5185 | baseVertex = draw.m_startVertex; |
| 5073 | 5186 | const VertexBufferGL& vb = m_vertexBuffers[draw.m_vertexBuffer.idx]; |
| 5074 | 5187 | uint16_t decl = !isValid(vb.m_decl) ? draw.m_vertexDecl.idx : vb.m_decl.idx; |
| 5075 | | const ProgramGL& program = m_program[programIdx]; |
| 5076 | 5188 | program.bindAttributes(m_vertexDecls[decl], draw.m_startVertex); |
| 5077 | 5189 | |
| 5078 | 5190 | if (isValid(draw.m_instanceDataBuffer) ) |
| r245576 | r245577 | |
| 5178 | 5290 | if (_render->m_debug & (BGFX_DEBUG_IFH|BGFX_DEBUG_STATS) ) |
| 5179 | 5291 | { |
| 5180 | 5292 | 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 | } |
| 5186 | 5301 | |
| 5187 | 5302 | TextVideoMem& tvm = m_textVideoMem; |
| 5188 | 5303 | |
| r245576 | r245577 | |
| 5225 | 5340 | ); |
| 5226 | 5341 | |
| 5227 | 5342 | 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]" |
| 5229 | 5344 | , _render->m_num |
| 5345 | , statsKeyType[0] |
| 5346 | , statsKeyType[1] |
| 5230 | 5347 | , elapsedCpuMs |
| 5231 | 5348 | , elapsedCpuMs > elapsedGpuMs ? '>' : '<' |
| 5232 | 5349 | , elapsedGpuMs |
| 5233 | 5350 | ); |
| 5234 | 5351 | for (uint32_t ii = 0; ii < BX_COUNTOF(s_primInfo); ++ii) |
| 5235 | 5352 | { |
| 5236 | | tvm.printf(10, pos++, 0x8e, " %8s: %7d (#inst: %5d), submitted: %7d" |
| 5353 | tvm.printf(10, pos++, 0x8e, " %9s: %7d (#inst: %5d), submitted: %7d" |
| 5237 | 5354 | , s_primName[ii] |
| 5238 | 5355 | , statsNumPrimsRendered[ii] |
| 5239 | 5356 | , statsNumInstances[ii] |
| r245576 | r245577 | |
| 5246 | 5363 | tvm.printf(tvm.m_width-27, 0, 0x1f, " [F11 - RenderDoc capture] "); |
| 5247 | 5364 | } |
| 5248 | 5365 | |
| 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); |
| 5252 | 5369 | |
| 5253 | 5370 | pos++; |
| 5254 | 5371 | tvm.printf(10, pos++, 0x8e, " State cache: "); |
| r245576 | r245577 | |
| 5354 | 5471 | |
| 5355 | 5472 | GL_CHECK(glFrameTerminatorGREMEDY() ); |
| 5356 | 5473 | } |
| 5357 | | } // namespace bgfx |
| 5474 | } } // namespace bgfx |
| 5358 | 5475 | |
| 5359 | 5476 | #else |
| 5360 | 5477 | |
| 5361 | | namespace bgfx |
| 5478 | namespace bgfx { namespace gl |
| 5362 | 5479 | { |
| 5363 | | RendererContextI* rendererCreateGL() |
| 5480 | RendererContextI* rendererCreate() |
| 5364 | 5481 | { |
| 5365 | 5482 | return NULL; |
| 5366 | 5483 | } |
| 5367 | 5484 | |
| 5368 | | void rendererDestroyGL() |
| 5485 | void rendererDestroy() |
| 5369 | 5486 | { |
| 5370 | 5487 | } |
| 5371 | | } // namespace bgfx |
| 5488 | } /* namespace gl */ } // namespace bgfx |
| 5372 | 5489 | |
| 5373 | 5490 | #endif // (BGFX_CONFIG_RENDERER_OPENGLES || BGFX_CONFIG_RENDERER_OPENGL) |
| 5374 | 5491 | |
trunk/3rdparty/bx/scripts/toolchain.lua
| r245576 | r245577 | |
| 19 | 19 | { "asmjs", "Emscripten/asm.js" }, |
| 20 | 20 | { "freebsd", "FreeBSD" }, |
| 21 | 21 | { "linux-gcc", "Linux (GCC compiler)" }, |
| 22 | { "linux-gcc-5", "Linux (GCC-5 compiler)" }, |
| 22 | 23 | { "linux-clang", "Linux (Clang compiler)" }, |
| 23 | 24 | { "ios-arm", "iOS - ARM" }, |
| 24 | 25 | { "ios-simulator", "iOS - Simulator" }, |
| r245576 | r245577 | |
| 40 | 41 | allowed = { |
| 41 | 42 | { "vs2012-clang", "Clang 3.6" }, |
| 42 | 43 | { "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" }, |
| 45 | 47 | { "winphone8", "Windows Phone 8.0" }, |
| 46 | 48 | { "winphone81", "Windows Phone 8.1" }, |
| 47 | 49 | }, |
| r245576 | r245577 | |
| 110 | 112 | premake.gcc.cxx = "$(ANDROID_NDK_ARM)/bin/arm-linux-androideabi-g++" |
| 111 | 113 | premake.gcc.ar = "$(ANDROID_NDK_ARM)/bin/arm-linux-androideabi-ar" |
| 112 | 114 | location (path.join(_buildDir, "projects", _ACTION .. "-android-arm")) |
| 113 | | end |
| 114 | 115 | |
| 115 | | if "android-mips" == _OPTIONS["gcc"] then |
| 116 | elseif "android-mips" == _OPTIONS["gcc"] then |
| 116 | 117 | |
| 117 | 118 | if not os.getenv("ANDROID_NDK_MIPS") or not os.getenv("ANDROID_NDK_ROOT") then |
| 118 | 119 | print("Set ANDROID_NDK_MIPS and ANDROID_NDK_ROOT envrionment variables.") |
| r245576 | r245577 | |
| 122 | 123 | premake.gcc.cxx = "$(ANDROID_NDK_MIPS)/bin/mipsel-linux-android-g++" |
| 123 | 124 | premake.gcc.ar = "$(ANDROID_NDK_MIPS)/bin/mipsel-linux-android-ar" |
| 124 | 125 | location (path.join(_buildDir, "projects", _ACTION .. "-android-mips")) |
| 125 | | end |
| 126 | 126 | |
| 127 | | if "android-x86" == _OPTIONS["gcc"] then |
| 127 | elseif "android-x86" == _OPTIONS["gcc"] then |
| 128 | 128 | |
| 129 | 129 | if not os.getenv("ANDROID_NDK_X86") or not os.getenv("ANDROID_NDK_ROOT") then |
| 130 | 130 | print("Set ANDROID_NDK_X86 and ANDROID_NDK_ROOT envrionment variables.") |
| r245576 | r245577 | |
| 134 | 134 | premake.gcc.cxx = "$(ANDROID_NDK_X86)/bin/i686-linux-android-g++" |
| 135 | 135 | premake.gcc.ar = "$(ANDROID_NDK_X86)/bin/i686-linux-android-ar" |
| 136 | 136 | location (path.join(_buildDir, "projects", _ACTION .. "-android-x86")) |
| 137 | | end |
| 138 | 137 | |
| 139 | | if "asmjs" == _OPTIONS["gcc"] then |
| 138 | elseif "asmjs" == _OPTIONS["gcc"] then |
| 140 | 139 | |
| 141 | 140 | if not os.getenv("EMSCRIPTEN") then |
| 142 | 141 | print("Set EMSCRIPTEN enviroment variables.") |
| r245576 | r245577 | |
| 147 | 146 | premake.gcc.ar = "$(EMSCRIPTEN)/emar" |
| 148 | 147 | premake.gcc.llvm = true |
| 149 | 148 | location (path.join(_buildDir, "projects", _ACTION .. "-asmjs")) |
| 150 | | end |
| 151 | 149 | |
| 152 | | if "freebsd" == _OPTIONS["gcc"] then |
| 150 | elseif "freebsd" == _OPTIONS["gcc"] then |
| 153 | 151 | location (path.join(_buildDir, "projects", _ACTION .. "-freebsd")) |
| 154 | | end |
| 155 | 152 | |
| 156 | | if "ios-arm" == _OPTIONS["gcc"] then |
| 153 | elseif "ios-arm" == _OPTIONS["gcc"] then |
| 157 | 154 | premake.gcc.cc = "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang" |
| 158 | 155 | premake.gcc.cxx = "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++" |
| 159 | 156 | premake.gcc.ar = "ar" |
| 160 | 157 | location (path.join(_buildDir, "projects", _ACTION .. "-ios-arm")) |
| 161 | | end |
| 162 | 158 | |
| 163 | | if "ios-simulator" == _OPTIONS["gcc"] then |
| 159 | elseif "ios-simulator" == _OPTIONS["gcc"] then |
| 164 | 160 | premake.gcc.cc = "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang" |
| 165 | 161 | premake.gcc.cxx = "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++" |
| 166 | 162 | premake.gcc.ar = "ar" |
| 167 | 163 | location (path.join(_buildDir, "projects", _ACTION .. "-ios-simulator")) |
| 168 | | end |
| 169 | 164 | |
| 170 | | if "linux-gcc" == _OPTIONS["gcc"] then |
| 165 | elseif "linux-gcc" == _OPTIONS["gcc"] then |
| 171 | 166 | location (path.join(_buildDir, "projects", _ACTION .. "-linux")) |
| 172 | | end |
| 173 | 167 | |
| 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 |
| 175 | 175 | premake.gcc.cc = "clang" |
| 176 | 176 | premake.gcc.cxx = "clang++" |
| 177 | 177 | premake.gcc.ar = "ar" |
| 178 | 178 | location (path.join(_buildDir, "projects", _ACTION .. "-linux-clang")) |
| 179 | | end |
| 180 | 179 | |
| 181 | | if "mingw-gcc" == _OPTIONS["gcc"] then |
| 180 | elseif "mingw-gcc" == _OPTIONS["gcc"] then |
| 182 | 181 | premake.gcc.cc = "$(MINGW)/bin/x86_64-w64-mingw32-gcc" |
| 183 | 182 | premake.gcc.cxx = "$(MINGW)/bin/x86_64-w64-mingw32-g++" |
| 184 | 183 | premake.gcc.ar = "$(MINGW)/bin/ar" |
| 185 | 184 | location (path.join(_buildDir, "projects", _ACTION .. "-mingw-gcc")) |
| 186 | | end |
| 187 | 185 | |
| 188 | | if "mingw-clang" == _OPTIONS["gcc"] then |
| 186 | elseif "mingw-clang" == _OPTIONS["gcc"] then |
| 189 | 187 | premake.gcc.cc = "$(CLANG)/bin/clang" |
| 190 | 188 | premake.gcc.cxx = "$(CLANG)/bin/clang++" |
| 191 | 189 | premake.gcc.ar = "$(MINGW)/bin/ar" |
| 192 | 190 | -- premake.gcc.ar = "$(CLANG)/bin/llvm-ar" |
| 193 | 191 | -- premake.gcc.llvm = true |
| 194 | 192 | location (path.join(_buildDir, "projects", _ACTION .. "-mingw-clang")) |
| 195 | | end |
| 196 | 193 | |
| 197 | | if "nacl" == _OPTIONS["gcc"] then |
| 194 | elseif "nacl" == _OPTIONS["gcc"] then |
| 198 | 195 | |
| 199 | 196 | if not os.getenv("NACL_SDK_ROOT") then |
| 200 | 197 | print("Set NACL_SDK_ROOT enviroment variables.") |
| r245576 | r245577 | |
| 211 | 208 | premake.gcc.cxx = naclToolchain .. "g++" |
| 212 | 209 | premake.gcc.ar = naclToolchain .. "ar" |
| 213 | 210 | location (path.join(_buildDir, "projects", _ACTION .. "-nacl")) |
| 214 | | end |
| 215 | 211 | |
| 216 | | if "nacl-arm" == _OPTIONS["gcc"] then |
| 212 | elseif "nacl-arm" == _OPTIONS["gcc"] then |
| 217 | 213 | |
| 218 | 214 | if not os.getenv("NACL_SDK_ROOT") then |
| 219 | 215 | print("Set NACL_SDK_ROOT enviroment variables.") |
| r245576 | r245577 | |
| 230 | 226 | premake.gcc.cxx = naclToolchain .. "g++" |
| 231 | 227 | premake.gcc.ar = naclToolchain .. "ar" |
| 232 | 228 | location (path.join(_buildDir, "projects", _ACTION .. "-nacl-arm")) |
| 233 | | end |
| 234 | 229 | |
| 235 | | if "osx" == _OPTIONS["gcc"] then |
| 230 | elseif "osx" == _OPTIONS["gcc"] then |
| 231 | |
| 236 | 232 | if os.is("linux") then |
| 237 | 233 | local osxToolchain = "x86_64-apple-darwin13-" |
| 238 | 234 | premake.gcc.cc = osxToolchain .. "clang" |
| r245576 | r245577 | |
| 240 | 236 | premake.gcc.ar = osxToolchain .. "ar" |
| 241 | 237 | end |
| 242 | 238 | location (path.join(_buildDir, "projects", _ACTION .. "-osx")) |
| 243 | | end |
| 244 | 239 | |
| 245 | | if "pnacl" == _OPTIONS["gcc"] then |
| 240 | elseif "pnacl" == _OPTIONS["gcc"] then |
| 246 | 241 | |
| 247 | 242 | if not os.getenv("NACL_SDK_ROOT") then |
| 248 | 243 | print("Set NACL_SDK_ROOT enviroment variables.") |
| r245576 | r245577 | |
| 259 | 254 | premake.gcc.cxx = naclToolchain .. "clang++" |
| 260 | 255 | premake.gcc.ar = naclToolchain .. "ar" |
| 261 | 256 | location (path.join(_buildDir, "projects", _ACTION .. "-pnacl")) |
| 262 | | end |
| 263 | 257 | |
| 264 | | if "qnx-arm" == _OPTIONS["gcc"] then |
| 258 | elseif "qnx-arm" == _OPTIONS["gcc"] then |
| 265 | 259 | |
| 266 | 260 | if not os.getenv("QNX_HOST") then |
| 267 | 261 | print("Set QNX_HOST enviroment variables.") |
| r245576 | r245577 | |
| 271 | 265 | premake.gcc.cxx = "$(QNX_HOST)/usr/bin/arm-unknown-nto-qnx8.0.0eabi-g++" |
| 272 | 266 | premake.gcc.ar = "$(QNX_HOST)/usr/bin/arm-unknown-nto-qnx8.0.0eabi-ar" |
| 273 | 267 | location (path.join(_buildDir, "projects", _ACTION .. "-qnx-arm")) |
| 274 | | end |
| 275 | 268 | |
| 276 | | if "rpi" == _OPTIONS["gcc"] then |
| 269 | elseif "rpi" == _OPTIONS["gcc"] then |
| 277 | 270 | location (path.join(_buildDir, "projects", _ACTION .. "-rpi")) |
| 278 | 271 | end |
| 279 | 272 | elseif _ACTION == "vs2012" or _ACTION == "vs2013" or _ACTION == "vs2015" then |
| r245576 | r245577 | |
| 281 | 274 | if (_ACTION .. "-clang") == _OPTIONS["vs"] then |
| 282 | 275 | premake.vstudio.toolset = ("LLVM-" .. _ACTION) |
| 283 | 276 | location (path.join(_buildDir, "projects", _ACTION .. "-clang")) |
| 284 | | end |
| 285 | 277 | |
| 286 | | if "winphone8" == _OPTIONS["vs"] then |
| 278 | elseif "winphone8" == _OPTIONS["vs"] then |
| 287 | 279 | premake.vstudio.toolset = "v110_wp80" |
| 288 | 280 | location (path.join(_buildDir, "projects", _ACTION .. "-winphone8")) |
| 289 | | end |
| 290 | 281 | |
| 291 | | if "winphone81" == _OPTIONS["vs"] then |
| 282 | elseif "winphone81" == _OPTIONS["vs"] then |
| 292 | 283 | premake.vstudio.toolset = "v120_wp81" |
| 293 | 284 | platforms { "ARM" } |
| 294 | 285 | location (path.join(_buildDir, "projects", _ACTION .. "-winphone81")) |
| 295 | | end |
| 296 | 286 | |
| 297 | | if ("vs2012-xp") == _OPTIONS["vs"] then |
| 287 | elseif ("vs2012-xp") == _OPTIONS["vs"] then |
| 298 | 288 | premake.vstudio.toolset = ("v110_xp") |
| 299 | 289 | location (path.join(_buildDir, "projects", _ACTION .. "-xp")) |
| 300 | | end |
| 301 | 290 | |
| 302 | | if ("vs2013-xp") == _OPTIONS["vs"] then |
| 291 | elseif ("vs2013-xp") == _OPTIONS["vs"] then |
| 303 | 292 | premake.vstudio.toolset = ("v120_xp") |
| 304 | 293 | 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")) |
| 305 | 298 | end |
| 306 | 299 | |
| 307 | 300 | elseif _ACTION == "xcode4" then |
| r245576 | r245577 | |
| 309 | 302 | if "osx" == _OPTIONS["xcode"] then |
| 310 | 303 | premake.xcode.toolset = "macosx" |
| 311 | 304 | location (path.join(_buildDir, "projects", _ACTION .. "-osx")) |
| 312 | | end |
| 313 | | if "ios" == _OPTIONS["xcode"] then |
| 305 | |
| 306 | elseif "ios" == _OPTIONS["xcode"] then |
| 314 | 307 | premake.xcode.toolset = "iphoneos" |
| 315 | 308 | location (path.join(_buildDir, "projects", _ACTION .. "-ios")) |
| 316 | 309 | end |
| r245576 | r245577 | |
| 479 | 472 | } |
| 480 | 473 | buildoptions { "-m64" } |
| 481 | 474 | |
| 482 | | configuration { "linux-gcc and not linux-clang" } |
| 475 | configuration { "linux-clang" } |
| 476 | |
| 477 | configuration { "linux-gcc-5" } |
| 483 | 478 | 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 { |
| 484 | 492 | "-mfpmath=sse", -- force SSE to get 32-bit and 64-bit builds deterministic. |
| 485 | 493 | } |
| 486 | 494 | |
| 487 | | configuration { "linux-clang" } |
| 488 | | |
| 489 | 495 | configuration { "linux-*" } |
| 490 | 496 | buildoptions { |
| 491 | 497 | "-msse2", |
| r245576 | r245577 | |
| 494 | 500 | } |
| 495 | 501 | buildoptions_cpp { |
| 496 | 502 | "-std=c++0x", |
| 497 | | } |
| 503 | } |
| 498 | 504 | links { |
| 499 | 505 | "rt", |
| 500 | 506 | "dl", |
| r245576 | r245577 | |
| 503 | 509 | "-Wl,--gc-sections", |
| 504 | 510 | } |
| 505 | 511 | |
| 506 | | configuration { "linux-gcc", "x32" } |
| 512 | configuration { "linux-g*", "x32" } |
| 507 | 513 | targetdir (path.join(_buildDir, "linux32_gcc/bin")) |
| 508 | 514 | objdir (path.join(_buildDir, "linux32_gcc/obj")) |
| 509 | 515 | libdirs { path.join(_libDir, "lib/linux32_gcc") } |
| r245576 | r245577 | |
| 511 | 517 | "-m32", |
| 512 | 518 | } |
| 513 | 519 | |
| 514 | | configuration { "linux-gcc", "x64" } |
| 520 | configuration { "linux-g*", "x64" } |
| 515 | 521 | targetdir (path.join(_buildDir, "linux64_gcc/bin")) |
| 516 | 522 | objdir (path.join(_buildDir, "linux64_gcc/obj")) |
| 517 | 523 | libdirs { path.join(_libDir, "lib/linux64_gcc") } |
| r245576 | r245577 | |
| 558 | 564 | } |
| 559 | 565 | buildoptions { |
| 560 | 566 | "-fPIC", |
| 561 | | "-std=c++0x", |
| 562 | 567 | "-no-canonical-prefixes", |
| 563 | 568 | "-Wa,--noexecstack", |
| 564 | 569 | "-fstack-protector", |
| r245576 | r245577 | |
| 567 | 572 | "-Wunused-value", |
| 568 | 573 | "-Wundef", |
| 569 | 574 | } |
| 575 | buildoptions_cpp { |
| 576 | "-std=c++0x", |
| 577 | } |
| 570 | 578 | linkoptions { |
| 571 | 579 | "-no-canonical-prefixes", |
| 572 | 580 | "-Wl,--no-undefined", |
| r245576 | r245577 | |
| 670 | 678 | |
| 671 | 679 | configuration { "nacl or nacl-arm or pnacl" } |
| 672 | 680 | buildoptions { |
| 673 | | "-std=c++0x", |
| 674 | 681 | "-U__STRICT_ANSI__", -- strcasecmp, setenv, unsetenv,... |
| 675 | 682 | "-fno-stack-protector", |
| 676 | 683 | "-fdiagnostics-show-option", |
| r245576 | r245577 | |
| 679 | 686 | "-Wunused-value", |
| 680 | 687 | "-Wundef", |
| 681 | 688 | } |
| 689 | buildoptions_cpp { |
| 690 | "-std=c++0x", |
| 691 | } |
| 682 | 692 | includedirs { |
| 683 | 693 | "$(NACL_SDK_ROOT)/include", |
| 684 | 694 | path.join(bxDir, "include/compat/nacl"), |
| r245576 | r245577 | |
| 756 | 766 | configuration { "osx", "x32" } |
| 757 | 767 | targetdir (path.join(_buildDir, "osx32_clang/bin")) |
| 758 | 768 | objdir (path.join(_buildDir, "osx32_clang/obj")) |
| 759 | | libdirs { path.join(_libDir, "lib/osx32_clang") } |
| 769 | --libdirs { path.join(_libDir, "lib/osx32_clang") } |
| 760 | 770 | buildoptions { |
| 761 | 771 | "-m32", |
| 762 | 772 | } |
| r245576 | r245577 | |
| 764 | 774 | configuration { "osx", "x64" } |
| 765 | 775 | targetdir (path.join(_buildDir, "osx64_clang/bin")) |
| 766 | 776 | objdir (path.join(_buildDir, "osx64_clang/obj")) |
| 767 | | libdirs { path.join(_libDir, "lib/osx64_clang") } |
| 777 | --libdirs { path.join(_libDir, "lib/osx64_clang") } |
| 768 | 778 | buildoptions { |
| 769 | 779 | "-m64", |
| 770 | 780 | } |
| r245576 | r245577 | |
| 831 | 841 | libdirs { path.join(_libDir, "lib/qnx-arm") } |
| 832 | 842 | -- includedirs { path.join(bxDir, "include/compat/qnx") } |
| 833 | 843 | buildoptions { |
| 834 | | "-std=c++0x", |
| 835 | 844 | "-Wno-psabi", -- note: the mangling of 'va_list' has changed in GCC 4.4.0 |
| 836 | 845 | "-Wunused-value", |
| 837 | 846 | "-Wundef", |
| 838 | 847 | } |
| 848 | buildoptions_cpp { |
| 849 | "-std=c++0x", |
| 850 | } |
| 839 | 851 | |
| 840 | 852 | configuration { "rpi" } |
| 841 | 853 | targetdir (path.join(_buildDir, "rpi/bin")) |