Previous 199869 Revisions Next

r36797 Monday 30th March, 2015 at 12:36:33 UTC by Miodrag Milanović
Updated to latest 3rdparty (nw)
[3rdparty/bgfx/3rdparty/sdf]sdf.h
[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/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]nanovg.cpp
[3rdparty/bgfx/examples/21-deferred]deferred.cpp
[3rdparty/bgfx/examples/23-vectordisplay]main.cpp vectordisplay.cpp
[3rdparty/bgfx/examples/25-c99]helloworld.c
[3rdparty/bgfx/examples/common]bounds.cpp
[3rdparty/bgfx/examples/common/entry]entry.cpp entry_p.h
[3rdparty/bgfx/include]bgfx.c99.h bgfx.h bgfxdefines.h
[3rdparty/bgfx/scripts]genie.lua
[3rdparty/bgfx/src]bgfx.cpp bgfx_p.h ovr.cpp ovr.h renderer_d3d11.cpp renderer_d3d9.cpp renderer_gl.cpp renderer_gl.h
[3rdparty/bx/include/bx]platform.h radixsort.h
[3rdparty/bx/scripts]toolchain.lua
[3rdparty/bx/tools/bin/darwin]genie
[3rdparty/bx/tools/bin/linux]genie
[3rdparty/bx/tools/bin/windows]genie.exe
[3rdparty/genie]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/base]api.lua bake.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*

