Previous 199869 Revisions Next

r36820 Tuesday 31st March, 2015 at 06:17:12 UTC by Miodrag Milanović
Update to latest 3rdparty, fixes issues on OpenGL 2.1 for bgfx (nw)
[3rdparty/bgfx].editorconfig
[3rdparty/bgfx/3rdparty/stb]stb_image.c
[3rdparty/bgfx/examples/08-update]update.cpp
[3rdparty/bgfx/examples/12-lod]lod.cpp
[3rdparty/bgfx/examples/13-stencil]stencil.cpp
[3rdparty/bgfx/examples/20-nanovg]blendish.h nanovg.cpp
[3rdparty/bgfx/examples/24-nbody]nbody.cpp
[3rdparty/bgfx/src]renderer_gl.cpp
[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/src/base]api.lua
[3rdparty/genie/src/host]scripts.c
[3rdparty/genie/src/tools]gcc.lua
[scripts]genie.lua

trunk/3rdparty/bgfx/.editorconfig
r245331r245332
88insert_final_newline     = true
99trim_trailing_whitespace = true
1010
11[*.c99.h]
12indent_style = space
13
1114[*.md]
1215trim_trailing_whitespace = false
1316max_line_length = 80
trunk/3rdparty/bgfx/3rdparty/stb/stb_image.c
r245331r245332
187187
188188#ifndef STBI_NO_STDIO
189189
190#if defined(_MSC_VER) && _MSC_VER >= 1400 && !defined(_CRT_SECURE_NO_WARNINGS)
191#define _CRT_SECURE_NO_WARNINGS // suppress warnings about fopen()
192#pragma warning(push)
193#pragma warning(disable:4996)   // suppress even more warnings about fopen()
190#if defined(_MSC_VER) && _MSC_VER >= 1400
191#   if !defined(_CRT_SECURE_NO_WARNINGS)
192#      define _CRT_SECURE_NO_WARNINGS // suppress warnings about fopen()
193#   endif
194#   pragma warning(push)
195#   pragma warning(disable:4996)   // suppress even more warnings about fopen()
196#   pragma warning(disable:4312)   // warning C4312: 'type cast': conversion from 'int' to 'unsigned char *' of greater size
197#   pragma warning(disable:4456)   // warning C4456: declaration of 'k' hides previous local declaration
198#   pragma warning(disable:4457)   // warning C4457: declaration of 'y' hides function parameter
194199#endif
195200#include <stdio.h>
196201#endif // STBI_NO_STDIO
trunk/3rdparty/bgfx/examples/08-update/update.cpp
r245331r245332
292292
293293            for (uint32_t ii = 0, num = bx::uint32_min(10, (uint32_t)quads.size() ); ii < num; ++ii)
294294            {
295               const PackCube& face = quads.front();
296               cube.clear(face);
295               cube.clear(quads.front() );
297296               quads.pop_front();
298297            }
299298         }
trunk/3rdparty/bgfx/examples/12-lod/lod.cpp
r245331r245332
2020   {0,0}, {1,2}, {3,3}, {4,1}, {5,3}, {7,2}, {6,0}, {5,2},
2121   {7,3}, {6,1}, {4,0}, {3,2}, {2,0}, {0,1}, {1,3}, {2,1},
2222   {0,2}, {1,0}, {2,2}, {0,3}, {1,1}, {3,0}, {4,2}, {5,0},
23   {7,1}, {6,3}, {5,1}, {7,0}, {6,2}, {4,3}, {3,1}, {2,3}
23   {7,1}, {6,3}, {5,1}, {7,0}, {6,2}, {4,3}, {3,1}, {2,3},
2424};
2525
2626int _main_(int /*_argc*/, char** /*_argv*/)
r245331r245332
5555
5656   bgfx::TextureHandle textureStipple;
5757
58   const bgfx::Memory* stipple = bgfx::alloc(8*4);
59   memset(stipple->data, 0, stipple->size);
58   const bgfx::Memory* stippleTex = bgfx::alloc(8*4);
59   memset(stippleTex->data, 0, stippleTex->size);
6060
6161   for (uint32_t ii = 0; ii < 32; ++ii)
6262   {
63      stipple->data[knightTour[ii].m_y * 8 + knightTour[ii].m_x] = ii*4;
63      stippleTex->data[knightTour[ii].m_y * 8 + knightTour[ii].m_x] = ii*4;
6464   }
6565
66   textureStipple = bgfx::createTexture2D(8, 4, 1, bgfx::TextureFormat::R8, BGFX_TEXTURE_MAG_POINT|BGFX_TEXTURE_MIN_POINT, stipple);
66   textureStipple = bgfx::createTexture2D(8, 4, 1
67         , bgfx::TextureFormat::R8
68         , BGFX_TEXTURE_MAG_POINT|BGFX_TEXTURE_MIN_POINT
69         , stippleTex
70         );
6771
6872   Mesh* meshTop[3] =
6973   {
trunk/3rdparty/bgfx/examples/13-stencil/stencil.cpp
r245331r245332
13191319                  );
13201320
13211321               // Cubes.
1322               for (uint8_t ii = 0; ii < numCubes; ++ii)
1322               for (uint8_t jj = 0; jj < numCubes; ++jj)
13231323               {
13241324                  cubeMesh.submit(viewId
1325                     , cubeMtx[ii]
1325                     , cubeMtx[jj]
13261326                     , programTextureLightning
13271327                     , s_renderStates[RenderState::ProjectionShadows_DrawDiffuse]
13281328                     , figureTex
trunk/3rdparty/bgfx/examples/20-nanovg/blendish.h
r245331r245332
11091109    #pragma warning (disable: 4100) // Switch off unreferenced formal parameter warnings
11101110    #pragma warning (disable: 4244)
11111111    #pragma warning (disable: 4305)
1112    #pragma warning (disable: 4838) // warning C4838: conversion from 'double' to 'float' requires a narrowing conversion
11121113    #ifdef __cplusplus
11131114    #define BND_INLINE inline
11141115    #else
trunk/3rdparty/bgfx/examples/20-nanovg/nanovg.cpp
r245331r245332
10421042            for (j = 0; j < nglyphs; j++) {
10431043               float x0 = glyphs[j].x;
10441044               float x1 = (j+1 < nglyphs) ? glyphs[j+1].x : x+row->width;
1045               float gx = x0 * 0.3f + x1 * 0.7f;
1046               if (mx >= px && mx < gx)
1045               float tgx = x0 * 0.3f + x1 * 0.7f;
1046               if (mx >= px && mx < tgx)
10471047                  caretx = glyphs[j].x;
1048               px = gx;
1048               px = tgx;
10491049            }
10501050            nvgBeginPath(vg);
10511051            nvgFillColor(vg, nvgRGBA(255,192,0,255));
trunk/3rdparty/bgfx/examples/24-nbody/nbody.cpp
r245331r245332
117117      , 0
118118      );
119119
120   // Imgui.
121   imguiCreate();
120   const bgfx::Caps* caps = bgfx::getCaps();
121   const bool computeSupported = !!(caps->supported & BGFX_CAPS_COMPUTE);
122122
123   bgfx::VertexDecl quadVertexDecl;
124   quadVertexDecl.begin()
125      .add(bgfx::Attrib::Position, 2, bgfx::AttribType::Float)
126      .end();
123   if (computeSupported)
124   {
125      // Imgui.
126      imguiCreate();
127127
128   // Create static vertex buffer.
129   bgfx::VertexBufferHandle vbh = bgfx::createVertexBuffer(
130        // Static data can be passed with bgfx::makeRef
131        bgfx::makeRef(s_quadVertices, sizeof(s_quadVertices) )
132      , quadVertexDecl
133      );
128      bgfx::VertexDecl quadVertexDecl;
129      quadVertexDecl.begin()
130         .add(bgfx::Attrib::Position, 2, bgfx::AttribType::Float)
131         .end();
134132
135   // Create static index buffer.
136   bgfx::IndexBufferHandle ibh = bgfx::createIndexBuffer(
137      // Static data can be passed with bgfx::makeRef
138      bgfx::makeRef(s_quadIndices, sizeof(s_quadIndices) )
139      );
133      // Create static vertex buffer.
134      bgfx::VertexBufferHandle vbh = bgfx::createVertexBuffer(
135            // Static data can be passed with bgfx::makeRef
136            bgfx::makeRef(s_quadVertices, sizeof(s_quadVertices) )
137            , quadVertexDecl
138            );
140139
141   // Create particle program from shaders.
142   bgfx::ProgramHandle particleProgram = loadProgram("vs_particle", "fs_particle");
140      // Create static index buffer.
141      bgfx::IndexBufferHandle ibh = bgfx::createIndexBuffer(
142            // Static data can be passed with bgfx::makeRef
143            bgfx::makeRef(s_quadIndices, sizeof(s_quadIndices) )
144            );
143145
144   // Setup compute buffers
145   bgfx::VertexDecl computeVertexDecl;
146   computeVertexDecl.begin()
147      .add(bgfx::Attrib::TexCoord0, 4, bgfx::AttribType::Float)
148      .end();
146      // Create particle program from shaders.
147      bgfx::ProgramHandle particleProgram = loadProgram("vs_particle", "fs_particle");
149148
150   const uint32_t threadGroupUpdateSize = 512;
151   const uint32_t maxParticleCount = 32 * 1024;
149      // Setup compute buffers
150      bgfx::VertexDecl computeVertexDecl;
151      computeVertexDecl.begin()
152         .add(bgfx::Attrib::TexCoord0, 4, bgfx::AttribType::Float)
153         .end();
152154
153   bgfx::DynamicVertexBufferHandle currPositionBuffer0 = bgfx::createDynamicVertexBuffer(1 << 15, computeVertexDecl, BGFX_BUFFER_COMPUTE_READ_WRITE);
154   bgfx::DynamicVertexBufferHandle currPositionBuffer1 = bgfx::createDynamicVertexBuffer(1 << 15, computeVertexDecl, BGFX_BUFFER_COMPUTE_READ_WRITE);
155   bgfx::DynamicVertexBufferHandle prevPositionBuffer0 = bgfx::createDynamicVertexBuffer(1 << 15, computeVertexDecl, BGFX_BUFFER_COMPUTE_READ_WRITE);
156   bgfx::DynamicVertexBufferHandle prevPositionBuffer1 = bgfx::createDynamicVertexBuffer(1 << 15, computeVertexDecl, BGFX_BUFFER_COMPUTE_READ_WRITE);
155      const uint32_t threadGroupUpdateSize = 512;
156      const uint32_t maxParticleCount = 32 * 1024;
157157
158   bgfx::UniformHandle u_params = bgfx::createUniform("u_params", bgfx::UniformType::Uniform4fv, 3);
158      bgfx::DynamicVertexBufferHandle currPositionBuffer0 = bgfx::createDynamicVertexBuffer(1 << 15, computeVertexDecl, BGFX_BUFFER_COMPUTE_READ_WRITE);
159      bgfx::DynamicVertexBufferHandle currPositionBuffer1 = bgfx::createDynamicVertexBuffer(1 << 15, computeVertexDecl, BGFX_BUFFER_COMPUTE_READ_WRITE);
160      bgfx::DynamicVertexBufferHandle prevPositionBuffer0 = bgfx::createDynamicVertexBuffer(1 << 15, computeVertexDecl, BGFX_BUFFER_COMPUTE_READ_WRITE);
161      bgfx::DynamicVertexBufferHandle prevPositionBuffer1 = bgfx::createDynamicVertexBuffer(1 << 15, computeVertexDecl, BGFX_BUFFER_COMPUTE_READ_WRITE);
159162
160   bgfx::ShaderHandle  initInstancesShader    = loadShader("cs_init_instances");
161   bgfx::ProgramHandle initInstancesProgram   = bgfx::createProgram(initInstancesShader, true);
162   bgfx::ShaderHandle  updateInstancesShader  = loadShader("cs_update_instances");
163   bgfx::ProgramHandle updateInstancesProgram = bgfx::createProgram(updateInstancesShader, true);
163      bgfx::UniformHandle u_params = bgfx::createUniform("u_params", bgfx::UniformType::Uniform4fv, 3);
164164
165   u_paramsDataStruct u_paramsData;
166   InitializeParams(0, &u_paramsData);
165      bgfx::ShaderHandle  initInstancesShader    = loadShader("cs_init_instances");
166      bgfx::ProgramHandle initInstancesProgram   = bgfx::createProgram(initInstancesShader, true);
167      bgfx::ShaderHandle  updateInstancesShader  = loadShader("cs_update_instances");
168      bgfx::ProgramHandle updateInstancesProgram = bgfx::createProgram(updateInstancesShader, true);
167169
168   bgfx::setUniform(u_params, &u_paramsData, 3);
169   bgfx::setBuffer(0, prevPositionBuffer0, bgfx::Access::Write);
170   bgfx::setBuffer(1, currPositionBuffer0, bgfx::Access::Write);
171   bgfx::dispatch(0, initInstancesProgram, maxParticleCount / threadGroupUpdateSize, 1, 1);
170      u_paramsDataStruct u_paramsData;
171      InitializeParams(0, &u_paramsData);
172172
173   float view[16];
174   float initialPos[3] = { 0.0f, 0.0f, -45.0f };
175   cameraCreate();
176   cameraSetPosition(initialPos);
177   cameraSetVerticalAngle(0.0f);
178   cameraGetViewMtx(view);
173      bgfx::setUniform(u_params, &u_paramsData, 3);
174      bgfx::setBuffer(0, prevPositionBuffer0, bgfx::Access::Write);
175      bgfx::setBuffer(1, currPositionBuffer0, bgfx::Access::Write);
176      bgfx::dispatch(0, initInstancesProgram, maxParticleCount / threadGroupUpdateSize, 1, 1);
179177
180   int32_t scrollArea = 0;
178      float view[16];
179      float initialPos[3] = { 0.0f, 0.0f, -45.0f };
180      cameraCreate();
181      cameraSetPosition(initialPos);
182      cameraSetVerticalAngle(0.0f);
183      cameraGetViewMtx(view);
181184
182   entry::MouseState mouseState;
183   while (!entry::processEvents(width, height, debug, reset, &mouseState) )
184   {
185      int64_t now = bx::getHPCounter();
186      static int64_t last = now;
187      const int64_t frameTime = now - last;
188      last = now;
189      const double freq = double(bx::getHPFrequency() );
190      const float deltaTime = float(frameTime/freq);
185      int32_t scrollArea = 0;
191186
192      // Set view 0 default viewport.
193      bgfx::setViewRect(0, 0, 0, width, height);
187      entry::MouseState mouseState;
188      while (!entry::processEvents(width, height, debug, reset, &mouseState) )
189      {
190         int64_t now = bx::getHPCounter();
191         static int64_t last = now;
192         const int64_t frameTime = now - last;
193         last = now;
194         const double freq = double(bx::getHPFrequency() );
195         const float deltaTime = float(frameTime/freq);
194196
195      // Use debug font to print information about this example.
196      bgfx::dbgTextClear();
197      bgfx::dbgTextPrintf(0, 1, 0x4f, "bgfx/examples/24-nbody");
198      bgfx::dbgTextPrintf(0, 2, 0x6f, "Description: N-body simulation with compute shaders using buffers.");
197         // Set view 0 default viewport.
198         bgfx::setViewRect(0, 0, 0, width, height);
199199
200      imguiBeginFrame(mouseState.m_mx
201         , mouseState.m_my
202         , (mouseState.m_buttons[entry::MouseButton::Left  ] ? IMGUI_MBUT_LEFT  : 0)
203         | (mouseState.m_buttons[entry::MouseButton::Right ] ? IMGUI_MBUT_RIGHT : 0)
204         , 0
205         , width
206         , height
207         );
208      imguiBeginScrollArea("Settings", width - width / 4 - 10, 10, width / 4, 500, &scrollArea);
209      imguiSlider("Random seed", u_paramsData.baseSeed, 0, 100);
210      int32_t shape = imguiChoose(u_paramsData.initialShape, "Point", "Sphere", "Box", "Donut");
211      imguiSlider("Initial speed", u_paramsData.initialSpeed, 0.0f, 300.0f, 0.1f);
212      bool reset = imguiButton("Reset");
213      imguiSeparatorLine();
214      imguiSlider("Particle count (x512)", u_paramsData.dispatchSize, 1, 64);
215      imguiSlider("Gravity", u_paramsData.gravity, 0.0f, 0.3f, 0.001f);
216      imguiSlider("Damping", u_paramsData.damping, 0.0f, 1.0f, 0.01f);
217      imguiSlider("Max acceleration", u_paramsData.maxAccel, 0.0f, 100.0f, 0.01f);
218      imguiSlider("Time step", u_paramsData.timeStep, 0.0f, 0.02f, 0.0001f);
219      imguiSeparatorLine();
220      imguiSlider("Particle intensity", u_paramsData.particleIntensity, 0.0f, 1.0f, 0.001f);
221      imguiSlider("Particle size", u_paramsData.particleSize, 0.0f, 1.0f, 0.001f);
222      imguiSlider("Particle power", u_paramsData.particlePower, 0.001f, 16.0f, 0.01f);
223      imguiEndScrollArea();
224      imguiEndFrame();
200         // Use debug font to print information about this example.
201         bgfx::dbgTextClear();
202         bgfx::dbgTextPrintf(0, 1, 0x4f, "bgfx/examples/24-nbody");
203         bgfx::dbgTextPrintf(0, 2, 0x6f, "Description: N-body simulation with compute shaders using buffers.");
225204
226      // Modify parameters and reset if shape is changed
227      if (shape != u_paramsData.initialShape)
228      {
229         reset = true;
230         InitializeParams(shape, &u_paramsData);
231      }
205         imguiBeginFrame(mouseState.m_mx
206               , mouseState.m_my
207               , (mouseState.m_buttons[entry::MouseButton::Left  ] ? IMGUI_MBUT_LEFT  : 0)
208               | (mouseState.m_buttons[entry::MouseButton::Right ] ? IMGUI_MBUT_RIGHT : 0)
209               , 0
210               , width
211               , height
212               );
213         imguiBeginScrollArea("Settings", width - width / 4 - 10, 10, width / 4, 500, &scrollArea);
214         imguiSlider("Random seed", u_paramsData.baseSeed, 0, 100);
215         int32_t shape = imguiChoose(u_paramsData.initialShape, "Point", "Sphere", "Box", "Donut");
216         imguiSlider("Initial speed", u_paramsData.initialSpeed, 0.0f, 300.0f, 0.1f);
217         bool defaults = imguiButton("Reset");
218         imguiSeparatorLine();
219         imguiSlider("Particle count (x512)", u_paramsData.dispatchSize, 1, 64);
220         imguiSlider("Gravity", u_paramsData.gravity, 0.0f, 0.3f, 0.001f);
221         imguiSlider("Damping", u_paramsData.damping, 0.0f, 1.0f, 0.01f);
222         imguiSlider("Max acceleration", u_paramsData.maxAccel, 0.0f, 100.0f, 0.01f);
223         imguiSlider("Time step", u_paramsData.timeStep, 0.0f, 0.02f, 0.0001f);
224         imguiSeparatorLine();
225         imguiSlider("Particle intensity", u_paramsData.particleIntensity, 0.0f, 1.0f, 0.001f);
226         imguiSlider("Particle size", u_paramsData.particleSize, 0.0f, 1.0f, 0.001f);
227         imguiSlider("Particle power", u_paramsData.particlePower, 0.001f, 16.0f, 0.01f);
228         imguiEndScrollArea();
229         imguiEndFrame();
232230
233      if (reset)
234      {
235         bgfx::setBuffer(0, prevPositionBuffer0, bgfx::Access::Write);
236         bgfx::setBuffer(1, currPositionBuffer0, bgfx::Access::Write);
231         // Modify parameters and reset if shape is changed
232         if (shape != u_paramsData.initialShape)
233         {
234            defaults = true;
235            InitializeParams(shape, &u_paramsData);
236         }
237
238         if (defaults)
239         {
240            bgfx::setBuffer(0, prevPositionBuffer0, bgfx::Access::Write);
241            bgfx::setBuffer(1, currPositionBuffer0, bgfx::Access::Write);
242            bgfx::setUniform(u_params, &u_paramsData, 3);
243            bgfx::dispatch(0, initInstancesProgram, maxParticleCount / threadGroupUpdateSize, 1, 1);
244         }
245
246         bgfx::setBuffer(0, prevPositionBuffer0, bgfx::Access::Read);
247         bgfx::setBuffer(1, currPositionBuffer0, bgfx::Access::Read);
248         bgfx::setBuffer(2, prevPositionBuffer1, bgfx::Access::Write);
249         bgfx::setBuffer(3, currPositionBuffer1, bgfx::Access::Write);
237250         bgfx::setUniform(u_params, &u_paramsData, 3);
238         bgfx::dispatch(0, initInstancesProgram, maxParticleCount / threadGroupUpdateSize, 1, 1);
239      }
251         bgfx::dispatch(0, updateInstancesProgram, u_paramsData.dispatchSize, 1, 1);
240252
241      bgfx::setBuffer(0, prevPositionBuffer0, bgfx::Access::Read);
242      bgfx::setBuffer(1, currPositionBuffer0, bgfx::Access::Read);
243      bgfx::setBuffer(2, prevPositionBuffer1, bgfx::Access::Write);
244      bgfx::setBuffer(3, currPositionBuffer1, bgfx::Access::Write);
245      bgfx::setUniform(u_params, &u_paramsData, 3);
246      bgfx::dispatch(0, updateInstancesProgram, u_paramsData.dispatchSize, 1, 1);
253         bx::xchg(currPositionBuffer0, currPositionBuffer1);
254         bx::xchg(prevPositionBuffer0, prevPositionBuffer1);
247255
248      bx::xchg(currPositionBuffer0, currPositionBuffer1);
249      bx::xchg(prevPositionBuffer0, prevPositionBuffer1);
256         // Update camera.
257         cameraUpdate(deltaTime, mouseState);
258         cameraGetViewMtx(view);
250259
251      float view[16];
260         // Set view and projection matrix for view 0.
261         const bgfx::HMD* hmd = bgfx::getHMD();
262         if (NULL != hmd)
263         {
264            float viewHead[16];
265            float eye[3] = {};
266            bx::mtxQuatTranslationHMD(viewHead, hmd->eye[0].rotation, eye);
252267
253      // Update camera.
254      cameraUpdate(deltaTime, mouseState);
255      cameraGetViewMtx(view);
268            float tmp[16];
269            bx::mtxMul(tmp, view, viewHead);
256270
257      // Set view and projection matrix for view 0.
258      const bgfx::HMD* hmd = bgfx::getHMD();
259      if (NULL != hmd)
260      {
261         float viewHead[16];
262         float eye[3] = {};
263         bx::mtxQuatTranslationHMD(viewHead, hmd->eye[0].rotation, eye);
271            float proj[16];
272            bx::mtxProj(proj, hmd->eye[0].fov, 0.1f, 10000.0f);
264273
265         float tmp[16];
266         bx::mtxMul(tmp, view, viewHead);
274            bgfx::setViewTransform(0, tmp, proj);
267275
268         float proj[16];
269         bx::mtxProj(proj, hmd->eye[0].fov, 0.1f, 10000.0f);
276            // Set view 0 default viewport.
277            //
278            // Use HMD's width/height since HMD's internal frame buffer size
279            // might be much larger than window size.
280            bgfx::setViewRect(0, 0, 0, hmd->width, hmd->height);
281         }
282         else
283         {
284            float proj[16];
285            bx::mtxProj(proj, 90.0f, float(width)/float(height), 0.1f, 10000.0f);
286            bgfx::setViewTransform(0, view, proj);
270287
271         bgfx::setViewTransform(0, tmp, proj);
288            // Set view 0 default viewport.
289            bgfx::setViewRect(0, 0, 0, width, height);
290         }
272291
273         // Set view 0 default viewport.
274         //
275         // Use HMD's width/height since HMD's internal frame buffer size
276         // might be much larger than window size.
277         bgfx::setViewRect(0, 0, 0, hmd->width, hmd->height);
292         // Set vertex and fragment shaders.
293         bgfx::setProgram(particleProgram);
294
295         // Set vertex and index buffer.
296         bgfx::setVertexBuffer(vbh);
297         bgfx::setIndexBuffer(ibh);
298         bgfx::setInstanceDataBuffer(currPositionBuffer0, 0, u_paramsData.dispatchSize * threadGroupUpdateSize);
299
300         // Set render states.
301         bgfx::setState(0
302               | BGFX_STATE_RGB_WRITE
303               | BGFX_STATE_BLEND_ADD
304               | BGFX_STATE_DEPTH_TEST_ALWAYS
305               );
306
307         // Submit primitive for rendering to view 0.
308         bgfx::submit(0);
309
310         // Advance to next frame. Rendering thread will be kicked to
311         // process submitted rendering primitives.
312         bgfx::frame();
278313      }
279      else
314
315      // Cleanup.
316      cameraDestroy();
317      imguiDestroy();
318      bgfx::destroyUniform(u_params);
319      bgfx::destroyDynamicVertexBuffer(currPositionBuffer0);
320      bgfx::destroyDynamicVertexBuffer(currPositionBuffer1);
321      bgfx::destroyDynamicVertexBuffer(prevPositionBuffer0);
322      bgfx::destroyDynamicVertexBuffer(prevPositionBuffer1);
323      bgfx::destroyProgram(updateInstancesProgram);
324      bgfx::destroyProgram(initInstancesProgram);
325      bgfx::destroyIndexBuffer(ibh);
326      bgfx::destroyVertexBuffer(vbh);
327      bgfx::destroyProgram(particleProgram);
328   }
329   else
330   {
331      int64_t timeOffset = bx::getHPCounter();
332
333      entry::MouseState mouseState;
334      while (!entry::processEvents(width, height, debug, reset, &mouseState) )
280335      {
281         float proj[16];
282         bx::mtxProj(proj, 90.0f, float(width)/float(height), 0.1f, 10000.0f);
283         bgfx::setViewTransform(0, view, proj);
336         int64_t now = bx::getHPCounter();
337         float time = (float)( (now - timeOffset)/double(bx::getHPFrequency() ) );
284338
285         // Set view 0 default viewport.
286339         bgfx::setViewRect(0, 0, 0, width, height);
287      }
288340
289      // Set vertex and fragment shaders.
290      bgfx::setProgram(particleProgram);
341         bgfx::dbgTextClear();
342         bgfx::dbgTextPrintf(0, 1, 0x4f, "bgfx/examples/24-nbody");
343         bgfx::dbgTextPrintf(0, 2, 0x6f, "Description: N-body simulation with compute shaders using buffers.");
291344
292      // Set vertex and index buffer.
293      bgfx::setVertexBuffer(vbh);
294      bgfx::setIndexBuffer(ibh);
295      bgfx::setInstanceDataBuffer(currPositionBuffer0, 0, u_paramsData.dispatchSize * threadGroupUpdateSize);
345         bool blink = uint32_t(time*3.0f)&1;
346         bgfx::dbgTextPrintf(0, 5, blink ? 0x1f : 0x01, " Compute is not supported by GPU. ");
296347
297      // Set render states.
298      bgfx::setState(0
299         | BGFX_STATE_RGB_WRITE
300         | BGFX_STATE_BLEND_ADD
301         | BGFX_STATE_DEPTH_TEST_ALWAYS
302         );
303
304      // Submit primitive for rendering to view 0.
305      bgfx::submit(0);
306
307      // Advance to next frame. Rendering thread will be kicked to
308      // process submitted rendering primitives.
309      bgfx::frame();
348         bgfx::submit(0);
349         bgfx::frame();
350      }
310351   }
311352
312   // Cleanup.
313   cameraDestroy();
314   imguiDestroy();
315   bgfx::destroyUniform(u_params);
316   bgfx::destroyDynamicVertexBuffer(currPositionBuffer0);
317   bgfx::destroyDynamicVertexBuffer(currPositionBuffer1);
318   bgfx::destroyDynamicVertexBuffer(prevPositionBuffer0);
319   bgfx::destroyDynamicVertexBuffer(prevPositionBuffer1);
320   bgfx::destroyProgram(updateInstancesProgram);
321   bgfx::destroyProgram(initInstancesProgram);
322   bgfx::destroyIndexBuffer(ibh);
323   bgfx::destroyVertexBuffer(vbh);
324   bgfx::destroyProgram(particleProgram);
325
326353   // Shutdown bgfx.
327354   bgfx::shutdown();
328355
trunk/3rdparty/bgfx/src/renderer_gl.cpp
r245331r245332
13521352
13531353         if (BX_ENABLED(BX_PLATFORM_NACL) )
13541354         {
1355            m_vaoSupport &= NULL != glGenVertexArrays
1355            m_vaoSupport &= true
1356               && NULL != glGenVertexArrays
13561357               && NULL != glDeleteVertexArrays
13571358               && NULL != glBindVertexArray
13581359               ;
r245331r245332
13991400            || s_extension[Extension::EXT_timer_query         ].m_supported
14001401            ;
14011402
1403         m_timerQuerySupport &= NULL != glGetQueryObjectui64v;
1404
14021405         g_caps.supported |= m_depthTextureSupport
14031406            ? BGFX_CAPS_TEXTURE_COMPARE_LEQUAL
14041407            : 0
trunk/3rdparty/bx/scripts/toolchain.lua
r245331r245332
4040      allowed = {
4141         { "vs2012-clang",  "Clang 3.6"         },
4242         { "vs2013-clang",  "Clang 3.6"         },
43         { "vs2012-xp",       "Visual Studio 2012 targeting XP" },
44         { "vs2013-xp",       "Visual Studio 2013 targeting XP" },
43         { "vs2012-xp",     "Visual Studio 2012 targeting XP" },
44         { "vs2013-xp",     "Visual Studio 2013 targeting XP" },
45         { "vs2015-xp",     "Visual Studio 2015 targeting XP" },
4546         { "winphone8",     "Windows Phone 8.0" },
4647         { "winphone81",    "Windows Phone 8.1" },
4748      },
r245331r245332
110111         premake.gcc.cxx = "$(ANDROID_NDK_ARM)/bin/arm-linux-androideabi-g++"
111112         premake.gcc.ar  = "$(ANDROID_NDK_ARM)/bin/arm-linux-androideabi-ar"
112113         location (path.join(_buildDir, "projects", _ACTION .. "-android-arm"))
113      end
114114
115      if "android-mips" == _OPTIONS["gcc"] then
115      elseif "android-mips" == _OPTIONS["gcc"] then
116116
117117         if not os.getenv("ANDROID_NDK_MIPS") or not os.getenv("ANDROID_NDK_ROOT") then
118118            print("Set ANDROID_NDK_MIPS and ANDROID_NDK_ROOT envrionment variables.")
r245331r245332
122122         premake.gcc.cxx = "$(ANDROID_NDK_MIPS)/bin/mipsel-linux-android-g++"
123123         premake.gcc.ar  = "$(ANDROID_NDK_MIPS)/bin/mipsel-linux-android-ar"
124124         location (path.join(_buildDir, "projects", _ACTION .. "-android-mips"))
125      end
126125
127      if "android-x86" == _OPTIONS["gcc"] then
126      elseif "android-x86" == _OPTIONS["gcc"] then
128127
129128         if not os.getenv("ANDROID_NDK_X86") or not os.getenv("ANDROID_NDK_ROOT") then
130129            print("Set ANDROID_NDK_X86 and ANDROID_NDK_ROOT envrionment variables.")
r245331r245332
134133         premake.gcc.cxx = "$(ANDROID_NDK_X86)/bin/i686-linux-android-g++"
135134         premake.gcc.ar  = "$(ANDROID_NDK_X86)/bin/i686-linux-android-ar"
136135         location (path.join(_buildDir, "projects", _ACTION .. "-android-x86"))
137      end
138136
139      if "asmjs" == _OPTIONS["gcc"] then
137      elseif "asmjs" == _OPTIONS["gcc"] then
140138
141139         if not os.getenv("EMSCRIPTEN") then
142140            print("Set EMSCRIPTEN enviroment variables.")
r245331r245332
147145         premake.gcc.ar   = "$(EMSCRIPTEN)/emar"
148146         premake.gcc.llvm = true
149147         location (path.join(_buildDir, "projects", _ACTION .. "-asmjs"))
150      end
151148
152      if "freebsd" == _OPTIONS["gcc"] then
149      elseif "freebsd" == _OPTIONS["gcc"] then
153150         location (path.join(_buildDir, "projects", _ACTION .. "-freebsd"))
154      end
155151
156      if "ios-arm" == _OPTIONS["gcc"] then
152      elseif "ios-arm" == _OPTIONS["gcc"] then
157153         premake.gcc.cc  = "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang"
158154         premake.gcc.cxx = "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++"
159155         premake.gcc.ar  = "ar"
160156         location (path.join(_buildDir, "projects", _ACTION .. "-ios-arm"))
161      end
162157
163      if "ios-simulator" == _OPTIONS["gcc"] then
158      elseif "ios-simulator" == _OPTIONS["gcc"] then
164159         premake.gcc.cc  = "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang"
165160         premake.gcc.cxx = "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++"
166161         premake.gcc.ar  = "ar"
167162         location (path.join(_buildDir, "projects", _ACTION .. "-ios-simulator"))
168      end
169163
170      if "linux-gcc" == _OPTIONS["gcc"] then
164      elseif "linux-gcc" == _OPTIONS["gcc"] then
171165         location (path.join(_buildDir, "projects", _ACTION .. "-linux"))
172      end
173166
174      if "linux-clang" == _OPTIONS["gcc"] then
167      elseif "linux-clang" == _OPTIONS["gcc"] then
175168         premake.gcc.cc  = "clang"
176169         premake.gcc.cxx = "clang++"
177170         premake.gcc.ar  = "ar"
178171         location (path.join(_buildDir, "projects", _ACTION .. "-linux-clang"))
179      end
180172
181      if "mingw-gcc" == _OPTIONS["gcc"] then
173      elseif "mingw-gcc" == _OPTIONS["gcc"] then
182174         premake.gcc.cc  = "$(MINGW)/bin/x86_64-w64-mingw32-gcc"
183175         premake.gcc.cxx = "$(MINGW)/bin/x86_64-w64-mingw32-g++"
184176         premake.gcc.ar  = "$(MINGW)/bin/ar"
185177         location (path.join(_buildDir, "projects", _ACTION .. "-mingw-gcc"))
186      end
187178
188      if "mingw-clang" == _OPTIONS["gcc"] then
179      elseif "mingw-clang" == _OPTIONS["gcc"] then
189180         premake.gcc.cc   = "$(CLANG)/bin/clang"
190181         premake.gcc.cxx  = "$(CLANG)/bin/clang++"
191182         premake.gcc.ar   = "$(MINGW)/bin/ar"
192183--         premake.gcc.ar   = "$(CLANG)/bin/llvm-ar"
193184--         premake.gcc.llvm = true
194185         location (path.join(_buildDir, "projects", _ACTION .. "-mingw-clang"))
195      end
196186
197      if "nacl" == _OPTIONS["gcc"] then
187      elseif "nacl" == _OPTIONS["gcc"] then
198188
199189         if not os.getenv("NACL_SDK_ROOT") then
200190            print("Set NACL_SDK_ROOT enviroment variables.")
r245331r245332
211201         premake.gcc.cxx = naclToolchain .. "g++"
212202         premake.gcc.ar  = naclToolchain .. "ar"
213203         location (path.join(_buildDir, "projects", _ACTION .. "-nacl"))
214      end
215204
216      if "nacl-arm" == _OPTIONS["gcc"] then
205      elseif "nacl-arm" == _OPTIONS["gcc"] then
217206
218207         if not os.getenv("NACL_SDK_ROOT") then
219208            print("Set NACL_SDK_ROOT enviroment variables.")
r245331r245332
230219         premake.gcc.cxx = naclToolchain .. "g++"
231220         premake.gcc.ar  = naclToolchain .. "ar"
232221         location (path.join(_buildDir, "projects", _ACTION .. "-nacl-arm"))
233      end
234222
235      if "osx" == _OPTIONS["gcc"] then
223      elseif "osx" == _OPTIONS["gcc"] then
224
236225         if os.is("linux") then
237226            local osxToolchain = "x86_64-apple-darwin13-"
238227            premake.gcc.cc  = osxToolchain .. "clang"
r245331r245332
240229            premake.gcc.ar  = osxToolchain .. "ar"
241230         end
242231         location (path.join(_buildDir, "projects", _ACTION .. "-osx"))
243      end
244232
245      if "pnacl" == _OPTIONS["gcc"] then
233      elseif "pnacl" == _OPTIONS["gcc"] then
246234
247235         if not os.getenv("NACL_SDK_ROOT") then
248236            print("Set NACL_SDK_ROOT enviroment variables.")
r245331r245332
259247         premake.gcc.cxx = naclToolchain .. "clang++"
260248         premake.gcc.ar  = naclToolchain .. "ar"
261249         location (path.join(_buildDir, "projects", _ACTION .. "-pnacl"))
262      end
263250
264      if "qnx-arm" == _OPTIONS["gcc"] then
251      elseif "qnx-arm" == _OPTIONS["gcc"] then
265252
266253         if not os.getenv("QNX_HOST") then
267254            print("Set QNX_HOST enviroment variables.")
r245331r245332
271258         premake.gcc.cxx = "$(QNX_HOST)/usr/bin/arm-unknown-nto-qnx8.0.0eabi-g++"
272259         premake.gcc.ar  = "$(QNX_HOST)/usr/bin/arm-unknown-nto-qnx8.0.0eabi-ar"
273260         location (path.join(_buildDir, "projects", _ACTION .. "-qnx-arm"))
274      end
275261
276      if "rpi" == _OPTIONS["gcc"] then
262      elseif "rpi" == _OPTIONS["gcc"] then
277263         location (path.join(_buildDir, "projects", _ACTION .. "-rpi"))
278264      end
279265   elseif _ACTION == "vs2012" or _ACTION == "vs2013" or _ACTION == "vs2015" then
r245331r245332
281267      if (_ACTION .. "-clang") == _OPTIONS["vs"] then
282268         premake.vstudio.toolset = ("LLVM-" .. _ACTION)
283269         location (path.join(_buildDir, "projects", _ACTION .. "-clang"))
284      end
285270
286      if "winphone8" == _OPTIONS["vs"] then
271      elseif "winphone8" == _OPTIONS["vs"] then
287272         premake.vstudio.toolset = "v110_wp80"
288273         location (path.join(_buildDir, "projects", _ACTION .. "-winphone8"))
289      end
290274
291      if "winphone81" == _OPTIONS["vs"] then
275      elseif "winphone81" == _OPTIONS["vs"] then
292276         premake.vstudio.toolset = "v120_wp81"
293277         platforms { "ARM" }
294278         location (path.join(_buildDir, "projects", _ACTION .. "-winphone81"))
295      end
296279
297      if ("vs2012-xp") == _OPTIONS["vs"] then
280      elseif ("vs2012-xp") == _OPTIONS["vs"] then
298281         premake.vstudio.toolset = ("v110_xp")
299282         location (path.join(_buildDir, "projects", _ACTION .. "-xp"))
300      end
301283
302      if ("vs2013-xp") == _OPTIONS["vs"] then
284      elseif ("vs2013-xp") == _OPTIONS["vs"] then
303285         premake.vstudio.toolset = ("v120_xp")
304286         location (path.join(_buildDir, "projects", _ACTION .. "-xp"))
287
288      elseif ("vs2015-xp") == _OPTIONS["vs"] then
289         premake.vstudio.toolset = ("v140_xp")
290         location (path.join(_buildDir, "projects", _ACTION .. "-xp"))
305291      end
306292
307293   elseif _ACTION == "xcode4" then
r245331r245332
309295      if "osx" == _OPTIONS["xcode"] then
310296         premake.xcode.toolset = "macosx"
311297         location (path.join(_buildDir, "projects", _ACTION .. "-osx"))
312      end
313      if "ios" == _OPTIONS["xcode"] then
298
299      elseif "ios" == _OPTIONS["xcode"] then
314300         premake.xcode.toolset = "iphoneos"
315301         location (path.join(_buildDir, "projects", _ACTION .. "-ios"))
316302      end
r245331r245332
760746   configuration { "osx", "x32" }
761747      targetdir (path.join(_buildDir, "osx32_clang/bin"))
762748      objdir (path.join(_buildDir, "osx32_clang/obj"))
763      libdirs { path.join(_libDir, "lib/osx32_clang") }
749      --libdirs { path.join(_libDir, "lib/osx32_clang") }
764750      buildoptions {
765751         "-m32",
766752      }
r245331r245332
768754   configuration { "osx", "x64" }
769755      targetdir (path.join(_buildDir, "osx64_clang/bin"))
770756      objdir (path.join(_buildDir, "osx64_clang/obj"))
771      libdirs { path.join(_libDir, "lib/osx64_clang") }
757      --libdirs { path.join(_libDir, "lib/osx64_clang") }
772758      buildoptions {
773759         "-m64",
774760      }
trunk/3rdparty/bx/tools/bin/darwin/genie
r245331r245332
Previous 199869 Revisions Next


© 1997-2024 The MAME Team