trunk/3rdparty/bgfx/3rdparty/sdf/sdf.h
r245308r245309
9292      } else if (a < (1.0-a1)) { // a1 <= a <= 1-a1
9393         df = (0.5f-a)*gx;
9494      } else { // 1-a1 < a <= 1
95         df = -0.5f*(gx + gy) + sqrt(2.0f*gx*gy*(1.0f-a));
95         df = -0.5f*(gx + gy) + sqrtf(2.0f*gx*gy*(1.0f-a));
9696      }
9797   }   
9898   return df;
trunk/3rdparty/bgfx/examples/02-metaballs/metaballs.cpp
r245308r245309
592592      float sphere[numSpheres][4];
593593      for (uint32_t ii = 0; ii < numSpheres; ++ii)
594594      {
595         sphere[ii][0] = sin(time*(ii*0.21f)+ii*0.37f) * (DIMS * 0.5f - 8.0f);
596         sphere[ii][1] = sin(time*(ii*0.37f)+ii*0.67f) * (DIMS * 0.5f - 8.0f);
597         sphere[ii][2] = cos(time*(ii*0.11f)+ii*0.13f) * (DIMS * 0.5f - 8.0f);
598         sphere[ii][3] = 1.0f/(2.0f + (sin(time*(ii*0.13f) )*0.5f+0.5f)*2.0f);
595         sphere[ii][0] = sinf(time*(ii*0.21f)+ii*0.37f) * (DIMS * 0.5f - 8.0f);
596         sphere[ii][1] = sinf(time*(ii*0.37f)+ii*0.67f) * (DIMS * 0.5f - 8.0f);
597         sphere[ii][2] = cosf(time*(ii*0.11f)+ii*0.13f) * (DIMS * 0.5f - 8.0f);
598         sphere[ii][3] = 1.0f/(2.0f + (sinf(time*(ii*0.13f) )*0.5f+0.5f)*2.0f);
599599      }
600600
601601      profUpdate = bx::getHPCounter();
trunk/3rdparty/bgfx/examples/05-instancing/instancing.cpp
r245308r245309
182182                  mtx[14] = 0.0f;
183183
184184                  float* color = (float*)&data[64];
185                  color[0] = sin(time+float(xx)/11.0f)*0.5f+0.5f;
186                  color[1] = cos(time+float(yy)/11.0f)*0.5f+0.5f;
187                  color[2] = sin(time*3.0f)*0.5f+0.5f;
185                  color[0] = sinf(time+float(xx)/11.0f)*0.5f+0.5f;
186                  color[1] = cosf(time+float(yy)/11.0f)*0.5f+0.5f;
187                  color[2] = sinf(time*3.0f)*0.5f+0.5f;
188188                  color[3] = 1.0f;
189189
190190                  data += instanceStride;
trunk/3rdparty/bgfx/examples/06-bump/bump.cpp
r245308r245309
192192
193193      float at[3]  = { 0.0f, 0.0f,  0.0f };
194194      float eye[3] = { 0.0f, 0.0f, -7.0f };
195     
195
196196      // Set view and projection matrix for view 0.
197197      const bgfx::HMD* hmd = bgfx::getHMD();
198198      if (NULL != hmd)
r245308r245309
227227      float lightPosRadius[4][4];
228228      for (uint32_t ii = 0; ii < numLights; ++ii)
229229      {
230         lightPosRadius[ii][0] = sin( (time*(0.1f + ii*0.17f) + ii*bx::piHalf*1.37f ) )*3.0f;
231         lightPosRadius[ii][1] = cos( (time*(0.2f + ii*0.29f) + ii*bx::piHalf*1.49f ) )*3.0f;
230         lightPosRadius[ii][0] = sinf( (time*(0.1f + ii*0.17f) + ii*bx::piHalf*1.37f ) )*3.0f;
231         lightPosRadius[ii][1] = cosf( (time*(0.2f + ii*0.29f) + ii*bx::piHalf*1.49f ) )*3.0f;
232232         lightPosRadius[ii][2] = -2.5f;
233233         lightPosRadius[ii][3] = 3.0f;
234234      }
r245308r245309
338338         }
339339      }
340340
341      // Advance to next frame. Rendering thread will be kicked to
341      // Advance to next frame. Rendering thread will be kicked to
342342      // process submitted rendering primitives.
343343      bgfx::frame();
344344   }
trunk/3rdparty/bgfx/examples/07-callback/callback.cpp
r245308r245309
372372
373373   bgfx::init(
374374        renderers[bx::getHPCounter() % numRenderers] /* randomize renderer */
375      , BGFX_PCI_ID_NONE
376      , 0
375377      , &callback  // custom callback handler
376378      , &allocator // custom allocator
377379      );
r245308r245309
442444
443445      float at[3] = { 0.0f, 0.0f, 0.0f };
444446      float eye[3] = { 0.0f, 0.0f, -35.0f };
445     
447
446448      float view[16];
447449      float proj[16];
448450      bx::mtxLookAt(view, eye, at);
r245308r245309
488490         bgfx::saveScreenShot("temp/frame150");
489491      }
490492
491      // Advance to next frame. Rendering thread will be kicked to
493      // Advance to next frame. Rendering thread will be kicked to
492494      // process submitted rendering primitives.
493495      bgfx::frame();
494496   }
trunk/3rdparty/bgfx/examples/08-update/update.cpp
r245308r245309
167167      }
168168   }
169169
170   bgfx::TextureHandle textures3d[] =
170   const bgfx::Caps* caps = bgfx::getCaps();
171   const bool texture3DSupported = !!(caps->supported & BGFX_CAPS_TEXTURE_3D);
172
173   uint32_t numTextures3d = 0;
174   bgfx::TextureHandle textures3d[3] = {};
175
176   if (texture3DSupported)
171177   {
172      bgfx::createTexture3D(32, 32, 32, 0, bgfx::TextureFormat::R8,   BGFX_TEXTURE_U_CLAMP|BGFX_TEXTURE_V_CLAMP|BGFX_TEXTURE_W_CLAMP, mem8),
173      bgfx::createTexture3D(32, 32, 32, 0, bgfx::TextureFormat::R16F, BGFX_TEXTURE_U_CLAMP|BGFX_TEXTURE_V_CLAMP|BGFX_TEXTURE_W_CLAMP, mem16f),
174      bgfx::createTexture3D(32, 32, 32, 0, bgfx::TextureFormat::R32F, BGFX_TEXTURE_U_CLAMP|BGFX_TEXTURE_V_CLAMP|BGFX_TEXTURE_W_CLAMP, mem32f),
175   };
178      if (0 != (BGFX_CAPS_FORMAT_TEXTURE_COLOR & caps->formats[bgfx::TextureFormat::R8]) )
179      {
180         textures3d[numTextures3d++] = bgfx::createTexture3D(32, 32, 32, 0, bgfx::TextureFormat::R8,   BGFX_TEXTURE_U_CLAMP|BGFX_TEXTURE_V_CLAMP|BGFX_TEXTURE_W_CLAMP, mem8);
181      }
176182
183      if (0 != (BGFX_CAPS_FORMAT_TEXTURE_COLOR & caps->formats[bgfx::TextureFormat::R16F]) )
184      {
185         textures3d[numTextures3d++] = bgfx::createTexture3D(32, 32, 32, 0, bgfx::TextureFormat::R16F, BGFX_TEXTURE_U_CLAMP|BGFX_TEXTURE_V_CLAMP|BGFX_TEXTURE_W_CLAMP, mem16f);
186      }
187
188      if (0 != (BGFX_CAPS_FORMAT_TEXTURE_COLOR & caps->formats[bgfx::TextureFormat::R32F]) )
189      {
190         textures3d[numTextures3d++] = bgfx::createTexture3D(32, 32, 32, 0, bgfx::TextureFormat::R32F, BGFX_TEXTURE_U_CLAMP|BGFX_TEXTURE_V_CLAMP|BGFX_TEXTURE_W_CLAMP, mem32f);
191      }
192   }
193
177194   // Create static vertex buffer.
178195   bgfx::VertexBufferHandle vbh = bgfx::createVertexBuffer(bgfx::makeRef(s_cubeVertices, sizeof(s_cubeVertices) ), PosTexcoordVertex::ms_decl);
179196
r245308r245309
188205
189206   bgfx::ProgramHandle program     = loadProgram("vs_update", "fs_update");
190207   bgfx::ProgramHandle programCmp  = loadProgram("vs_update", "fs_update_cmp");
191   bgfx::ProgramHandle program3d   = loadProgram("vs_update", "fs_update_3d");
208   bgfx::ProgramHandle program3d   = BGFX_INVALID_HANDLE;
209   if (texture3DSupported)
210   {
211      program3d = loadProgram("vs_update", "fs_update_3d");
212   }
192213
193214   const uint32_t textureSide = 2048;
194215
r245308r245309
399420         bgfx::submit(1);
400421      }
401422
402      for (uint32_t ii = 0; ii < BX_COUNTOF(textures3d); ++ii)
423      for (uint32_t ii = 0; ii < numTextures3d; ++ii)
403424      {
404425         bx::mtxTranslate(mtx, xpos + ii*2.1f, -4.0f, 0.0f);
405426
r245308r245309
465486      bgfx::destroyTexture(textures[ii]);
466487   }
467488
468   for (uint32_t ii = 0; ii < BX_COUNTOF(textures3d); ++ii)
489   for (uint32_t ii = 0; ii < numTextures3d; ++ii)
469490   {
470491      bgfx::destroyTexture(textures3d[ii]);
471492   }
r245308r245309
474495   bgfx::destroyTexture(textureCube);
475496   bgfx::destroyIndexBuffer(ibh);
476497   bgfx::destroyVertexBuffer(vbh);
477   bgfx::destroyProgram(program3d);
498   if (bgfx::isValid(program3d) )
499   {
500      bgfx::destroyProgram(program3d);
501   }
478502   bgfx::destroyProgram(programCmp);
479503   bgfx::destroyProgram(program);
480504   bgfx::destroyUniform(u_time);
trunk/3rdparty/bgfx/examples/09-hdr/hdr.cpp
r245308r245309
174174   bgfx::setViewName(8, "Blur vertical");
175175   bgfx::setViewName(9, "Blur horizontal + tonemap");
176176
177   bgfx::TextureHandle uffizi = loadTexture("uffizi.dds", BGFX_TEXTURE_U_CLAMP|BGFX_TEXTURE_V_CLAMP|BGFX_TEXTURE_W_CLAMP);
177   bgfx::TextureHandle uffizi = loadTexture("uffizi.dds"
178         , 0
179         | BGFX_TEXTURE_U_CLAMP
180         | BGFX_TEXTURE_V_CLAMP
181         | BGFX_TEXTURE_W_CLAMP
182         );
178183
179184   bgfx::ProgramHandle skyProgram     = loadProgram("vs_hdr_skybox",  "fs_hdr_skybox");
180185   bgfx::ProgramHandle lumProgram     = loadProgram("vs_hdr_lum",     "fs_hdr_lum");
r245308r245309
371376
372377      // Render skybox into view 0.
373378      bgfx::setTexture(0, u_texCube, uffizi);
379
374380      bgfx::setProgram(skyProgram);
375381      bgfx::setState(BGFX_STATE_RGB_WRITE|BGFX_STATE_ALPHA_WRITE);
376382      screenSpaceQuad( (float)width, (float)height, true);
trunk/3rdparty/bgfx/examples/13-stencil/stencil.cpp
r245308r245309
10401040      const float radius = (scene == StencilReflectionScene) ? 15.0f : 25.0f;
10411041      for (uint8_t ii = 0; ii < numLights; ++ii)
10421042      {
1043         lightPosRadius[ii][0] = sin( (lightTimeAccumulator*1.1f + ii*0.03f + ii*bx::piHalf*1.07f ) )*20.0f;
1044         lightPosRadius[ii][1] = 8.0f + (1.0f - cos( (lightTimeAccumulator*1.5f + ii*0.29f + bx::piHalf*1.49f ) ))*4.0f;
1045         lightPosRadius[ii][2] = cos( (lightTimeAccumulator*1.3f + ii*0.13f + ii*bx::piHalf*1.79f ) )*20.0f;
1043         lightPosRadius[ii][0] = sinf( (lightTimeAccumulator*1.1f + ii*0.03f + ii*bx::piHalf*1.07f ) )*20.0f;
1044         lightPosRadius[ii][1] = 8.0f + (1.0f - cosf( (lightTimeAccumulator*1.5f + ii*0.29f + bx::piHalf*1.49f ) ))*4.0f;
1045         lightPosRadius[ii][2] = cosf( (lightTimeAccumulator*1.3f + ii*0.13f + ii*bx::piHalf*1.79f ) )*20.0f;
10461046         lightPosRadius[ii][3] = radius;
10471047      }
10481048      memcpy(s_uniforms.m_lightPosRadius, lightPosRadius, numLights * 4*sizeof(float));
r245308r245309
11121112            , 0.0f
11131113            , 0.0f
11141114            , 0.0f
1115            , sin(ii * 2.0f + 13.0f - sceneTimeAccumulator) * 13.0f
1115            , sinf(ii * 2.0f + 13.0f - sceneTimeAccumulator) * 13.0f
11161116            , 4.0f
1117            , cos(ii * 2.0f + 13.0f - sceneTimeAccumulator) * 13.0f
1117            , cosf(ii * 2.0f + 13.0f - sceneTimeAccumulator) * 13.0f
11181118            );
11191119      }
11201120
r245308r245309
11881188
11891189            // Set lights back.
11901190            memcpy(s_uniforms.m_lightPosRadius, lightPosRadius, numLights * 4*sizeof(float));
1191
11921191            // Third pass - Blend plane.
11931192
11941193            // Floor.
r245308r245309
12171216                  , s_renderStates[RenderState::StencilReflection_DrawScene]
12181217                  );
12191218            }
1219
12201220         }
12211221         break;
12221222
trunk/3rdparty/bgfx/examples/14-shadowvolumes/shadowvolumes.cpp
r245308r245309
22762276      {
22772277         for (uint8_t ii = 0; ii < settings_numLights; ++ii)
22782278         {
2279            lightPosRadius[ii][0] = cos(2.0f*bx::pi/settings_numLights * float(ii) + lightTimeAccumulator * 1.1f + 3.0f) * 20.0f;
2279            lightPosRadius[ii][0] = cosf(2.0f*bx::pi/settings_numLights * float(ii) + lightTimeAccumulator * 1.1f + 3.0f) * 20.0f;
22802280            lightPosRadius[ii][1] = 20.0f;
2281            lightPosRadius[ii][2] = sin(2.0f*bx::pi/settings_numLights * float(ii) + lightTimeAccumulator * 1.1f + 3.0f) * 20.0f;
2281            lightPosRadius[ii][2] = sinf(2.0f*bx::pi/settings_numLights * float(ii) + lightTimeAccumulator * 1.1f + 3.0f) * 20.0f;
22822282            lightPosRadius[ii][3] = 20.0f;
22832283         }
22842284      }
r245308r245309
22862286      {
22872287         for (uint8_t ii = 0; ii < settings_numLights; ++ii)
22882288         {
2289            lightPosRadius[ii][0] = cos(float(ii) * 2.0f/settings_numLights + lightTimeAccumulator * 1.3f + bx::pi) * 40.0f;
2289            lightPosRadius[ii][0] = cosf(float(ii) * 2.0f/settings_numLights + lightTimeAccumulator * 1.3f + bx::pi) * 40.0f;
22902290            lightPosRadius[ii][1] = 20.0f;
2291            lightPosRadius[ii][2] = sin(float(ii) * 2.0f/settings_numLights + lightTimeAccumulator * 1.3f + bx::pi) * 40.0f;
2291            lightPosRadius[ii][2] = sinf(float(ii) * 2.0f/settings_numLights + lightTimeAccumulator * 1.3f + bx::pi) * 40.0f;
22922292            lightPosRadius[ii][3] = 20.0f;
22932293         }
22942294      }
r245308r245309
23622362         inst.m_rotation[0] = 0.0f;
23632363         inst.m_rotation[1] = 0.0f;
23642364         inst.m_rotation[2] = 0.0f;
2365         inst.m_pos[0]      = sin(ii * 2.0f + 13.0f + sceneTimeAccumulator * 1.1f) * 13.0f;
2365         inst.m_pos[0]      = sinf(ii * 2.0f + 13.0f + sceneTimeAccumulator * 1.1f) * 13.0f;
23662366         inst.m_pos[1]      = 6.0f;
2367         inst.m_pos[2]      = cos(ii * 2.0f + 13.0f + sceneTimeAccumulator * 1.1f) * 13.0f;
2367         inst.m_pos[2]      = cosf(ii * 2.0f + 13.0f + sceneTimeAccumulator * 1.1f) * 13.0f;
23682368         inst.m_model       = &cubeModel;
23692369      }
23702370
r245308r245309
23792379         inst.m_rotation[0] = 0.0f;
23802380         inst.m_rotation[1] = 0.0f;
23812381         inst.m_rotation[2] = 0.0f;
2382         inst.m_pos[0]      = sin(ii * 2.0f + 13.0f + sceneTimeAccumulator * 1.1f) * 13.0f;
2382         inst.m_pos[0]      = sinf(ii * 2.0f + 13.0f + sceneTimeAccumulator * 1.1f) * 13.0f;
23832383         inst.m_pos[1]      = 22.0f;
2384         inst.m_pos[2]      = cos(ii * 2.0f + 13.0f + sceneTimeAccumulator * 1.1f) * 13.0f;
2384         inst.m_pos[2]      = cosf(ii * 2.0f + 13.0f + sceneTimeAccumulator * 1.1f) * 13.0f;
23852385         inst.m_model       = &cubeModel;
23862386      }
23872387
trunk/3rdparty/bgfx/examples/15-shadowmaps-simple/shadowmaps_simple.cpp
r245308r245309
221221
222222      // Setup lights.
223223      float lightPos[4];
224      lightPos[0] = -cos(timeAccumulatorLight);
224      lightPos[0] = -cosf(timeAccumulatorLight);
225225      lightPos[1] = -1.0f;
226      lightPos[2] = -sin(timeAccumulatorLight);
226      lightPos[2] = -sinf(timeAccumulatorLight);
227227      lightPos[3] = 0.0f;
228228
229229      bgfx::setUniform(u_lightPos, lightPos);
trunk/3rdparty/bgfx/examples/16-shadowmaps/shadowmaps.cpp
r245308r245309
21652165      if (settings.m_updateScene)  { timeAccumulatorScene += deltaTime; }
21662166
21672167      // Setup lights.
2168      pointLight.m_position.m_x = cos(timeAccumulatorLight) * 20.0f;
2168      pointLight.m_position.m_x = cosf(timeAccumulatorLight) * 20.0f;
21692169      pointLight.m_position.m_y = 26.0f;
2170      pointLight.m_position.m_z = sin(timeAccumulatorLight) * 20.0f;
2170      pointLight.m_position.m_z = sinf(timeAccumulatorLight) * 20.0f;
21712171      pointLight.m_spotDirectionInner.m_x = -pointLight.m_position.m_x;
21722172      pointLight.m_spotDirectionInner.m_y = -pointLight.m_position.m_y;
21732173      pointLight.m_spotDirectionInner.m_z = -pointLight.m_position.m_z;
21742174
2175      directionalLight.m_position.m_x = -cos(timeAccumulatorLight);
2175      directionalLight.m_position.m_x = -cosf(timeAccumulatorLight);
21762176      directionalLight.m_position.m_y = -1.0f;
2177      directionalLight.m_position.m_z = -sin(timeAccumulatorLight);
2177      directionalLight.m_position.m_z = -sinf(timeAccumulatorLight);
21782178
21792179      // Setup instance matrices.
21802180      float mtxFloor[16];
trunk/3rdparty/bgfx/examples/20-nanovg/nanovg.cpp
r245308r245309
387387   float ry = y + ey;
388388   float dx,dy,d;
389389   float br = (ex < ey ? ex : ey) * 0.5f;
390   float blink = 1 - pow(sinf(t*0.5f),200)*0.8f;
390   float blink = 1 - powf(sinf(t*0.5f),200)*0.8f;
391391
392392   bg = nvgLinearGradient(vg, x,y+h*0.5f,x+w*0.1f,y+h, nvgRGBA(0,0,0,32), nvgRGBA(0,0,0,16));
393393   nvgBeginPath(vg);
r245308r245309
10751075      nvgBeginPath(vg);
10761076      nvgFillColor(vg, nvgRGBA(255,192,0,255));
10771077      nvgRoundedRect(vg
1078         , round(bounds[0])-4.0f
1079         , round(bounds[1])-2.0f
1080         , round(bounds[2]-bounds[0])+8.0f
1081         , round(bounds[3]-bounds[1])+4.0f
1082         , (round(bounds[3]-bounds[1])+4.0f)/2.0f-1.0f
1078         , roundf(bounds[0])-4.0f
1079         , roundf(bounds[1])-2.0f
1080         , roundf(bounds[2]-bounds[0])+8.0f
1081         , roundf(bounds[3]-bounds[1])+4.0f
1082         , (roundf(bounds[3]-bounds[1])+4.0f)/2.0f-1.0f
10831083         );
10841084      nvgFill(vg);
10851085
r245308r245309
10971097   nvgBeginPath(vg);
10981098   nvgFillColor(vg, nvgRGBA(220,220,220,255));
10991099   nvgRoundedRect(vg
1100      , round(bounds[0]-2.0f)
1101      , round(bounds[1]-2.0f)
1102      , round(bounds[2]-bounds[0])+4.0f
1103      , round(bounds[3]-bounds[1])+4.0f
1100      , roundf(bounds[0]-2.0f)
1101      , roundf(bounds[1]-2.0f)
1102      , roundf(bounds[2]-bounds[0])+4.0f
1103      , roundf(bounds[3]-bounds[1])+4.0f
11041104      , 3.0f
11051105      );
11061106   px = float( (int)((bounds[2]+bounds[0])/2) );
trunk/3rdparty/bgfx/examples/21-deferred/deferred.cpp
r245308r245309
529529         {
530530            Sphere lightPosRadius;
531531
532            float lightTime = time * lightAnimationSpeed * (sin(light/float(numLights) * bx::piHalf ) * 0.5f + 0.5f);
533            lightPosRadius.m_center[0] = sin( ( (lightTime + light*0.47f) + bx::piHalf*1.37f ) )*offset;
534            lightPosRadius.m_center[1] = cos( ( (lightTime + light*0.69f) + bx::piHalf*1.49f ) )*offset;
535            lightPosRadius.m_center[2] = sin( ( (lightTime + light*0.37f) + bx::piHalf*1.57f ) )*2.0f;
532            float lightTime = time * lightAnimationSpeed * (sinf(light/float(numLights) * bx::piHalf ) * 0.5f + 0.5f);
533            lightPosRadius.m_center[0] = sinf( ( (lightTime + light*0.47f) + bx::piHalf*1.37f ) )*offset;
534            lightPosRadius.m_center[1] = cosf( ( (lightTime + light*0.69f) + bx::piHalf*1.49f ) )*offset;
535            lightPosRadius.m_center[2] = sinf( ( (lightTime + light*0.37f) + bx::piHalf*1.57f ) )*2.0f;
536536            lightPosRadius.m_radius = 2.0f;
537537
538538            Aabb aabb;
trunk/3rdparty/bgfx/examples/23-vectordisplay/main.cpp
r245308r245309
150150      // draw moving shape
151151      static float counter = 0.0f;
152152      counter += 0.01f;
153      float posX = width  / 2.0f + sin(counter * 3.18378f) * (width / 2.0f);
154      float posY = height / 2.0f + cos(counter) * (height / 2.0f);
153      float posX = width  / 2.0f + sinf(counter * 3.18378f) * (width / 2.0f);
154      float posY = height / 2.0f + cosf(counter) * (height / 2.0f);
155155      vd.drawCircle(posX, posY, 5.0f, 10.0f);
156156
157157      vd.endFrame();
trunk/3rdparty/bgfx/examples/23-vectordisplay/vectordisplay.cpp
r245308r245309
361361      line->y0 = m_pendingPoints[i - 1].y;
362362      line->x1 = m_pendingPoints[i].x;
363363      line->y1 = m_pendingPoints[i].y;
364      line->a = atan2(line->y1 - line->y0, line->x1 - line->x0);                  // angle from positive x axis, increasing ccw, [-pi, pi]
364      line->a = atan2f(line->y1 - line->y0, line->x1 - line->x0); // angle from positive x axis, increasing ccw, [-pi, pi]
365365      line->sin_a = sinf(line->a);
366366      line->cos_a = cosf(line->a);
367      line->len = sqrt( (line->x1 - line->x0) * (line->x1 - line->x0) + (line->y1 - line->y0) * (line->y1 - line->y0) );
367      line->len = sqrtf( (line->x1 - line->x0) * (line->x1 - line->x0) + (line->y1 - line->y0) * (line->y1 - line->y0) );
368368
369369      // figure out what connections we have
370370      line->has_prev = (!line->is_first
trunk/3rdparty/bgfx/examples/25-c99/helloworld.c
r245308r245309
1515
1616int _main_(int _argc, char** _argv)
1717{
18   uint32_t width  = 1280;
19   uint32_t height = 720;
20   uint32_t debug  = BGFX_DEBUG_TEXT;
21   uint32_t reset  = BGFX_RESET_VSYNC;
1822   (void)_argc;
1923   (void)_argv;
20   uint32_t width = 1280;
21   uint32_t height = 720;
22   uint32_t debug = BGFX_DEBUG_TEXT;
23   uint32_t reset = BGFX_RESET_VSYNC;
2424
25   bgfx_init(BGFX_RENDERER_TYPE_COUNT, NULL, NULL);
25   bgfx_init(BGFX_RENDERER_TYPE_COUNT
26         , BGFX_PCI_ID_NONE
27         , 0
28         , NULL
29         , NULL
30         );
2631   bgfx_reset(width, height, reset);
2732
2833   // Enable debug text.
trunk/3rdparty/bgfx/examples/common/bounds.cpp
r245308r245309
264264      {
265265         position = (float*)&vertex[index*_stride];
266266
267         float xx = position[0] - center[0];
268         float yy = position[1] - center[1];
269         float zz = position[2] - center[2];
267         xx = position[0] - center[0];
268         yy = position[1] - center[1];
269         zz = position[2] - center[2];
270270         float distSq = xx*xx + yy*yy + zz*zz;
271271
272272         if (distSq > maxDistSq)
trunk/3rdparty/bgfx/examples/common/entry/entry.cpp
r245308r245309
2929#if ENTRY_CONFIG_IMPLEMENT_DEFAULT_ALLOCATOR
3030   bx::ReallocatorI* getDefaultAllocator()
3131   {
32BX_PRAGMA_DIAGNOSTIC_PUSH_MSVC();
33BX_PRAGMA_DIAGNOSTIC_IGNORED_MSVC(4459); // warning C4459: declaration of 's_allocator' hides global declaration
3234      static bx::CrtAllocator s_allocator;
3335      return &s_allocator;
36BX_PRAGMA_DIAGNOSTIC_POP_MSVC();
3437   }
3538#endif // ENTRY_CONFIG_IMPLEMENT_DEFAULT_ALLOCATOR
3639
trunk/3rdparty/bgfx/examples/common/entry/entry_p.h
r245308r245309
161161   class EventQueue
162162   {
163163   public:
164      ~EventQueue()
165      {
166         for (const Event* ev = poll(); NULL != ev; ev = poll() )
167         {
168            release(ev);
169         }
170      }
171
164172      void postAxisEvent(WindowHandle _handle, GamepadHandle _gamepad, GamepadAxis::Enum _axis, int32_t _value)
165173      {
166174         AxisEvent* ev = new AxisEvent(_handle);
trunk/3rdparty/bgfx/include/bgfx.c99.h
r245308r245309
273273} bgfx_texture_info_t;
274274
275275/**
276 */
277typedef struct bgfx_caps_gpu
278{
279    uint16_t vendorId;
280    uint16_t deviceId;
281
282} bgfx_caps_gpu_t;
283
284/**
276285 *  Renderer capabilities.
277286 */
278287typedef struct bgfx_caps
r245308r245309
293302    uint16_t maxViews;          /* < Maximum views.                    */
294303    uint16_t maxDrawCalls;      /* < Maximum draw calls.               */
295304    uint8_t  maxFBAttachments;  /* < Maximum frame buffer attachments. */
305    uint8_t  numGPUs;           /* <                                   */
296306
307    uint16_t vendorId;          /* <                                   */
308    uint16_t deviceId;          /* <                                   */
309    bgfx_caps_gpu_t gpu[4];     /* <                                   */
310
297311    /**
298312     *  Supported texture formats.
299313     *   `BGFX_CAPS_FORMAT_TEXTURE_NONE` - not supported
r245308r245309
559573 *    specified, library uses default CRT allocator. The library assumes
560574 *    custom allocator is thread safe.
561575 */
562BGFX_C_API void bgfx_init(bgfx_renderer_type_t _type, bgfx_callback_interface_t* _callback, bgfx_reallocator_interface_t* _allocator);
576BGFX_C_API void bgfx_init(bgfx_renderer_type_t _type, uint16_t _vendorId, uint16_t _deviceId, bgfx_callback_interface_t* _callback, bgfx_reallocator_interface_t* _allocator);
563577
564578/**
565579 *  Shutdown bgfx library.
trunk/3rdparty/bgfx/include/bgfx.h
r245308r245309
315315      uint16_t maxViews;         ///< Maximum views.
316316      uint16_t maxDrawCalls;     ///< Maximum draw calls.
317317      uint8_t  maxFBAttachments; ///< Maximum frame buffer attachments.
318      uint8_t  numGPUs; ///<
318319
320      uint16_t vendorId; ///<
321      uint16_t deviceId; ///<
322
323      struct GPU
324      {
325         uint16_t vendorId;
326         uint16_t deviceId;
327      };
328
329      GPU gpu[4];      ///<
330
319331      /// Supported texture formats.
320332      ///   - `BGFX_CAPS_FORMAT_TEXTURE_NONE` - not supported
321333      ///   - `BGFX_CAPS_FORMAT_TEXTURE_COLOR` - supported
r245308r245309
508520   ///   default rendering backend will be selected.
509521   ///   See: `bgfx::RendererType`
510522   ///
523   /// @param _vendorId Vendor PCI id. If set to BGFX_PCI_ID_NONE it will select the first device.
524   ///   - `BGFX_PCI_ID_NONE` - autoselect.
525   ///   - `BGFX_PCI_ID_AMD` - AMD.
526   ///   - `BGFX_PCI_ID_INTEL` - Intel.
527   ///   - `BGFX_PCI_ID_NVIDIA` - nVidia.
528   ///
529   /// @param _deviceId Device id. If set to 0 it will select first device, or device with
530   ///   matching id.
531   ///
511532   /// @param _callback Provide application specific callback interface.
512533   ///   See: `bgfx::CallbackI`
513534   ///
r245308r245309
517538   ///
518539   /// @attention C99 equivalent is `bgfx_init`.
519540   ///
520   void init(RendererType::Enum _type = RendererType::Count, CallbackI* _callback = NULL, bx::ReallocatorI* _reallocator = NULL);
541   void init(RendererType::Enum _type = RendererType::Count, uint16_t _vendorId = BGFX_PCI_ID_NONE, uint16_t _deviceId = 0, CallbackI* _callback = NULL, bx::ReallocatorI* _reallocator = NULL);
521542
522543   /// Shutdown bgfx library.
523544   ///
trunk/3rdparty/bgfx/include/bgfxdefines.h
r245308r245309
333333#define BGFX_SUBMIT_EYE_MASK  UINT8_C(0x03)
334334#define BGFX_SUBMIT_EYE_FIRST BGFX_SUBMIT_EYE_LEFT
335335
336///
337#define BGFX_PCI_ID_NONE   UINT16_C(0x0000)
338#define BGFX_PCI_ID_AMD    UINT16_C(0x1002)
339#define BGFX_PCI_ID_INTEL  UINT16_C(0x8086)
340#define BGFX_PCI_ID_NVIDIA UINT16_C(0x10de)
341
336342#endif // BGFX_DEFINES_H_HEADER_GUARD
trunk/3rdparty/bgfx/scripts/genie.lua
r245308r245309
158158         "ws2_32",
159159      }
160160
161      configuration { "x32" }
162         libdirs { path.join("$(OVR_DIR)/LibOVR/Lib/Win32", _ACTION) }
161      -- Check for LibOVR 5.0+
162      if os.isdir(path.join(os.getenv("OVR_DIR"), "LibOVR/Lib/Windows/Win32/Debug/VS2012")) then
163163
164      configuration { "x64" }
165         libdirs { path.join("$(OVR_DIR)/LibOVR/Lib/x64", _ACTION) }
164         configuration { "x32", "Debug" }
165            libdirs { path.join("$(OVR_DIR)/LibOVR/Lib/Windows/Win32/Debug", _ACTION) }
166166
167      configuration { "x32", "Debug" }
168         links { "libovrd" }
167         configuration { "x32", "Release" }
168            libdirs { path.join("$(OVR_DIR)/LibOVR/Lib/Windows/Win32/Release", _ACTION) }
169169
170      configuration { "x32", "Release" }
171         links { "libovr" }
170         configuration { "x64", "Debug" }
171            libdirs { path.join("$(OVR_DIR)/LibOVR/Lib/Windows/x64/Debug", _ACTION) }
172172
173      configuration { "x64", "Debug" }
174         links { "libovr64d" }
173         configuration { "x64", "Release" }
174            libdirs { path.join("$(OVR_DIR)/LibOVR/Lib/Windows/x64/Release", _ACTION) }
175175
176      configuration { "x64", "Release" }
177         links { "libovr64" }
176         configuration { "x32 or x64" }
177            links { "libovr" }
178      else
179         configuration { "x32" }
180            libdirs { path.join("$(OVR_DIR)/LibOVR/Lib/Win32", _ACTION) }
178181
182         configuration { "x64" }
183            libdirs { path.join("$(OVR_DIR)/LibOVR/Lib/x64", _ACTION) }
184
185         configuration { "x32", "Debug" }
186            links { "libovrd" }
187
188         configuration { "x32", "Release" }
189            links { "libovr" }
190
191         configuration { "x64", "Debug" }
192            links { "libovr64d" }
193
194         configuration { "x64", "Release" }
195            links { "libovr64" }
196      end
197
179198      configuration {}
180199   end
181200
trunk/3rdparty/bgfx/src/bgfx.cpp
r245308r245309
888888
889889   static void dumpCaps()
890890   {
891      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            );
892896      for (uint32_t ii = 0; ii < BX_COUNTOF(s_capsFlags); ++ii)
893897      {
894898         if (0 != (g_caps.supported & s_capsFlags[ii].m_flag) )
r245308r245309
19771981      return s_rendererCreator[_type].name;
19781982   }
19791983
1980   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)
19811985   {
19821986      BX_CHECK(NULL == s_ctx, "bgfx is already initialized.");
19831987      BX_TRACE("Init...");
r245308r245309
19891993      g_caps.maxViews     = BGFX_CONFIG_MAX_VIEWS;
19901994      g_caps.maxDrawCalls = BGFX_CONFIG_MAX_DRAW_CALLS;
19911995      g_caps.maxFBAttachments = 1;
1996      g_caps.vendorId = _vendorId;
1997      g_caps.deviceId = _deviceId;
19921998
19931999      if (NULL != _allocator)
19942000      {
r245308r245309
30123018   return bgfx::getRendererName(bgfx::RendererType::Enum(_type) );
30133019}
30143020
3015BGFX_C_API void bgfx_init(bgfx_renderer_type_t _type, struct bgfx_callback_interface* _callback, struct bgfx_reallocator_interface* _allocator)
3021BGFX_C_API void bgfx_init(bgfx_renderer_type_t _type, uint16_t _vendorId, uint16_t _deviceId, bgfx_callback_interface_t* _callback, bgfx_reallocator_interface_t* _allocator)
30163022{
30173023   return bgfx::init(bgfx::RendererType::Enum(_type)
3024      , _vendorId
3025      , _deviceId
30183026      , reinterpret_cast<bgfx::CallbackI*>(_callback)
30193027      , reinterpret_cast<bx::ReallocatorI*>(_allocator)
30203028      );
trunk/3rdparty/bgfx/src/bgfx_p.h
r245308r245309
2929#include <string.h>
3030#include <alloca.h>
3131
32// Check handle, cannot be bgfx::invalidHandle and must be valid.
3233#define BGFX_CHECK_HANDLE(_desc, _handleAlloc, _handle) \
3334         BX_CHECK(isValid(_handle) \
3435            && _handleAlloc.isValid(_handle.idx) \
r245308r245309
3637            , _desc \
3738            , _handle.idx \
3839            , _handleAlloc.getMaxHandles() \
39            );
40            )
4041
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
4152namespace bgfx
4253{
4354#if BX_COMPILER_CLANG_ANALYZER
r245308r245309
30913102
30923103      BGFX_API_FUNC(void setViewFrameBuffer(uint8_t _id, FrameBufferHandle _handle) )
30933104      {
3094         BGFX_CHECK_HANDLE("setViewFrameBuffer", m_frameBufferHandle, _handle);
3105         BGFX_CHECK_HANDLE_INVALID_OK("setViewFrameBuffer", m_frameBufferHandle, _handle);
30953106         m_fb[_id] = _handle;
30963107      }
30973108
r245308r245309
32593270
32603271      BGFX_API_FUNC(void setTexture(uint8_t _stage, UniformHandle _sampler, TextureHandle _handle, uint32_t _flags) )
32613272      {
3262         BGFX_CHECK_HANDLE("setTexture", m_textureHandle, _handle);
3273         BGFX_CHECK_HANDLE_INVALID_OK("setTexture/TextureHandle", m_textureHandle, _handle);
32633274         m_submit->setTexture(_stage, _sampler, _handle, _flags);
32643275      }
32653276
32663277      BGFX_API_FUNC(void setTexture(uint8_t _stage, UniformHandle _sampler, FrameBufferHandle _handle, uint8_t _attachment, uint32_t _flags) )
32673278      {
3279         BGFX_CHECK_HANDLE_INVALID_OK("setTexture/FrameBufferHandle", m_frameBufferHandle, _handle);
32683280         BX_CHECK(_attachment < g_caps.maxFBAttachments, "Frame buffer attachment index %d is invalid.", _attachment);
32693281         TextureHandle textureHandle = BGFX_INVALID_HANDLE;
32703282         if (isValid(_handle) )
trunk/3rdparty/bgfx/src/ovr.cpp
r245308r245309
123123      result = ovrHmd_ConfigureRendering(m_hmd
124124         , _config
125125         , 0
126         | ovrDistortionCap_Chromatic
126#if OVR_VERSION < OVR_VERSION_050
127         | ovrDistortionCap_Chromatic // permanently enabled >= v5.0
128#endif
127129         | ovrDistortionCap_Vignette
128130         | ovrDistortionCap_TimeWarp
129131         | ovrDistortionCap_Overdrive
trunk/3rdparty/bgfx/src/ovr.h
r245308r245309
1010
1111#if BGFX_CONFIG_USE_OVR
1212
13#   include <OVR.h>
13#   include <OVR_Version.h>
1414
1515#   define OVR_VERSION_(_a, _b, _c) (_a * 10000 + _b * 100 + _c)
1616#   define OVR_VERSION     OVR_VERSION_(OVR_MAJOR_VERSION, OVR_MINOR_VERSION, OVR_BUILD_VERSION)
1717#   define OVR_VERSION_042 OVR_VERSION_(0, 4, 2)
1818#   define OVR_VERSION_043 OVR_VERSION_(0, 4, 3)
1919#   define OVR_VERSION_044 OVR_VERSION_(0, 4, 4)
20#   define OVR_VERSION_050 OVR_VERSION_(0, 5, 0)
2021
22#   if OVR_VERSION < OVR_VERSION_050
23#      include <OVR.h>
24#   else
25#      include <OVR_CAPI.h>
26#   endif // OVR_VERSION < OVR_VERSION_050
27
2128#   if BGFX_CONFIG_RENDERER_DIRECT3D9
2229#      define OVR_D3D_VERSION 9
23#      include <OVR_D3D.h>
30#      if OVR_VERSION < OVR_VERSION_050
31#         include <OVR_D3D.h>
32#      else
33#         include <OVR_CAPI_D3D.h>
34#      endif
2435#   endif // BGFX_CONFIG_RENDERER_DIRECT3D9
2536
2637#   if BGFX_CONFIG_RENDERER_DIRECT3D11
r245308r245309
2940#         undef OVR_D3D_VERSION
3041#      endif // OVR_CAPI_D3D_h
3142#      define OVR_D3D_VERSION 11
32#      include <OVR_D3D.h>
43#      if OVR_VERSION < OVR_VERSION_050
44#         include <OVR_D3D.h>
45#      else
46#         include <OVR_CAPI_D3D.h>
47#      endif
3348#   endif // BGFX_CONFIG_RENDERER_DIRECT3D11
3449
3550#   if BGFX_CONFIG_RENDERER_OPENGL
36#      include <OVR_GL.h>
51#      if OVR_VERSION < OVR_VERSION_050
52#         include <OVR_GL.h>
53#      else
54#         include <OVR_CAPI_GL.h>
55#      endif
3756#   endif // BGFX_CONFIG_RENDERER_OPENGL
3857
3958namespace bgfx
trunk/3rdparty/bgfx/src/renderer_d3d11.cpp
r245308r245309
513513         m_driverType = D3D_DRIVER_TYPE_HARDWARE;
514514
515515         IDXGIAdapter* adapter;
516         for (uint32_t ii = 0; DXGI_ERROR_NOT_FOUND != factory->EnumAdapters(ii, &adapter); ++ii)
516         for (uint32_t ii = 0
517            ; DXGI_ERROR_NOT_FOUND != factory->EnumAdapters(ii, &adapter) && ii < BX_COUNTOF(g_caps.gpu)
518            ; ++ii
519            )
517520         {
518521            DXGI_ADAPTER_DESC desc;
519522            hr = adapter->GetDesc(&desc);
r245308r245309
536539                  , desc.SharedSystemMemory
537540                  );
538541
542               g_caps.gpu[ii].vendorId = (uint16_t)desc.VendorId;
543               g_caps.gpu[ii].deviceId = (uint16_t)desc.DeviceId;
544               ++g_caps.numGPUs;
545
546               if ( (BGFX_PCI_ID_NONE != g_caps.vendorId ||             0 != g_caps.deviceId)
547               &&   (BGFX_PCI_ID_NONE == g_caps.vendorId || desc.VendorId == g_caps.vendorId)
548               &&   (               0 == g_caps.deviceId || desc.DeviceId == g_caps.deviceId) )
549               {
550                  m_adapter = adapter;
551                  m_adapter->AddRef();
552                  m_driverType = D3D_DRIVER_TYPE_UNKNOWN;
553               }
554
539555               if (BX_ENABLED(BGFX_CONFIG_DEBUG_PERFHUD)
540556               &&  0 != strstr(description, "PerfHUD") )
541557               {
r245308r245309
594610         }
595611         BGFX_FATAL(SUCCEEDED(hr), Fatal::UnableToInitialize, "Unable to create Direct3D11 device.");
596612
613         if (NULL != m_adapter)
614         {
615            DX_RELEASE(m_adapter, 2);
616         }
617
597618         IDXGIDevice* device = NULL;
598619         hr = E_FAIL;
599620         for (uint32_t ii = 0; ii < BX_COUNTOF(s_deviceIIDs) && FAILED(hr); ++ii)
r245308r245309
616637
617638         hr = adapter->GetDesc(&m_adapterDesc);
618639         BGFX_FATAL(SUCCEEDED(hr), Fatal::UnableToInitialize, "Unable to create Direct3D11 device.");
640         g_caps.vendorId = (uint16_t)m_adapterDesc.VendorId;
641         g_caps.deviceId = (uint16_t)m_adapterDesc.DeviceId;
619642
620643#if BX_PLATFORM_WINRT
621644         hr = adapter->GetParent(__uuidof(IDXGIFactory2), (void**)&m_factory);
r245308r245309
734757            {
735758               D3D11_FEATURE_DATA_FORMAT_SUPPORT data; // D3D11_FEATURE_DATA_FORMAT_SUPPORT2
736759               data.InFormat = s_textureFormat[ii].m_fmt;
737               HRESULT hr = m_device->CheckFeatureSupport(D3D11_FEATURE_FORMAT_SUPPORT, &data, sizeof(data) );
760               hr = m_device->CheckFeatureSupport(D3D11_FEATURE_FORMAT_SUPPORT, &data, sizeof(data) );
738761               if (SUCCEEDED(hr) )
739762               {
740763                  support |= 0 != (data.OutFormatSupport & (0
r245308r245309
31233146      uint32_t statsNumPrimsRendered[BX_COUNTOF(s_primInfo)] = {};
31243147      uint32_t statsNumInstances[BX_COUNTOF(s_primInfo)] = {};
31253148      uint32_t statsNumIndices = 0;
3149      uint32_t statsKeyType[2] = {};
31263150
31273151      if (0 == (_render->m_debug&BGFX_DEBUG_IFH) )
31283152      {
r245308r245309
31353159         for (int32_t item = 0, restartItem = numItems; item < numItems || restartItem < numItems;)
31363160         {
31373161            const bool isCompute = key.decode(_render->m_sortKeys[item], _render->m_viewRemap);
3162            statsKeyType[isCompute]++;
3163
31383164            const bool viewChanged = 0
31393165               || key.m_view != view
31403166               || item == numItems
r245308r245309
37783804               );
37793805
37803806            double elapsedCpuMs = double(elapsed)*toMs;
3781            tvm.printf(10, pos++, 0x8e, "  Draw calls: %4d / CPU %3.4f [ms]"
3807            tvm.printf(10, pos++, 0x8e, "  Submitted: %4d (draw %4d, compute %4d) / CPU %3.4f [ms]"
37823808               , _render->m_num
3809               , statsKeyType[0]
3810               , statsKeyType[1]
37833811               , elapsedCpuMs
37843812               );
37853813            for (uint32_t ii = 0; ii < BX_COUNTOF(s_primName); ++ii)
trunk/3rdparty/bgfx/src/renderer_d3d9.cpp
r245308r245309
359359         m_adapter = D3DADAPTER_DEFAULT;
360360         m_deviceType = D3DDEVTYPE_HAL;
361361
362         uint32_t adapterCount = m_d3d9->GetAdapterCount();
363         for (uint32_t ii = 0; ii < adapterCount; ++ii)
362         uint8_t numGPUs = bx::uint32_min(BX_COUNTOF(g_caps.gpu), m_d3d9->GetAdapterCount() );
363         for (uint32_t ii = 0; ii < numGPUs; ++ii)
364364         {
365            D3DADAPTER_IDENTIFIER9 identifier;
366            HRESULT hr = m_d3d9->GetAdapterIdentifier(ii, 0, &identifier);
365            D3DADAPTER_IDENTIFIER9 desc;
366            HRESULT hr = m_d3d9->GetAdapterIdentifier(ii, 0, &desc);
367367            if (SUCCEEDED(hr) )
368368            {
369369               BX_TRACE("Adapter #%d", ii);
370               BX_TRACE("\tDriver: %s", identifier.Driver);
371               BX_TRACE("\tDescription: %s", identifier.Description);
372               BX_TRACE("\tDeviceName: %s", identifier.DeviceName);
370               BX_TRACE("\tDriver: %s", desc.Driver);
371               BX_TRACE("\tDescription: %s", desc.Description);
372               BX_TRACE("\tDeviceName: %s", desc.DeviceName);
373373               BX_TRACE("\tVendorId: 0x%08x, DeviceId: 0x%08x, SubSysId: 0x%08x, Revision: 0x%08x"
374                  , identifier.VendorId
375                  , identifier.DeviceId
376                  , identifier.SubSysId
377                  , identifier.Revision
374                  , desc.VendorId
375                  , desc.DeviceId
376                  , desc.SubSysId
377                  , desc.Revision
378378                  );
379379
380               g_caps.gpu[ii].vendorId = (uint16_t)desc.VendorId;
381               g_caps.gpu[ii].deviceId = (uint16_t)desc.DeviceId;
382
383               if ( (BGFX_PCI_ID_NONE != g_caps.vendorId ||             0 != g_caps.deviceId)
384               &&   (BGFX_PCI_ID_NONE == g_caps.vendorId || desc.VendorId == g_caps.vendorId)
385               &&   (               0 == g_caps.deviceId || desc.DeviceId == g_caps.deviceId) )
386               {
387                  m_adapter = ii;
388               }
389
380390#if BGFX_CONFIG_DEBUG_PERFHUD
381               if (0 != strstr(identifier.Description, "PerfHUD") )
391               if (0 != strstr(desc.Description, "PerfHUD") )
382392               {
383393                  m_adapter = ii;
384394                  m_deviceType = D3DDEVTYPE_REF;
r245308r245309
388398         }
389399
390400         DX_CHECK(m_d3d9->GetAdapterIdentifier(m_adapter, 0, &m_identifier) );
391         m_amd = m_identifier.VendorId == 0x1002;
392         m_nvidia = m_identifier.VendorId == 0x10de;
401         m_amd    = m_identifier.VendorId == BGFX_PCI_ID_AMD;
402         m_nvidia = m_identifier.VendorId == BGFX_PCI_ID_NVIDIA;
403         g_caps.vendorId = (uint16_t)m_identifier.VendorId;
404         g_caps.deviceId = (uint16_t)m_identifier.DeviceId;
393405
394406         uint32_t behaviorFlags[] =
395407         {
r245308r245309
22152227            if (NULL != _rect)
22162228            {
22172229               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;
2230               rect.left   = _rect->m_x;
2231               rect.top    = _rect->m_y;
2232               rect.right  = rect.left + _rect->m_width;
2233               rect.bottom = rect.top  + _rect->m_height;
22222234               DX_CHECK(m_texture2d->LockRect(_lod, &lockedRect, &rect, 0) );
22232235            }
22242236            else
r245308r245309
24942506
24952507      if (convert)
24962508      {
2497         uint8_t* temp = (uint8_t*)BX_ALLOC(g_allocator, rectpitch*_rect.m_height);
2509         temp = (uint8_t*)BX_ALLOC(g_allocator, rectpitch*_rect.m_height);
24982510         imageDecodeToBgra8(temp, data, _rect.m_width, _rect.m_height, srcpitch, m_requestedFormat);
24992511         data = temp;
25002512      }
r245308r245309
28642876      FrameBufferHandle fbh = BGFX_INVALID_HANDLE;
28652877      uint32_t blendFactor = 0;
28662878
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);
2879      uint8_t primIndex;
2880      {
2881         const uint64_t pt = _render->m_debug&BGFX_DEBUG_WIREFRAME ? BGFX_STATE_PT_LINES : 0;
2882         primIndex = uint8_t(pt>>BGFX_STATE_PT_SHIFT);
2883      }
28692884      PrimInfo prim = s_primInfo[primIndex];
28702885
28712886      bool viewHasScissor = false;
r245308r245309
28762891      uint32_t statsNumPrimsRendered[BX_COUNTOF(s_primInfo)] = {};
28772892      uint32_t statsNumInstances[BX_COUNTOF(s_primInfo)] = {};
28782893      uint32_t statsNumIndices = 0;
2894      uint32_t statsKeyType[2] = {};
28792895
28802896      invalidateSamplerState();
28812897
r245308r245309
28842900         for (uint32_t item = 0, numItems = _render->m_num; item < numItems; ++item)
28852901         {
28862902            const bool isCompute = key.decode(_render->m_sortKeys[item], _render->m_viewRemap);
2903            statsKeyType[isCompute]++;
28872904
28882905            if (isCompute)
28892906            {
r245308r245309
34143431               );
34153432
34163433            double elapsedCpuMs = double(elapsed)*toMs;
3417            tvm.printf(10, pos++, 0x8e, "  Draw calls: %4d / CPU %3.4f [ms]"
3434            tvm.printf(10, pos++, 0x8e, "  Submitted: %4d (draw %4d, compute %4d) / CPU %3.4f [ms]"
34183435               , _render->m_num
3436               , statsKeyType[0]
3437               , statsKeyType[1]
34193438               , elapsedCpuMs
34203439               );
34213440            for (uint32_t ii = 0; ii < BX_COUNTOF(s_primName); ++ii)
trunk/3rdparty/bgfx/src/renderer_gl.cpp
r245308r245309
237237   };
238238   BX_STATIC_ASSERT(TextureFormat::Count == BX_COUNTOF(s_textureFormat) );
239239
240   static bool s_textureFilter[TextureFormat::Count+1];
241
240242   static GLenum s_rboFormat[] =
241243   {
242244      GL_ZERO,               // BC1
r245308r245309
358360         ANGLE_texture_compression_dxt1,
359361         ANGLE_texture_compression_dxt3,
360362         ANGLE_texture_compression_dxt5,
363         ANGLE_timer_query,
361364         ANGLE_translated_shader_source,
362365
363366         APPLE_texture_format_BGRA8888,
r245308r245309
418421         EXT_blend_minmax,
419422         EXT_blend_subtract,
420423         EXT_color_buffer_half_float,
424         EXT_color_buffer_float,
421425         EXT_compressed_ETC1_RGB8_sub_texture,
422426         EXT_debug_label,
423427         EXT_debug_marker,
424428         EXT_discard_framebuffer,
429         EXT_disjoint_timer_query,
425430         EXT_draw_buffers,
426431         EXT_frag_depth,
427432         EXT_framebuffer_blit,
r245308r245309
511516      bool m_initialize;
512517   };
513518
514   static Extension s_extension[Extension::Count] =
519   static Extension s_extension[] =
515520   {
516521      { "AMD_conservative_depth",                false,                             true  },
517522
r245308r245309
522527      { "ANGLE_texture_compression_dxt1",        false,                             true  },
523528      { "ANGLE_texture_compression_dxt3",        false,                             true  },
524529      { "ANGLE_texture_compression_dxt5",        false,                             true  },
530      { "ANGLE_timer_query",                     false,                             true  },
525531      { "ANGLE_translated_shader_source",        false,                             true  },
526532
527533      { "APPLE_texture_format_BGRA8888",         false,                             true  },
r245308r245309
582588      { "EXT_blend_minmax",                      BGFX_CONFIG_RENDERER_OPENGL >= 14, true  },
583589      { "EXT_blend_subtract",                    BGFX_CONFIG_RENDERER_OPENGL >= 14, true  },
584590      { "EXT_color_buffer_half_float",           false,                             true  }, // GLES2 extension.
591      { "EXT_color_buffer_float",                false,                             true  }, // GLES2 extension.
585592      { "EXT_compressed_ETC1_RGB8_sub_texture",  false,                             true  }, // GLES2 extension.
586593      { "EXT_debug_label",                       false,                             true  },
587594      { "EXT_debug_marker",                      false,                             true  },
588595      { "EXT_discard_framebuffer",               false,                             true  }, // GLES2 extension.
596      { "EXT_disjoint_timer_query",              false,                             true  }, // GLES2 extension.
589597      { "EXT_draw_buffers",                      false,                             true  }, // GLES2 extension.
590598      { "EXT_frag_depth",                        false,                             true  }, // GLES2 extension.
591599      { "EXT_framebuffer_blit",                  BGFX_CONFIG_RENDERER_OPENGL >= 30, true  },
r245308r245309
609617      { "EXT_texture_storage",                   false,                             true  },
610618      { "EXT_texture_swizzle",                   false,                             true  },
611619      { "EXT_texture_type_2_10_10_10_REV",       false,                             true  },
612      { "EXT_timer_query",                       false,                            true  },
620      { "EXT_timer_query",                       BGFX_CONFIG_RENDERER_OPENGL >= 33, true  },
613621      { "EXT_unpack_subimage",                   false,                             true  },
614622
615623      { "GOOGLE_depth_texture",                  false,                             true  },
r245308r245309
667675      { "WEBKIT_WEBGL_compressed_texture_s3tc",  false,                             true  },
668676      { "WEBKIT_WEBGL_depth_texture",            false,                             true  },
669677   };
678   BX_STATIC_ASSERT(Extension::Count == BX_COUNTOF(s_extension) );
670679
671680   static const char* s_ARB_shader_texture_lod[] =
672681   {
r245308r245309
921930      return 0 == err;
922931   }
923932
933   static void getFilters(uint32_t _flags, bool _hasMips, GLenum& _magFilter, GLenum& _minFilter)
934   {
935      const uint32_t mag = (_flags&BGFX_TEXTURE_MAG_MASK)>>BGFX_TEXTURE_MAG_SHIFT;
936      const uint32_t min = (_flags&BGFX_TEXTURE_MIN_MASK)>>BGFX_TEXTURE_MIN_SHIFT;
937      const uint32_t mip = (_flags&BGFX_TEXTURE_MIP_MASK)>>BGFX_TEXTURE_MIP_SHIFT;
938      _magFilter = s_textureFilterMag[mag];
939      _minFilter = s_textureFilterMin[min][_hasMips ? mip+1 : 0];
940   }
941
924942   struct RendererContextGL : public RendererContextI
925943   {
926944      RendererContextGL()
r245308r245309
939957         , m_programBinarySupport(false)
940958         , m_textureSwizzleSupport(false)
941959         , m_depthTextureSupport(false)
960         , m_timerQuerySupport(false)
942961         , m_flip(false)
943962         , m_hash( (BX_PLATFORM_WINDOWS<<1) | BX_ARCH_64BIT)
944963         , m_backBufferFbo(0)
r245308r245309
11001119            }
11011120         }
11021121
1122         // Allow all texture filters.
1123         memset(s_textureFilter, true, BX_COUNTOF(s_textureFilter) );
1124
11031125         bool bc123Supported = 0
11041126            || s_extension[Extension::EXT_texture_compression_s3tc        ].m_supported
11051127            || s_extension[Extension::MOZ_WEBGL_compressed_texture_s3tc   ].m_supported
r245308r245309
11921214            {
11931215               setTextureFormat(TextureFormat::RGBA16F, GL_RGBA, GL_RGBA, GL_HALF_FLOAT);
11941216
1217               if (s_extension[Extension::OES_texture_half_float].m_supported
1218               ||  s_extension[Extension::OES_texture_float     ].m_supported)
1219               {
1220                  // https://www.khronos.org/registry/gles/extensions/OES/OES_texture_float.txt
1221                  // When half/float is available via extensions texture will be marked as
1222                  // incomplete if it uses anything other than nearest filter.
1223                  const bool linear16F = s_extension[Extension::OES_texture_half_float_linear].m_supported;
1224                  const bool linear32F = s_extension[Extension::OES_texture_float_linear     ].m_supported;
1225
1226                  s_textureFilter[TextureFormat::R16F]    = linear16F;
1227                  s_textureFilter[TextureFormat::RG16F]   = linear16F;
1228                  s_textureFilter[TextureFormat::RGBA16F] = linear16F;
1229                  s_textureFilter[TextureFormat::R32F]    = linear32F;
1230                  s_textureFilter[TextureFormat::RG32F]   = linear32F;
1231                  s_textureFilter[TextureFormat::RGBA32F] = linear32F;
1232               }
1233
11951234               if (BX_ENABLED(BX_PLATFORM_IOS) )
11961235               {
11971236                  setTextureFormat(TextureFormat::D16,   GL_DEPTH_COMPONENT, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT);
r245308r245309
13531392            || s_extension[Extension::WEBKIT_WEBGL_depth_texture].m_supported
13541393            ;
13551394
1395         m_timerQuerySupport = 0
1396            || s_extension[Extension::ANGLE_timer_query       ].m_supported
1397            || s_extension[Extension::ARB_timer_query         ].m_supported
1398            || s_extension[Extension::EXT_disjoint_timer_query].m_supported
1399            || s_extension[Extension::EXT_timer_query         ].m_supported
1400            ;
1401
13561402         g_caps.supported |= m_depthTextureSupport
13571403            ? BGFX_CAPS_TEXTURE_COMPARE_LEQUAL
13581404            : 0
r245308r245309
14621508            glInvalidateFramebuffer = stubInvalidateFramebuffer;
14631509         }
14641510
1465         if (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGL) )
1511         if (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGL)
1512         &&  m_timerQuerySupport)
14661513         {
14671514            m_queries.create();
14681515         }
r245308r245309
14921539
14931540         invalidateCache();
14941541
1495         if (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGL) )
1542         if (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGL)
1543         &&  m_timerQuerySupport)
14961544         {
14971545            m_queries.destroy();
14981546         }
r245308r245309
20542102               {
20552103                  sampler = m_samplerStateCache.add(_flags);
20562104
2057                  GL_CHECK(glSamplerParameteri(sampler, GL_TEXTURE_WRAP_S, s_textureAddress[(_flags&BGFX_TEXTURE_U_MASK)>>BGFX_TEXTURE_U_SHIFT]) );
2058                  GL_CHECK(glSamplerParameteri(sampler, GL_TEXTURE_WRAP_T, s_textureAddress[(_flags&BGFX_TEXTURE_V_MASK)>>BGFX_TEXTURE_V_SHIFT]) );
2059                  GL_CHECK(glSamplerParameteri(sampler, GL_TEXTURE_WRAP_R, s_textureAddress[(_flags&BGFX_TEXTURE_W_MASK)>>BGFX_TEXTURE_W_SHIFT]) );
2105                  GL_CHECK(glSamplerParameteri(sampler
2106                     , GL_TEXTURE_WRAP_S
2107                     , s_textureAddress[(_flags&BGFX_TEXTURE_U_MASK)>>BGFX_TEXTURE_U_SHIFT]
2108                     ) );
2109                  GL_CHECK(glSamplerParameteri(sampler
2110                     , GL_TEXTURE_WRAP_T
2111                     , s_textureAddress[(_flags&BGFX_TEXTURE_V_MASK)>>BGFX_TEXTURE_V_SHIFT]
2112                     ) );
2113                  GL_CHECK(glSamplerParameteri(sampler
2114                     , GL_TEXTURE_WRAP_R
2115                     , s_textureAddress[(_flags&BGFX_TEXTURE_W_MASK)>>BGFX_TEXTURE_W_SHIFT]
2116                     ) );
20602117
2061                  const uint32_t mag = (_flags&BGFX_TEXTURE_MAG_MASK)>>BGFX_TEXTURE_MAG_SHIFT;
2062                  const uint32_t min = (_flags&BGFX_TEXTURE_MIN_MASK)>>BGFX_TEXTURE_MIN_SHIFT;
2063                  const uint32_t mip = (_flags&BGFX_TEXTURE_MIP_MASK)>>BGFX_TEXTURE_MIP_SHIFT;
2064                  GLenum minFilter = s_textureFilterMin[min][1 < _numMips ? mip+1 : 0];
2065                  GL_CHECK(glSamplerParameteri(sampler, GL_TEXTURE_MAG_FILTER, s_textureFilterMag[mag]) );
2118                  GLenum minFilter;
2119                  GLenum magFilter;
2120                  getFilters(_flags, 1 < _numMips, magFilter, minFilter);
2121                  GL_CHECK(glSamplerParameteri(sampler, GL_TEXTURE_MAG_FILTER, magFilter) );
20662122                  GL_CHECK(glSamplerParameteri(sampler, GL_TEXTURE_MIN_FILTER, minFilter) );
2123
20672124                  if (0 != (_flags & (BGFX_TEXTURE_MIN_ANISOTROPIC|BGFX_TEXTURE_MAG_ANISOTROPIC) )
20682125                  &&  0.0f < m_maxAnisotropy)
20692126                  {
r245308r245309
25642621      bool m_programBinarySupport;
25652622      bool m_textureSwizzleSupport;
25662623      bool m_depthTextureSupport;
2624      bool m_timerQuerySupport;
25672625      bool m_flip;
25682626
25692627      uint64_t m_hash;
r245308r245309
28692927      m_numPredefined = 0;
28702928       m_numSamplers = 0;
28712929
2872      struct VariableInfo
2873      {
2874         GLenum type;
2875         GLint  loc;
2876         GLint  num;
2877      };
2878      VariableInfo vi;
2879      GLenum props[] = { GL_TYPE, GL_LOCATION, GL_ARRAY_SIZE };
2880
28812930      const bool piqSupported = s_extension[Extension::ARB_program_interface_query].m_supported;
28822931
28832932      BX_TRACE("Uniforms (%d):", activeUniforms);
28842933      for (int32_t ii = 0; ii < activeUniforms; ++ii)
28852934      {
2935         struct VariableInfo
2936         {
2937            GLenum type;
2938            GLint  loc;
2939            GLint  num;
2940         };
2941         VariableInfo vi;
2942         GLenum props[] ={ GL_TYPE, GL_LOCATION, GL_ARRAY_SIZE };
2943
28862944         GLenum gltype;
28872945         GLint num;
28882946         GLint loc;
r245308r245309
32103268         BX_CHECK(0 != m_id, "Failed to generate texture id.");
32113269         GL_CHECK(glBindTexture(_target, m_id) );
32123270
3213         setSamplerState(_flags);
3214
32153271         const TextureFormatInfo& tfi = s_textureFormat[_format];
3216         m_fmt = tfi.m_fmt;
3272         m_fmt = tfi.m_fmt;
32173273         m_type = tfi.m_type;
32183274
32193275         const bool compressed = isCompressed(TextureFormat::Enum(_format) );
r245308r245309
32223278         if (decompress)
32233279         {
32243280            m_textureFormat = (uint8_t)TextureFormat::BGRA8;
3225            const TextureFormatInfo& tfi = s_textureFormat[TextureFormat::BGRA8];
3226            m_fmt = tfi.m_fmt;
3227            m_type = tfi.m_type;
3281            const TextureFormatInfo& tfiBgra8 = s_textureFormat[TextureFormat::BGRA8];
3282            m_fmt  = tfiBgra8.m_fmt;
3283            m_type = tfiBgra8.m_type;
32283284         }
32293285
3286         setSamplerState(_flags);
3287
32303288         if (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGL)
32313289         &&  TextureFormat::BGRA8 == m_textureFormat
32323290         &&  GL_RGBA == m_fmt
r245308r245309
35913649
35923650   void TextureGL::setSamplerState(uint32_t _flags)
35933651   {
3652      if (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGLES < 30)
3653      &&  !s_textureFilter[m_textureFormat])
3654      {
3655         // Force point sampling when texture format doesn't support linear sampling.
3656         _flags &= 0
3657            | BGFX_TEXTURE_MIN_MASK
3658            | BGFX_TEXTURE_MAG_MASK
3659            | BGFX_TEXTURE_MIP_MASK
3660            ;
3661         _flags |= 0
3662            | BGFX_TEXTURE_MIN_POINT
3663            | BGFX_TEXTURE_MAG_POINT
3664            | BGFX_TEXTURE_MIP_POINT
3665            ;
3666      }
3667
35943668      const uint32_t flags = (0 != (BGFX_SAMPLER_DEFAULT_FLAGS & _flags) ? m_flags : _flags) & BGFX_TEXTURE_SAMPLER_BITS_MASK;
35953669      if (flags != m_currentFlags)
35963670      {
r245308r245309
36113685            GL_CHECK(glTexParameteri(target, GL_TEXTURE_WRAP_R, s_textureAddress[(flags&BGFX_TEXTURE_W_MASK)>>BGFX_TEXTURE_W_SHIFT]) );
36123686         }
36133687
3614         const uint32_t mag = (flags&BGFX_TEXTURE_MAG_MASK)>>BGFX_TEXTURE_MAG_SHIFT;
3615         const uint32_t min = (flags&BGFX_TEXTURE_MIN_MASK)>>BGFX_TEXTURE_MIN_SHIFT;
3616         const uint32_t mip = (flags&BGFX_TEXTURE_MIP_MASK)>>BGFX_TEXTURE_MIP_SHIFT;
3617         const GLenum minFilter = s_textureFilterMin[min][1 < numMips ? mip+1 : 0];
3618         GL_CHECK(glTexParameteri(target, GL_TEXTURE_MAG_FILTER, s_textureFilterMag[mag]) );
3688         GLenum magFilter;
3689         GLenum minFilter;
3690         getFilters(flags, 1 < numMips, magFilter, minFilter);
3691         GL_CHECK(glTexParameteri(target, GL_TEXTURE_MAG_FILTER, magFilter) );
36193692         GL_CHECK(glTexParameteri(target, GL_TEXTURE_MIN_FILTER, minFilter) );
36203693         if (0 != (flags & (BGFX_TEXTURE_MIN_ANISOTROPIC|BGFX_TEXTURE_MAG_ANISOTROPIC) )
36213694         &&  0.0f < s_renderGL->m_maxAnisotropy)
r245308r245309
40064079                  {
40074080                     for (uint32_t ii = 0, num = g_caps.maxFBAttachments; ii < num; ++ii)
40084081                     {
4009                        char temp[16];
4010                        bx::snprintf(temp, BX_COUNTOF(temp), "gl_FragData[%d]", ii);
4011                        fragData = bx::uint32_max(fragData, NULL == strstr(code, temp) ? 0 : ii+1);
4082                        char tmpFragData[16];
4083                        bx::snprintf(tmpFragData, BX_COUNTOF(tmpFragData), "gl_FragData[%d]", ii);
4084                        fragData = bx::uint32_max(fragData, NULL == strstr(code, tmpFragData) ? 0 : ii+1);
40124085                     }
40134086
40144087                     BGFX_FATAL(0 != fragData, Fatal::InvalidShader, "Unable to find and patch gl_FragData!");
r245308r245309
42084281         GL_CHECK(glGenFramebuffers(1, &m_fbo[1]) );
42094282         GL_CHECK(glBindFramebuffer(GL_FRAMEBUFFER, m_fbo[1]) );
42104283
4211         for (uint32_t ii = 0, colorIdx = 0; ii < _num; ++ii)
4284         colorIdx = 0;
4285         for (uint32_t ii = 0; ii < _num; ++ii)
42124286         {
42134287            TextureHandle handle = _handles[ii];
42144288            if (isValid(handle) )
r245308r245309
43564430      int64_t captureElapsed = 0;
43574431
43584432      if (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGL)
4359      && (_render->m_debug & (BGFX_DEBUG_IFH|BGFX_DEBUG_STATS) ) )
4433      && (_render->m_debug & (BGFX_DEBUG_IFH|BGFX_DEBUG_STATS) )
4434      &&  m_timerQuerySupport)
43604435      {
43614436         m_queries.begin(0, GL_TIME_ELAPSED);
43624437      }
r245308r245309
44014476               ;
44024477      uint32_t blendFactor = 0;
44034478
4404      const uint64_t pt = _render->m_debug&BGFX_DEBUG_WIREFRAME ? BGFX_STATE_PT_LINES : 0;
4405      uint8_t primIndex = uint8_t(pt>>BGFX_STATE_PT_SHIFT);
4479      uint8_t primIndex;
4480      {
4481         const uint64_t pt = _render->m_debug&BGFX_DEBUG_WIREFRAME ? BGFX_STATE_PT_LINES : 0;
4482         primIndex = uint8_t(pt>>BGFX_STATE_PT_SHIFT);
4483      }
44064484      PrimInfo prim = s_primInfo[primIndex];
44074485
44084486      uint32_t baseVertex = 0;
r245308r245309
44214499      uint32_t statsNumPrimsRendered[BX_COUNTOF(s_primInfo)] = {};
44224500      uint32_t statsNumInstances[BX_COUNTOF(s_primInfo)] = {};
44234501      uint32_t statsNumIndices = 0;
4502      uint32_t statsKeyType[2] = {};
44244503
44254504      if (0 == (_render->m_debug&BGFX_DEBUG_IFH) )
44264505      {
r245308r245309
44354514         for (int32_t item = 0, restartItem = numItems; item < numItems || restartItem < numItems;)
44364515         {
44374516            const bool isCompute   = key.decode(_render->m_sortKeys[item], _render->m_viewRemap);
4517            statsKeyType[isCompute]++;
4518
44384519            const bool viewChanged = 0
44394520               || key.m_view != view
44404521               || item == numItems
r245308r245309
47944875                        && blendIndependentSupported
47954876                        ;
47964877
4797                     const uint32_t blend    = uint32_t( (newFlags&BGFX_STATE_BLEND_MASK)>>BGFX_STATE_BLEND_SHIFT);
4798                     const uint32_t equation = uint32_t( (newFlags&BGFX_STATE_BLEND_EQUATION_MASK)>>BGFX_STATE_BLEND_EQUATION_SHIFT);
4878                     const uint32_t blend  = uint32_t( (newFlags&BGFX_STATE_BLEND_MASK)>>BGFX_STATE_BLEND_SHIFT);
4879                     const uint32_t srcRGB = (blend    )&0xf;
4880                     const uint32_t dstRGB = (blend>> 4)&0xf;
4881                     const uint32_t srcA   = (blend>> 8)&0xf;
4882                     const uint32_t dstA   = (blend>>12)&0xf;
47994883
4800                     const uint32_t srcRGB  = (blend    )&0xf;
4801                     const uint32_t dstRGB  = (blend>> 4)&0xf;
4802                     const uint32_t srcA    = (blend>> 8)&0xf;
4803                     const uint32_t dstA    = (blend>>12)&0xf;
4884                     const uint32_t equ    = uint32_t((newFlags&BGFX_STATE_BLEND_EQUATION_MASK)>>BGFX_STATE_BLEND_EQUATION_SHIFT);
4885                     const uint32_t equRGB = (equ   )&0x7;
4886                     const uint32_t equA   = (equ>>3)&0x7;
48044887
4805                     const uint32_t equRGB = (equation   )&0x7;
4806                     const uint32_t equA   = (equation>>3)&0x7;
4807
48084888                     const uint32_t numRt = getNumRt();
48094889
48104890                     if (!BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGL)
r245308r245309
49855065                        currentVao = id;
49865066                        GL_CHECK(glBindVertexArray(id) );
49875067
4988                        ProgramGL& program = m_program[programIdx];
49895068                        program.add(hash);
49905069
49915070                        if (isValid(draw.m_vertexBuffer) )
r245308r245309
50835162                        baseVertex = draw.m_startVertex;
50845163                        const VertexBufferGL& vb = m_vertexBuffers[draw.m_vertexBuffer.idx];
50855164                        uint16_t decl = !isValid(vb.m_decl) ? draw.m_vertexDecl.idx : vb.m_decl.idx;
5086                        const ProgramGL& program = m_program[programIdx];
50875165                        program.bindAttributes(m_vertexDecls[decl], draw.m_startVertex);
50885166
50895167                        if (isValid(draw.m_instanceDataBuffer) )
r245308r245309
51895267      if (_render->m_debug & (BGFX_DEBUG_IFH|BGFX_DEBUG_STATS) )
51905268      {
51915269         double elapsedGpuMs = 0.0;
5192#if BGFX_CONFIG_RENDERER_OPENGL
5193         m_queries.end(GL_TIME_ELAPSED);
5194         uint64_t elapsedGl = m_queries.getResult(0);
5195         elapsedGpuMs = double(elapsedGl)/1e6;
5196#endif // BGFX_CONFIG_RENDERER_OPENGL
5270         uint64_t elapsedGl  = 0;
5271         if (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGL)
5272         &&  m_timerQuerySupport)
5273         {
5274            m_queries.end(GL_TIME_ELAPSED);
5275            elapsedGl    = m_queries.getResult(0);
5276            elapsedGpuMs = double(elapsedGl)/1e6;
5277         }
51975278
51985279         TextVideoMem& tvm = m_textVideoMem;
51995280
r245308r245309
52365317               );
52375318
52385319            double elapsedCpuMs = double(elapsed)*toMs;
5239            tvm.printf(10, pos++, 0x8e, " Draw calls: %4d / CPU %3.4f [ms] %c GPU %3.4f [ms]"
5320            tvm.printf(10, pos++, 0x8e, "   Submitted: %4d (draw %4d, compute %4d) / CPU %3.4f [ms] %c GPU %3.4f [ms]"
52405321               , _render->m_num
5322               , statsKeyType[0]
5323               , statsKeyType[1]
52415324               , elapsedCpuMs
52425325               , elapsedCpuMs > elapsedGpuMs ? '>' : '<'
52435326               , elapsedGpuMs
52445327               );
52455328            for (uint32_t ii = 0; ii < BX_COUNTOF(s_primInfo); ++ii)
52465329            {
5247               tvm.printf(10, pos++, 0x8e, "   %8s: %7d (#inst: %5d), submitted: %7d"
5330               tvm.printf(10, pos++, 0x8e, "   %9s: %7d (#inst: %5d), submitted: %7d"
52485331                  , s_primName[ii]
52495332                  , statsNumPrimsRendered[ii]
52505333                  , statsNumInstances[ii]
r245308r245309
52575340               tvm.printf(tvm.m_width-27, 0, 0x1f, " [F11 - RenderDoc capture] ");
52585341            }
52595342
5260            tvm.printf(10, pos++, 0x8e, "    Indices: %7d", statsNumIndices);
5261            tvm.printf(10, pos++, 0x8e, "   DVB size: %7d", _render->m_vboffset);
5262            tvm.printf(10, pos++, 0x8e, "   DIB size: %7d", _render->m_iboffset);
5343            tvm.printf(10, pos++, 0x8e, "     Indices: %7d", statsNumIndices);
5344            tvm.printf(10, pos++, 0x8e, "    DVB size: %7d", _render->m_vboffset);
5345            tvm.printf(10, pos++, 0x8e, "    DIB size: %7d", _render->m_iboffset);
52635346
52645347            pos++;
52655348            tvm.printf(10, pos++, 0x8e, " State cache:     ");
trunk/3rdparty/bgfx/src/renderer_gl.h
r245308r245309
623623            BX_MACRO_BLOCK_BEGIN \
624624               /*BX_TRACE(#_call);*/ \
625625               _call; \
626               GLenum err = glGetError(); \
627               _check(0 == err, #_call "; GL error 0x%x: %s", err, glEnumName(err) ); \
628               BX_UNUSED(err); \
626               GLenum gl_err = glGetError(); \
627               _check(0 == gl_err, #_call "; GL error 0x%x: %s", gl_err, glEnumName(gl_err) ); \
628               BX_UNUSED(gl_err); \
629629            BX_MACRO_BLOCK_END
630630
631631#define IGNORE_GL_ERROR_CHECK(...) BX_NOOP()
trunk/3rdparty/bx/include/bx/platform.h
r245308r245309
218218            BX_STRINGIZE(__clang_minor__) "." \
219219            BX_STRINGIZE(__clang_patchlevel__)
220220#elif BX_COMPILER_MSVC
221#   if BX_COMPILER_MSVC >= 1800
221#   if BX_COMPILER_MSVC >= 1900
222#      define BX_COMPILER_NAME "MSVC 14.0"
223#   elif BX_COMPILER_MSVC >= 1800
222224#      define BX_COMPILER_NAME "MSVC 12.0"
223225#   elif BX_COMPILER_MSVC >= 1700
224226#      define BX_COMPILER_NAME "MSVC 11.0"
trunk/3rdparty/bx/include/bx/radixsort.h
r245308r245309
3030         memset(histogram, 0, sizeof(uint16_t)*BX_RADIXSORT_HISTOGRAM_SIZE);
3131
3232         bool sorted = true;
33         uint32_t key = keys[0];
34         uint32_t prevKey = key;
35         for (uint32_t ii = 0; ii < _size; ++ii, prevKey = key)
3633         {
37            key = keys[ii];
38            uint16_t index = (key>>shift)&BX_RADIXSORT_BIT_MASK;
39            ++histogram[index];
40            sorted &= prevKey <= key;
34            uint32_t key = keys[0];
35            uint32_t prevKey = key;
36            for (uint32_t ii = 0; ii < _size; ++ii, prevKey = key)
37            {
38               key = keys[ii];
39               uint16_t index = (key>>shift)&BX_RADIXSORT_BIT_MASK;
40               ++histogram[index];
41               sorted &= prevKey <= key;
42            }
4143         }
4244
4345         if (sorted)
r245308r245309
101103         memset(histogram, 0, sizeof(uint16_t)*BX_RADIXSORT_HISTOGRAM_SIZE);
102104
103105         bool sorted = true;
104         uint64_t key = keys[0];
105         uint64_t prevKey = key;
106         for (uint32_t ii = 0; ii < _size; ++ii, prevKey = key)
107106         {
108            key = keys[ii];
109            uint16_t index = (key>>shift)&BX_RADIXSORT_BIT_MASK;
110            ++histogram[index];
111            sorted &= prevKey <= key;
107            uint64_t key = keys[0];
108            uint64_t prevKey = key;
109            for (uint32_t ii = 0; ii < _size; ++ii, prevKey = key)
110            {
111               key = keys[ii];
112               uint16_t index = (key>>shift)&BX_RADIXSORT_BIT_MASK;
113               ++histogram[index];
114               sorted &= prevKey <= key;
115            }
112116         }
113117
114118         if (sorted)
trunk/3rdparty/bx/scripts/toolchain.lua
r245308r245309
494494      }
495495      buildoptions_cpp {
496496         "-std=c++0x",
497      }     
497      }
498498      links {
499499         "rt",
500500         "dl",
r245308r245309
558558      }
559559      buildoptions {
560560         "-fPIC",
561         "-std=c++0x",
562561         "-no-canonical-prefixes",
563562         "-Wa,--noexecstack",
564563         "-fstack-protector",
r245308r245309
567566         "-Wunused-value",
568567         "-Wundef",
569568      }
569      buildoptions_cpp {
570         "-std=c++0x",
571      }
570572      linkoptions {
571573         "-no-canonical-prefixes",
572574         "-Wl,--no-undefined",
r245308r245309
670672
671673   configuration { "nacl or nacl-arm or pnacl" }
672674      buildoptions {
673         "-std=c++0x",
674675         "-U__STRICT_ANSI__", -- strcasecmp, setenv, unsetenv,...
675676         "-fno-stack-protector",
676677         "-fdiagnostics-show-option",
r245308r245309
679680         "-Wunused-value",
680681         "-Wundef",
681682      }
683      buildoptions_cpp {
684         "-std=c++0x",
685      }
682686      includedirs {
683687         "$(NACL_SDK_ROOT)/include",
684688         path.join(bxDir, "include/compat/nacl"),
r245308r245309
831835      libdirs { path.join(_libDir, "lib/qnx-arm") }
832836--      includedirs { path.join(bxDir, "include/compat/qnx") }
833837      buildoptions {
834         "-std=c++0x",
835838         "-Wno-psabi", -- note: the mangling of 'va_list' has changed in GCC 4.4.0
836839         "-Wunused-value",
837840         "-Wundef",
838841      }
842      buildoptions_cpp {
843         "-std=c++0x",
844      }
839845
840846   configuration { "rpi" }
841847      targetdir (path.join(_buildDir, "rpi/bin"))
trunk/3rdparty/bx/tools/bin/darwin/genie
r245308r245309
Previous 199869 Revisions Next


© 1997-2024 The MAME Team