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] | |
[3rdparty/genie/src/host/lua-5.2.3/doc] | |
[3rdparty/genie/src/host/lua-5.2.3/src] | |
[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* |
r245308 | r245309 | |
---|---|---|
92 | 92 | } else if (a < (1.0-a1)) { // a1 <= a <= 1-a1 |
93 | 93 | df = (0.5f-a)*gx; |
94 | 94 | } 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)); | |
96 | 96 | } |
97 | 97 | } |
98 | 98 | return df; |
r245308 | r245309 | |
---|---|---|
592 | 592 | float sphere[numSpheres][4]; |
593 | 593 | for (uint32_t ii = 0; ii < numSpheres; ++ii) |
594 | 594 | { |
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); | |
599 | 599 | } |
600 | 600 | |
601 | 601 | profUpdate = bx::getHPCounter(); |
r245308 | r245309 | |
---|---|---|
182 | 182 | mtx[14] = 0.0f; |
183 | 183 | |
184 | 184 | 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; | |
188 | 188 | color[3] = 1.0f; |
189 | 189 | |
190 | 190 | data += instanceStride; |
r245308 | r245309 | |
---|---|---|
192 | 192 | |
193 | 193 | float at[3] = { 0.0f, 0.0f, 0.0f }; |
194 | 194 | float eye[3] = { 0.0f, 0.0f, -7.0f }; |
195 | ||
195 | ||
196 | 196 | // Set view and projection matrix for view 0. |
197 | 197 | const bgfx::HMD* hmd = bgfx::getHMD(); |
198 | 198 | if (NULL != hmd) |
r245308 | r245309 | |
227 | 227 | float lightPosRadius[4][4]; |
228 | 228 | for (uint32_t ii = 0; ii < numLights; ++ii) |
229 | 229 | { |
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; | |
232 | 232 | lightPosRadius[ii][2] = -2.5f; |
233 | 233 | lightPosRadius[ii][3] = 3.0f; |
234 | 234 | } |
r245308 | r245309 | |
338 | 338 | } |
339 | 339 | } |
340 | 340 | |
341 | // Advance to next frame. Rendering thread will be kicked to | |
341 | // Advance to next frame. Rendering thread will be kicked to | |
342 | 342 | // process submitted rendering primitives. |
343 | 343 | bgfx::frame(); |
344 | 344 | } |
r245308 | r245309 | |
---|---|---|
372 | 372 | |
373 | 373 | bgfx::init( |
374 | 374 | renderers[bx::getHPCounter() % numRenderers] /* randomize renderer */ |
375 | , BGFX_PCI_ID_NONE | |
376 | , 0 | |
375 | 377 | , &callback // custom callback handler |
376 | 378 | , &allocator // custom allocator |
377 | 379 | ); |
r245308 | r245309 | |
442 | 444 | |
443 | 445 | float at[3] = { 0.0f, 0.0f, 0.0f }; |
444 | 446 | float eye[3] = { 0.0f, 0.0f, -35.0f }; |
445 | ||
447 | ||
446 | 448 | float view[16]; |
447 | 449 | float proj[16]; |
448 | 450 | bx::mtxLookAt(view, eye, at); |
r245308 | r245309 | |
488 | 490 | bgfx::saveScreenShot("temp/frame150"); |
489 | 491 | } |
490 | 492 | |
491 | // Advance to next frame. Rendering thread will be kicked to | |
493 | // Advance to next frame. Rendering thread will be kicked to | |
492 | 494 | // process submitted rendering primitives. |
493 | 495 | bgfx::frame(); |
494 | 496 | } |
r245308 | r245309 | |
---|---|---|
167 | 167 | } |
168 | 168 | } |
169 | 169 | |
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) | |
171 | 177 | { |
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 | } | |
176 | 182 | |
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 | ||
177 | 194 | // Create static vertex buffer. |
178 | 195 | bgfx::VertexBufferHandle vbh = bgfx::createVertexBuffer(bgfx::makeRef(s_cubeVertices, sizeof(s_cubeVertices) ), PosTexcoordVertex::ms_decl); |
179 | 196 | |
r245308 | r245309 | |
188 | 205 | |
189 | 206 | bgfx::ProgramHandle program = loadProgram("vs_update", "fs_update"); |
190 | 207 | 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 | } | |
192 | 213 | |
193 | 214 | const uint32_t textureSide = 2048; |
194 | 215 | |
r245308 | r245309 | |
399 | 420 | bgfx::submit(1); |
400 | 421 | } |
401 | 422 | |
402 | for (uint32_t ii = 0; ii < | |
423 | for (uint32_t ii = 0; ii < numTextures3d; ++ii) | |
403 | 424 | { |
404 | 425 | bx::mtxTranslate(mtx, xpos + ii*2.1f, -4.0f, 0.0f); |
405 | 426 | |
r245308 | r245309 | |
465 | 486 | bgfx::destroyTexture(textures[ii]); |
466 | 487 | } |
467 | 488 | |
468 | for (uint32_t ii = 0; ii < | |
489 | for (uint32_t ii = 0; ii < numTextures3d; ++ii) | |
469 | 490 | { |
470 | 491 | bgfx::destroyTexture(textures3d[ii]); |
471 | 492 | } |
r245308 | r245309 | |
474 | 495 | bgfx::destroyTexture(textureCube); |
475 | 496 | bgfx::destroyIndexBuffer(ibh); |
476 | 497 | bgfx::destroyVertexBuffer(vbh); |
477 | bgfx::destroyProgram(program3d); | |
498 | if (bgfx::isValid(program3d) ) | |
499 | { | |
500 | bgfx::destroyProgram(program3d); | |
501 | } | |
478 | 502 | bgfx::destroyProgram(programCmp); |
479 | 503 | bgfx::destroyProgram(program); |
480 | 504 | bgfx::destroyUniform(u_time); |
r245308 | r245309 | |
---|---|---|
174 | 174 | bgfx::setViewName(8, "Blur vertical"); |
175 | 175 | bgfx::setViewName(9, "Blur horizontal + tonemap"); |
176 | 176 | |
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 | ); | |
178 | 183 | |
179 | 184 | bgfx::ProgramHandle skyProgram = loadProgram("vs_hdr_skybox", "fs_hdr_skybox"); |
180 | 185 | bgfx::ProgramHandle lumProgram = loadProgram("vs_hdr_lum", "fs_hdr_lum"); |
r245308 | r245309 | |
371 | 376 | |
372 | 377 | // Render skybox into view 0. |
373 | 378 | bgfx::setTexture(0, u_texCube, uffizi); |
379 | ||
374 | 380 | bgfx::setProgram(skyProgram); |
375 | 381 | bgfx::setState(BGFX_STATE_RGB_WRITE|BGFX_STATE_ALPHA_WRITE); |
376 | 382 | screenSpaceQuad( (float)width, (float)height, true); |
r245308 | r245309 | |
---|---|---|
1040 | 1040 | const float radius = (scene == StencilReflectionScene) ? 15.0f : 25.0f; |
1041 | 1041 | for (uint8_t ii = 0; ii < numLights; ++ii) |
1042 | 1042 | { |
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; | |
1046 | 1046 | lightPosRadius[ii][3] = radius; |
1047 | 1047 | } |
1048 | 1048 | memcpy(s_uniforms.m_lightPosRadius, lightPosRadius, numLights * 4*sizeof(float)); |
r245308 | r245309 | |
1112 | 1112 | , 0.0f |
1113 | 1113 | , 0.0f |
1114 | 1114 | , 0.0f |
1115 | , sin(ii * 2.0f + 13.0f - sceneTimeAccumulator) * 13.0f | |
1115 | , sinf(ii * 2.0f + 13.0f - sceneTimeAccumulator) * 13.0f | |
1116 | 1116 | , 4.0f |
1117 | , cos(ii * 2.0f + 13.0f - sceneTimeAccumulator) * 13.0f | |
1117 | , cosf(ii * 2.0f + 13.0f - sceneTimeAccumulator) * 13.0f | |
1118 | 1118 | ); |
1119 | 1119 | } |
1120 | 1120 | |
r245308 | r245309 | |
1188 | 1188 | |
1189 | 1189 | // Set lights back. |
1190 | 1190 | memcpy(s_uniforms.m_lightPosRadius, lightPosRadius, numLights * 4*sizeof(float)); |
1191 | ||
1192 | 1191 | // Third pass - Blend plane. |
1193 | 1192 | |
1194 | 1193 | // Floor. |
r245308 | r245309 | |
1217 | 1216 | , s_renderStates[RenderState::StencilReflection_DrawScene] |
1218 | 1217 | ); |
1219 | 1218 | } |
1219 | ||
1220 | 1220 | } |
1221 | 1221 | break; |
1222 | 1222 |
r245308 | r245309 | |
---|---|---|
2276 | 2276 | { |
2277 | 2277 | for (uint8_t ii = 0; ii < settings_numLights; ++ii) |
2278 | 2278 | { |
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; | |
2280 | 2280 | 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; | |
2282 | 2282 | lightPosRadius[ii][3] = 20.0f; |
2283 | 2283 | } |
2284 | 2284 | } |
r245308 | r245309 | |
2286 | 2286 | { |
2287 | 2287 | for (uint8_t ii = 0; ii < settings_numLights; ++ii) |
2288 | 2288 | { |
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; | |
2290 | 2290 | 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; | |
2292 | 2292 | lightPosRadius[ii][3] = 20.0f; |
2293 | 2293 | } |
2294 | 2294 | } |
r245308 | r245309 | |
2362 | 2362 | inst.m_rotation[0] = 0.0f; |
2363 | 2363 | inst.m_rotation[1] = 0.0f; |
2364 | 2364 | 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; | |
2366 | 2366 | 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; | |
2368 | 2368 | inst.m_model = &cubeModel; |
2369 | 2369 | } |
2370 | 2370 | |
r245308 | r245309 | |
2379 | 2379 | inst.m_rotation[0] = 0.0f; |
2380 | 2380 | inst.m_rotation[1] = 0.0f; |
2381 | 2381 | 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; | |
2383 | 2383 | 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; | |
2385 | 2385 | inst.m_model = &cubeModel; |
2386 | 2386 | } |
2387 | 2387 |
r245308 | r245309 | |
---|---|---|
221 | 221 | |
222 | 222 | // Setup lights. |
223 | 223 | float lightPos[4]; |
224 | lightPos[0] = -cos(timeAccumulatorLight); | |
224 | lightPos[0] = -cosf(timeAccumulatorLight); | |
225 | 225 | lightPos[1] = -1.0f; |
226 | lightPos[2] = -sin(timeAccumulatorLight); | |
226 | lightPos[2] = -sinf(timeAccumulatorLight); | |
227 | 227 | lightPos[3] = 0.0f; |
228 | 228 | |
229 | 229 | bgfx::setUniform(u_lightPos, lightPos); |
r245308 | r245309 | |
---|---|---|
2165 | 2165 | if (settings.m_updateScene) { timeAccumulatorScene += deltaTime; } |
2166 | 2166 | |
2167 | 2167 | // Setup lights. |
2168 | pointLight.m_position.m_x = cos(timeAccumulatorLight) * 20.0f; | |
2168 | pointLight.m_position.m_x = cosf(timeAccumulatorLight) * 20.0f; | |
2169 | 2169 | 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; | |
2171 | 2171 | pointLight.m_spotDirectionInner.m_x = -pointLight.m_position.m_x; |
2172 | 2172 | pointLight.m_spotDirectionInner.m_y = -pointLight.m_position.m_y; |
2173 | 2173 | pointLight.m_spotDirectionInner.m_z = -pointLight.m_position.m_z; |
2174 | 2174 | |
2175 | directionalLight.m_position.m_x = -cos(timeAccumulatorLight); | |
2175 | directionalLight.m_position.m_x = -cosf(timeAccumulatorLight); | |
2176 | 2176 | directionalLight.m_position.m_y = -1.0f; |
2177 | directionalLight.m_position.m_z = -sin(timeAccumulatorLight); | |
2177 | directionalLight.m_position.m_z = -sinf(timeAccumulatorLight); | |
2178 | 2178 | |
2179 | 2179 | // Setup instance matrices. |
2180 | 2180 | float mtxFloor[16]; |
r245308 | r245309 | |
---|---|---|
387 | 387 | float ry = y + ey; |
388 | 388 | float dx,dy,d; |
389 | 389 | 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; | |
391 | 391 | |
392 | 392 | bg = nvgLinearGradient(vg, x,y+h*0.5f,x+w*0.1f,y+h, nvgRGBA(0,0,0,32), nvgRGBA(0,0,0,16)); |
393 | 393 | nvgBeginPath(vg); |
r245308 | r245309 | |
1075 | 1075 | nvgBeginPath(vg); |
1076 | 1076 | nvgFillColor(vg, nvgRGBA(255,192,0,255)); |
1077 | 1077 | 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 | |
1083 | 1083 | ); |
1084 | 1084 | nvgFill(vg); |
1085 | 1085 | |
r245308 | r245309 | |
1097 | 1097 | nvgBeginPath(vg); |
1098 | 1098 | nvgFillColor(vg, nvgRGBA(220,220,220,255)); |
1099 | 1099 | 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 | |
1104 | 1104 | , 3.0f |
1105 | 1105 | ); |
1106 | 1106 | px = float( (int)((bounds[2]+bounds[0])/2) ); |
r245308 | r245309 | |
---|---|---|
529 | 529 | { |
530 | 530 | Sphere lightPosRadius; |
531 | 531 | |
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; | |
536 | 536 | lightPosRadius.m_radius = 2.0f; |
537 | 537 | |
538 | 538 | Aabb aabb; |
r245308 | r245309 | |
---|---|---|
150 | 150 | // draw moving shape |
151 | 151 | static float counter = 0.0f; |
152 | 152 | 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); | |
155 | 155 | vd.drawCircle(posX, posY, 5.0f, 10.0f); |
156 | 156 | |
157 | 157 | vd.endFrame(); |
r245308 | r245309 | |
---|---|---|
361 | 361 | line->y0 = m_pendingPoints[i - 1].y; |
362 | 362 | line->x1 = m_pendingPoints[i].x; |
363 | 363 | line->y1 = m_pendingPoints[i].y; |
364 | line->a = atan2(line->y1 - line->y0, line->x1 - line->x0); | |
364 | line->a = atan2f(line->y1 - line->y0, line->x1 - line->x0); // angle from positive x axis, increasing ccw, [-pi, pi] | |
365 | 365 | line->sin_a = sinf(line->a); |
366 | 366 | 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) ); | |
368 | 368 | |
369 | 369 | // figure out what connections we have |
370 | 370 | line->has_prev = (!line->is_first |
r245308 | r245309 | |
---|---|---|
15 | 15 | |
16 | 16 | int _main_(int _argc, char** _argv) |
17 | 17 | { |
18 | uint32_t width = 1280; | |
19 | uint32_t height = 720; | |
20 | uint32_t debug = BGFX_DEBUG_TEXT; | |
21 | uint32_t reset = BGFX_RESET_VSYNC; | |
18 | 22 | (void)_argc; |
19 | 23 | (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; | |
24 | 24 | |
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 | ); | |
26 | 31 | bgfx_reset(width, height, reset); |
27 | 32 | |
28 | 33 | // Enable debug text. |
r245308 | r245309 | |
---|---|---|
264 | 264 | { |
265 | 265 | position = (float*)&vertex[index*_stride]; |
266 | 266 | |
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]; | |
270 | 270 | float distSq = xx*xx + yy*yy + zz*zz; |
271 | 271 | |
272 | 272 | if (distSq > maxDistSq) |
r245308 | r245309 | |
---|---|---|
29 | 29 | #if ENTRY_CONFIG_IMPLEMENT_DEFAULT_ALLOCATOR |
30 | 30 | bx::ReallocatorI* getDefaultAllocator() |
31 | 31 | { |
32 | BX_PRAGMA_DIAGNOSTIC_PUSH_MSVC(); | |
33 | BX_PRAGMA_DIAGNOSTIC_IGNORED_MSVC(4459); // warning C4459: declaration of 's_allocator' hides global declaration | |
32 | 34 | static bx::CrtAllocator s_allocator; |
33 | 35 | return &s_allocator; |
36 | BX_PRAGMA_DIAGNOSTIC_POP_MSVC(); | |
34 | 37 | } |
35 | 38 | #endif // ENTRY_CONFIG_IMPLEMENT_DEFAULT_ALLOCATOR |
36 | 39 |
r245308 | r245309 | |
---|---|---|
161 | 161 | class EventQueue |
162 | 162 | { |
163 | 163 | public: |
164 | ~EventQueue() | |
165 | { | |
166 | for (const Event* ev = poll(); NULL != ev; ev = poll() ) | |
167 | { | |
168 | release(ev); | |
169 | } | |
170 | } | |
171 | ||
164 | 172 | void postAxisEvent(WindowHandle _handle, GamepadHandle _gamepad, GamepadAxis::Enum _axis, int32_t _value) |
165 | 173 | { |
166 | 174 | AxisEvent* ev = new AxisEvent(_handle); |
r245308 | r245309 | |
---|---|---|
273 | 273 | } bgfx_texture_info_t; |
274 | 274 | |
275 | 275 | /** |
276 | */ | |
277 | typedef struct bgfx_caps_gpu | |
278 | { | |
279 | uint16_t vendorId; | |
280 | uint16_t deviceId; | |
281 | ||
282 | } bgfx_caps_gpu_t; | |
283 | ||
284 | /** | |
276 | 285 | * Renderer capabilities. |
277 | 286 | */ |
278 | 287 | typedef struct bgfx_caps |
r245308 | r245309 | |
293 | 302 | uint16_t maxViews; /* < Maximum views. */ |
294 | 303 | uint16_t maxDrawCalls; /* < Maximum draw calls. */ |
295 | 304 | uint8_t maxFBAttachments; /* < Maximum frame buffer attachments. */ |
305 | uint8_t numGPUs; /* < */ | |
296 | 306 | |
307 | uint16_t vendorId; /* < */ | |
308 | uint16_t deviceId; /* < */ | |
309 | bgfx_caps_gpu_t gpu[4]; /* < */ | |
310 | ||
297 | 311 | /** |
298 | 312 | * Supported texture formats. |
299 | 313 | * `BGFX_CAPS_FORMAT_TEXTURE_NONE` - not supported |
r245308 | r245309 | |
559 | 573 | * specified, library uses default CRT allocator. The library assumes |
560 | 574 | * custom allocator is thread safe. |
561 | 575 | */ |
562 | BGFX_C_API void bgfx_init(bgfx_renderer_type_t _type, bgfx_callback_interface_t* _callback, bgfx_reallocator_interface_t* _allocator); | |
576 | BGFX_C_API void bgfx_init(bgfx_renderer_type_t _type, uint16_t _vendorId, uint16_t _deviceId, bgfx_callback_interface_t* _callback, bgfx_reallocator_interface_t* _allocator); | |
563 | 577 | |
564 | 578 | /** |
565 | 579 | * Shutdown bgfx library. |
r245308 | r245309 | |
---|---|---|
315 | 315 | uint16_t maxViews; ///< Maximum views. |
316 | 316 | uint16_t maxDrawCalls; ///< Maximum draw calls. |
317 | 317 | uint8_t maxFBAttachments; ///< Maximum frame buffer attachments. |
318 | uint8_t numGPUs; ///< | |
318 | 319 | |
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 | ||
319 | 331 | /// Supported texture formats. |
320 | 332 | /// - `BGFX_CAPS_FORMAT_TEXTURE_NONE` - not supported |
321 | 333 | /// - `BGFX_CAPS_FORMAT_TEXTURE_COLOR` - supported |
r245308 | r245309 | |
508 | 520 | /// default rendering backend will be selected. |
509 | 521 | /// See: `bgfx::RendererType` |
510 | 522 | /// |
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 | /// | |
511 | 532 | /// @param _callback Provide application specific callback interface. |
512 | 533 | /// See: `bgfx::CallbackI` |
513 | 534 | /// |
r245308 | r245309 | |
517 | 538 | /// |
518 | 539 | /// @attention C99 equivalent is `bgfx_init`. |
519 | 540 | /// |
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); | |
521 | 542 | |
522 | 543 | /// Shutdown bgfx library. |
523 | 544 | /// |
r245308 | r245309 | |
---|---|---|
333 | 333 | #define BGFX_SUBMIT_EYE_MASK UINT8_C(0x03) |
334 | 334 | #define BGFX_SUBMIT_EYE_FIRST BGFX_SUBMIT_EYE_LEFT |
335 | 335 | |
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 | ||
336 | 342 | #endif // BGFX_DEFINES_H_HEADER_GUARD |
r245308 | r245309 | |
---|---|---|
158 | 158 | "ws2_32", |
159 | 159 | } |
160 | 160 | |
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 | |
163 | 163 | |
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) } | |
166 | 166 | |
167 | configuration { "x32", "Debug" } | |
168 | links { "libovrd" } | |
167 | configuration { "x32", "Release" } | |
168 | libdirs { path.join("$(OVR_DIR)/LibOVR/Lib/Windows/Win32/Release", _ACTION) } | |
169 | 169 | |
170 | configuration { "x32", "Release" } | |
171 | links { "libovr" } | |
170 | configuration { "x64", "Debug" } | |
171 | libdirs { path.join("$(OVR_DIR)/LibOVR/Lib/Windows/x64/Debug", _ACTION) } | |
172 | 172 | |
173 | configuration { "x64", "Debug" } | |
174 | links { "libovr64d" } | |
173 | configuration { "x64", "Release" } | |
174 | libdirs { path.join("$(OVR_DIR)/LibOVR/Lib/Windows/x64/Release", _ACTION) } | |
175 | 175 | |
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) } | |
178 | 181 | |
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 | ||
179 | 198 | configuration {} |
180 | 199 | end |
181 | 200 |
r245308 | r245309 | |
---|---|---|
888 | 888 | |
889 | 889 | static void dumpCaps() |
890 | 890 | { |
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 | ); | |
892 | 896 | for (uint32_t ii = 0; ii < BX_COUNTOF(s_capsFlags); ++ii) |
893 | 897 | { |
894 | 898 | if (0 != (g_caps.supported & s_capsFlags[ii].m_flag) ) |
r245308 | r245309 | |
1977 | 1981 | return s_rendererCreator[_type].name; |
1978 | 1982 | } |
1979 | 1983 | |
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) | |
1981 | 1985 | { |
1982 | 1986 | BX_CHECK(NULL == s_ctx, "bgfx is already initialized."); |
1983 | 1987 | BX_TRACE("Init..."); |
r245308 | r245309 | |
1989 | 1993 | g_caps.maxViews = BGFX_CONFIG_MAX_VIEWS; |
1990 | 1994 | g_caps.maxDrawCalls = BGFX_CONFIG_MAX_DRAW_CALLS; |
1991 | 1995 | g_caps.maxFBAttachments = 1; |
1996 | g_caps.vendorId = _vendorId; | |
1997 | g_caps.deviceId = _deviceId; | |
1992 | 1998 | |
1993 | 1999 | if (NULL != _allocator) |
1994 | 2000 | { |
r245308 | r245309 | |
3012 | 3018 | return bgfx::getRendererName(bgfx::RendererType::Enum(_type) ); |
3013 | 3019 | } |
3014 | 3020 | |
3015 | BGFX_C_API void bgfx_init(bgfx_renderer_type_t _type, | |
3021 | BGFX_C_API void bgfx_init(bgfx_renderer_type_t _type, uint16_t _vendorId, uint16_t _deviceId, bgfx_callback_interface_t* _callback, bgfx_reallocator_interface_t* _allocator) | |
3016 | 3022 | { |
3017 | 3023 | return bgfx::init(bgfx::RendererType::Enum(_type) |
3024 | , _vendorId | |
3025 | , _deviceId | |
3018 | 3026 | , reinterpret_cast<bgfx::CallbackI*>(_callback) |
3019 | 3027 | , reinterpret_cast<bx::ReallocatorI*>(_allocator) |
3020 | 3028 | ); |
r245308 | r245309 | |
---|---|---|
29 | 29 | #include <string.h> |
30 | 30 | #include <alloca.h> |
31 | 31 | |
32 | // Check handle, cannot be bgfx::invalidHandle and must be valid. | |
32 | 33 | #define BGFX_CHECK_HANDLE(_desc, _handleAlloc, _handle) \ |
33 | 34 | BX_CHECK(isValid(_handle) \ |
34 | 35 | && _handleAlloc.isValid(_handle.idx) \ |
r245308 | r245309 | |
36 | 37 | , _desc \ |
37 | 38 | , _handle.idx \ |
38 | 39 | , _handleAlloc.getMaxHandles() \ |
39 | ) | |
40 | ) | |
40 | 41 | |
42 | // Check handle, it's ok to be bgfx::invalidHandle or must be valid. | |
43 | #define BGFX_CHECK_HANDLE_INVALID_OK(_desc, _handleAlloc, _handle) \ | |
44 | BX_CHECK(!isValid(_handle) \ | |
45 | || _handleAlloc.isValid(_handle.idx) \ | |
46 | , "Invalid handle. %s handle: %d (max %d)" \ | |
47 | , _desc \ | |
48 | , _handle.idx \ | |
49 | , _handleAlloc.getMaxHandles() \ | |
50 | ) | |
51 | ||
41 | 52 | namespace bgfx |
42 | 53 | { |
43 | 54 | #if BX_COMPILER_CLANG_ANALYZER |
r245308 | r245309 | |
3091 | 3102 | |
3092 | 3103 | BGFX_API_FUNC(void setViewFrameBuffer(uint8_t _id, FrameBufferHandle _handle) ) |
3093 | 3104 | { |
3094 | BGFX_CHECK_HANDLE("setViewFrameBuffer", m_frameBufferHandle, _handle); | |
3105 | BGFX_CHECK_HANDLE_INVALID_OK("setViewFrameBuffer", m_frameBufferHandle, _handle); | |
3095 | 3106 | m_fb[_id] = _handle; |
3096 | 3107 | } |
3097 | 3108 | |
r245308 | r245309 | |
3259 | 3270 | |
3260 | 3271 | BGFX_API_FUNC(void setTexture(uint8_t _stage, UniformHandle _sampler, TextureHandle _handle, uint32_t _flags) ) |
3261 | 3272 | { |
3262 | BGFX_CHECK_HANDLE("setTexture", m_textureHandle, _handle); | |
3273 | BGFX_CHECK_HANDLE_INVALID_OK("setTexture/TextureHandle", m_textureHandle, _handle); | |
3263 | 3274 | m_submit->setTexture(_stage, _sampler, _handle, _flags); |
3264 | 3275 | } |
3265 | 3276 | |
3266 | 3277 | BGFX_API_FUNC(void setTexture(uint8_t _stage, UniformHandle _sampler, FrameBufferHandle _handle, uint8_t _attachment, uint32_t _flags) ) |
3267 | 3278 | { |
3279 | BGFX_CHECK_HANDLE_INVALID_OK("setTexture/FrameBufferHandle", m_frameBufferHandle, _handle); | |
3268 | 3280 | BX_CHECK(_attachment < g_caps.maxFBAttachments, "Frame buffer attachment index %d is invalid.", _attachment); |
3269 | 3281 | TextureHandle textureHandle = BGFX_INVALID_HANDLE; |
3270 | 3282 | if (isValid(_handle) ) |
r245308 | r245309 | |
---|---|---|
123 | 123 | result = ovrHmd_ConfigureRendering(m_hmd |
124 | 124 | , _config |
125 | 125 | , 0 |
126 | | ovrDistortionCap_Chromatic | |
126 | #if OVR_VERSION < OVR_VERSION_050 | |
127 | | ovrDistortionCap_Chromatic // permanently enabled >= v5.0 | |
128 | #endif | |
127 | 129 | | ovrDistortionCap_Vignette |
128 | 130 | | ovrDistortionCap_TimeWarp |
129 | 131 | | ovrDistortionCap_Overdrive |
r245308 | r245309 | |
---|---|---|
10 | 10 | |
11 | 11 | #if BGFX_CONFIG_USE_OVR |
12 | 12 | |
13 | # include <OVR.h> | |
13 | # include <OVR_Version.h> | |
14 | 14 | |
15 | 15 | # define OVR_VERSION_(_a, _b, _c) (_a * 10000 + _b * 100 + _c) |
16 | 16 | # define OVR_VERSION OVR_VERSION_(OVR_MAJOR_VERSION, OVR_MINOR_VERSION, OVR_BUILD_VERSION) |
17 | 17 | # define OVR_VERSION_042 OVR_VERSION_(0, 4, 2) |
18 | 18 | # define OVR_VERSION_043 OVR_VERSION_(0, 4, 3) |
19 | 19 | # define OVR_VERSION_044 OVR_VERSION_(0, 4, 4) |
20 | # define OVR_VERSION_050 OVR_VERSION_(0, 5, 0) | |
20 | 21 | |
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 | ||
21 | 28 | # if BGFX_CONFIG_RENDERER_DIRECT3D9 |
22 | 29 | # 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 | |
24 | 35 | # endif // BGFX_CONFIG_RENDERER_DIRECT3D9 |
25 | 36 | |
26 | 37 | # if BGFX_CONFIG_RENDERER_DIRECT3D11 |
r245308 | r245309 | |
29 | 40 | # undef OVR_D3D_VERSION |
30 | 41 | # endif // OVR_CAPI_D3D_h |
31 | 42 | # 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 | |
33 | 48 | # endif // BGFX_CONFIG_RENDERER_DIRECT3D11 |
34 | 49 | |
35 | 50 | # 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 | |
37 | 56 | # endif // BGFX_CONFIG_RENDERER_OPENGL |
38 | 57 | |
39 | 58 | namespace bgfx |
r245308 | r245309 | |
---|---|---|
513 | 513 | m_driverType = D3D_DRIVER_TYPE_HARDWARE; |
514 | 514 | |
515 | 515 | 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 | ) | |
517 | 520 | { |
518 | 521 | DXGI_ADAPTER_DESC desc; |
519 | 522 | hr = adapter->GetDesc(&desc); |
r245308 | r245309 | |
536 | 539 | , desc.SharedSystemMemory |
537 | 540 | ); |
538 | 541 | |
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 | ||
539 | 555 | if (BX_ENABLED(BGFX_CONFIG_DEBUG_PERFHUD) |
540 | 556 | && 0 != strstr(description, "PerfHUD") ) |
541 | 557 | { |
r245308 | r245309 | |
594 | 610 | } |
595 | 611 | BGFX_FATAL(SUCCEEDED(hr), Fatal::UnableToInitialize, "Unable to create Direct3D11 device."); |
596 | 612 | |
613 | if (NULL != m_adapter) | |
614 | { | |
615 | DX_RELEASE(m_adapter, 2); | |
616 | } | |
617 | ||
597 | 618 | IDXGIDevice* device = NULL; |
598 | 619 | hr = E_FAIL; |
599 | 620 | for (uint32_t ii = 0; ii < BX_COUNTOF(s_deviceIIDs) && FAILED(hr); ++ii) |
r245308 | r245309 | |
616 | 637 | |
617 | 638 | hr = adapter->GetDesc(&m_adapterDesc); |
618 | 639 | 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; | |
619 | 642 | |
620 | 643 | #if BX_PLATFORM_WINRT |
621 | 644 | hr = adapter->GetParent(__uuidof(IDXGIFactory2), (void**)&m_factory); |
r245308 | r245309 | |
734 | 757 | { |
735 | 758 | D3D11_FEATURE_DATA_FORMAT_SUPPORT data; // D3D11_FEATURE_DATA_FORMAT_SUPPORT2 |
736 | 759 | data.InFormat = s_textureFormat[ii].m_fmt; |
737 | | |
760 | hr = m_device->CheckFeatureSupport(D3D11_FEATURE_FORMAT_SUPPORT, &data, sizeof(data) ); | |
738 | 761 | if (SUCCEEDED(hr) ) |
739 | 762 | { |
740 | 763 | support |= 0 != (data.OutFormatSupport & (0 |
r245308 | r245309 | |
3123 | 3146 | uint32_t statsNumPrimsRendered[BX_COUNTOF(s_primInfo)] = {}; |
3124 | 3147 | uint32_t statsNumInstances[BX_COUNTOF(s_primInfo)] = {}; |
3125 | 3148 | uint32_t statsNumIndices = 0; |
3149 | uint32_t statsKeyType[2] = {}; | |
3126 | 3150 | |
3127 | 3151 | if (0 == (_render->m_debug&BGFX_DEBUG_IFH) ) |
3128 | 3152 | { |
r245308 | r245309 | |
3135 | 3159 | for (int32_t item = 0, restartItem = numItems; item < numItems || restartItem < numItems;) |
3136 | 3160 | { |
3137 | 3161 | const bool isCompute = key.decode(_render->m_sortKeys[item], _render->m_viewRemap); |
3162 | statsKeyType[isCompute]++; | |
3163 | ||
3138 | 3164 | const bool viewChanged = 0 |
3139 | 3165 | || key.m_view != view |
3140 | 3166 | || item == numItems |
r245308 | r245309 | |
3778 | 3804 | ); |
3779 | 3805 | |
3780 | 3806 | double elapsedCpuMs = double(elapsed)*toMs; |
3781 | tvm.printf(10, pos++, 0x8e, " | |
3807 | tvm.printf(10, pos++, 0x8e, " Submitted: %4d (draw %4d, compute %4d) / CPU %3.4f [ms]" | |
3782 | 3808 | , _render->m_num |
3809 | , statsKeyType[0] | |
3810 | , statsKeyType[1] | |
3783 | 3811 | , elapsedCpuMs |
3784 | 3812 | ); |
3785 | 3813 | for (uint32_t ii = 0; ii < BX_COUNTOF(s_primName); ++ii) |
r245308 | r245309 | |
---|---|---|
359 | 359 | m_adapter = D3DADAPTER_DEFAULT; |
360 | 360 | m_deviceType = D3DDEVTYPE_HAL; |
361 | 361 | |
362 | uint32_t adapterCount = m_d3d9->GetAdapterCount(); | |
363 | for (uint32_t ii = 0; ii < adapterCount; ++ii) | |
362 | uint8_t numGPUs = bx::uint32_min(BX_COUNTOF(g_caps.gpu), m_d3d9->GetAdapterCount() ); | |
363 | for (uint32_t ii = 0; ii < numGPUs; ++ii) | |
364 | 364 | { |
365 | D3DADAPTER_IDENTIFIER9 identifier; | |
366 | HRESULT hr = m_d3d9->GetAdapterIdentifier(ii, 0, &identifier); | |
365 | D3DADAPTER_IDENTIFIER9 desc; | |
366 | HRESULT hr = m_d3d9->GetAdapterIdentifier(ii, 0, &desc); | |
367 | 367 | if (SUCCEEDED(hr) ) |
368 | 368 | { |
369 | 369 | BX_TRACE("Adapter #%d", ii); |
370 | BX_TRACE("\tDriver: %s", identifier.Driver); | |
371 | BX_TRACE("\tDescription: %s", identifier.Description); | |
372 | BX_TRACE("\tDeviceName: %s", identifier.DeviceName); | |
370 | BX_TRACE("\tDriver: %s", desc.Driver); | |
371 | BX_TRACE("\tDescription: %s", desc.Description); | |
372 | BX_TRACE("\tDeviceName: %s", desc.DeviceName); | |
373 | 373 | BX_TRACE("\tVendorId: 0x%08x, DeviceId: 0x%08x, SubSysId: 0x%08x, Revision: 0x%08x" |
374 | , identifier.VendorId | |
375 | , identifier.DeviceId | |
376 | , identifier.SubSysId | |
377 | , identifier.Revision | |
374 | , desc.VendorId | |
375 | , desc.DeviceId | |
376 | , desc.SubSysId | |
377 | , desc.Revision | |
378 | 378 | ); |
379 | 379 | |
380 | 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 | ||
380 | 390 | #if BGFX_CONFIG_DEBUG_PERFHUD |
381 | if (0 != strstr( | |
391 | if (0 != strstr(desc.Description, "PerfHUD") ) | |
382 | 392 | { |
383 | 393 | m_adapter = ii; |
384 | 394 | m_deviceType = D3DDEVTYPE_REF; |
r245308 | r245309 | |
388 | 398 | } |
389 | 399 | |
390 | 400 | 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; | |
393 | 405 | |
394 | 406 | uint32_t behaviorFlags[] = |
395 | 407 | { |
r245308 | r245309 | |
2215 | 2227 | if (NULL != _rect) |
2216 | 2228 | { |
2217 | 2229 | 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; | |
2222 | 2234 | DX_CHECK(m_texture2d->LockRect(_lod, &lockedRect, &rect, 0) ); |
2223 | 2235 | } |
2224 | 2236 | else |
r245308 | r245309 | |
2494 | 2506 | |
2495 | 2507 | if (convert) |
2496 | 2508 | { |
2497 | | |
2509 | temp = (uint8_t*)BX_ALLOC(g_allocator, rectpitch*_rect.m_height); | |
2498 | 2510 | imageDecodeToBgra8(temp, data, _rect.m_width, _rect.m_height, srcpitch, m_requestedFormat); |
2499 | 2511 | data = temp; |
2500 | 2512 | } |
r245308 | r245309 | |
2864 | 2876 | FrameBufferHandle fbh = BGFX_INVALID_HANDLE; |
2865 | 2877 | uint32_t blendFactor = 0; |
2866 | 2878 | |
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 | } | |
2869 | 2884 | PrimInfo prim = s_primInfo[primIndex]; |
2870 | 2885 | |
2871 | 2886 | bool viewHasScissor = false; |
r245308 | r245309 | |
2876 | 2891 | uint32_t statsNumPrimsRendered[BX_COUNTOF(s_primInfo)] = {}; |
2877 | 2892 | uint32_t statsNumInstances[BX_COUNTOF(s_primInfo)] = {}; |
2878 | 2893 | uint32_t statsNumIndices = 0; |
2894 | uint32_t statsKeyType[2] = {}; | |
2879 | 2895 | |
2880 | 2896 | invalidateSamplerState(); |
2881 | 2897 | |
r245308 | r245309 | |
2884 | 2900 | for (uint32_t item = 0, numItems = _render->m_num; item < numItems; ++item) |
2885 | 2901 | { |
2886 | 2902 | const bool isCompute = key.decode(_render->m_sortKeys[item], _render->m_viewRemap); |
2903 | statsKeyType[isCompute]++; | |
2887 | 2904 | |
2888 | 2905 | if (isCompute) |
2889 | 2906 | { |
r245308 | r245309 | |
3414 | 3431 | ); |
3415 | 3432 | |
3416 | 3433 | double elapsedCpuMs = double(elapsed)*toMs; |
3417 | tvm.printf(10, pos++, 0x8e, " | |
3434 | tvm.printf(10, pos++, 0x8e, " Submitted: %4d (draw %4d, compute %4d) / CPU %3.4f [ms]" | |
3418 | 3435 | , _render->m_num |
3436 | , statsKeyType[0] | |
3437 | , statsKeyType[1] | |
3419 | 3438 | , elapsedCpuMs |
3420 | 3439 | ); |
3421 | 3440 | for (uint32_t ii = 0; ii < BX_COUNTOF(s_primName); ++ii) |
r245308 | r245309 | |
---|---|---|
237 | 237 | }; |
238 | 238 | BX_STATIC_ASSERT(TextureFormat::Count == BX_COUNTOF(s_textureFormat) ); |
239 | 239 | |
240 | static bool s_textureFilter[TextureFormat::Count+1]; | |
241 | ||
240 | 242 | static GLenum s_rboFormat[] = |
241 | 243 | { |
242 | 244 | GL_ZERO, // BC1 |
r245308 | r245309 | |
358 | 360 | ANGLE_texture_compression_dxt1, |
359 | 361 | ANGLE_texture_compression_dxt3, |
360 | 362 | ANGLE_texture_compression_dxt5, |
363 | ANGLE_timer_query, | |
361 | 364 | ANGLE_translated_shader_source, |
362 | 365 | |
363 | 366 | APPLE_texture_format_BGRA8888, |
r245308 | r245309 | |
418 | 421 | EXT_blend_minmax, |
419 | 422 | EXT_blend_subtract, |
420 | 423 | EXT_color_buffer_half_float, |
424 | EXT_color_buffer_float, | |
421 | 425 | EXT_compressed_ETC1_RGB8_sub_texture, |
422 | 426 | EXT_debug_label, |
423 | 427 | EXT_debug_marker, |
424 | 428 | EXT_discard_framebuffer, |
429 | EXT_disjoint_timer_query, | |
425 | 430 | EXT_draw_buffers, |
426 | 431 | EXT_frag_depth, |
427 | 432 | EXT_framebuffer_blit, |
r245308 | r245309 | |
511 | 516 | bool m_initialize; |
512 | 517 | }; |
513 | 518 | |
514 | static Extension s_extension[ | |
519 | static Extension s_extension[] = | |
515 | 520 | { |
516 | 521 | { "AMD_conservative_depth", false, true }, |
517 | 522 | |
r245308 | r245309 | |
522 | 527 | { "ANGLE_texture_compression_dxt1", false, true }, |
523 | 528 | { "ANGLE_texture_compression_dxt3", false, true }, |
524 | 529 | { "ANGLE_texture_compression_dxt5", false, true }, |
530 | { "ANGLE_timer_query", false, true }, | |
525 | 531 | { "ANGLE_translated_shader_source", false, true }, |
526 | 532 | |
527 | 533 | { "APPLE_texture_format_BGRA8888", false, true }, |
r245308 | r245309 | |
582 | 588 | { "EXT_blend_minmax", BGFX_CONFIG_RENDERER_OPENGL >= 14, true }, |
583 | 589 | { "EXT_blend_subtract", BGFX_CONFIG_RENDERER_OPENGL >= 14, true }, |
584 | 590 | { "EXT_color_buffer_half_float", false, true }, // GLES2 extension. |
591 | { "EXT_color_buffer_float", false, true }, // GLES2 extension. | |
585 | 592 | { "EXT_compressed_ETC1_RGB8_sub_texture", false, true }, // GLES2 extension. |
586 | 593 | { "EXT_debug_label", false, true }, |
587 | 594 | { "EXT_debug_marker", false, true }, |
588 | 595 | { "EXT_discard_framebuffer", false, true }, // GLES2 extension. |
596 | { "EXT_disjoint_timer_query", false, true }, // GLES2 extension. | |
589 | 597 | { "EXT_draw_buffers", false, true }, // GLES2 extension. |
590 | 598 | { "EXT_frag_depth", false, true }, // GLES2 extension. |
591 | 599 | { "EXT_framebuffer_blit", BGFX_CONFIG_RENDERER_OPENGL >= 30, true }, |
r245308 | r245309 | |
609 | 617 | { "EXT_texture_storage", false, true }, |
610 | 618 | { "EXT_texture_swizzle", false, true }, |
611 | 619 | { "EXT_texture_type_2_10_10_10_REV", false, true }, |
612 | { "EXT_timer_query", | |
620 | { "EXT_timer_query", BGFX_CONFIG_RENDERER_OPENGL >= 33, true }, | |
613 | 621 | { "EXT_unpack_subimage", false, true }, |
614 | 622 | |
615 | 623 | { "GOOGLE_depth_texture", false, true }, |
r245308 | r245309 | |
667 | 675 | { "WEBKIT_WEBGL_compressed_texture_s3tc", false, true }, |
668 | 676 | { "WEBKIT_WEBGL_depth_texture", false, true }, |
669 | 677 | }; |
678 | BX_STATIC_ASSERT(Extension::Count == BX_COUNTOF(s_extension) ); | |
670 | 679 | |
671 | 680 | static const char* s_ARB_shader_texture_lod[] = |
672 | 681 | { |
r245308 | r245309 | |
921 | 930 | return 0 == err; |
922 | 931 | } |
923 | 932 | |
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 | ||
924 | 942 | struct RendererContextGL : public RendererContextI |
925 | 943 | { |
926 | 944 | RendererContextGL() |
r245308 | r245309 | |
939 | 957 | , m_programBinarySupport(false) |
940 | 958 | , m_textureSwizzleSupport(false) |
941 | 959 | , m_depthTextureSupport(false) |
960 | , m_timerQuerySupport(false) | |
942 | 961 | , m_flip(false) |
943 | 962 | , m_hash( (BX_PLATFORM_WINDOWS<<1) | BX_ARCH_64BIT) |
944 | 963 | , m_backBufferFbo(0) |
r245308 | r245309 | |
1100 | 1119 | } |
1101 | 1120 | } |
1102 | 1121 | |
1122 | // Allow all texture filters. | |
1123 | memset(s_textureFilter, true, BX_COUNTOF(s_textureFilter) ); | |
1124 | ||
1103 | 1125 | bool bc123Supported = 0 |
1104 | 1126 | || s_extension[Extension::EXT_texture_compression_s3tc ].m_supported |
1105 | 1127 | || s_extension[Extension::MOZ_WEBGL_compressed_texture_s3tc ].m_supported |
r245308 | r245309 | |
1192 | 1214 | { |
1193 | 1215 | setTextureFormat(TextureFormat::RGBA16F, GL_RGBA, GL_RGBA, GL_HALF_FLOAT); |
1194 | 1216 | |
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 | ||
1195 | 1234 | if (BX_ENABLED(BX_PLATFORM_IOS) ) |
1196 | 1235 | { |
1197 | 1236 | setTextureFormat(TextureFormat::D16, GL_DEPTH_COMPONENT, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT); |
r245308 | r245309 | |
1353 | 1392 | || s_extension[Extension::WEBKIT_WEBGL_depth_texture].m_supported |
1354 | 1393 | ; |
1355 | 1394 | |
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 | ||
1356 | 1402 | g_caps.supported |= m_depthTextureSupport |
1357 | 1403 | ? BGFX_CAPS_TEXTURE_COMPARE_LEQUAL |
1358 | 1404 | : 0 |
r245308 | r245309 | |
1462 | 1508 | glInvalidateFramebuffer = stubInvalidateFramebuffer; |
1463 | 1509 | } |
1464 | 1510 | |
1465 | if (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGL) ) | |
1511 | if (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGL) | |
1512 | && m_timerQuerySupport) | |
1466 | 1513 | { |
1467 | 1514 | m_queries.create(); |
1468 | 1515 | } |
r245308 | r245309 | |
1492 | 1539 | |
1493 | 1540 | invalidateCache(); |
1494 | 1541 | |
1495 | if (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGL) ) | |
1542 | if (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGL) | |
1543 | && m_timerQuerySupport) | |
1496 | 1544 | { |
1497 | 1545 | m_queries.destroy(); |
1498 | 1546 | } |
r245308 | r245309 | |
2054 | 2102 | { |
2055 | 2103 | sampler = m_samplerStateCache.add(_flags); |
2056 | 2104 | |
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 | ) ); | |
2060 | 2117 | |
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) ); | |
2066 | 2122 | GL_CHECK(glSamplerParameteri(sampler, GL_TEXTURE_MIN_FILTER, minFilter) ); |
2123 | ||
2067 | 2124 | if (0 != (_flags & (BGFX_TEXTURE_MIN_ANISOTROPIC|BGFX_TEXTURE_MAG_ANISOTROPIC) ) |
2068 | 2125 | && 0.0f < m_maxAnisotropy) |
2069 | 2126 | { |
r245308 | r245309 | |
2564 | 2621 | bool m_programBinarySupport; |
2565 | 2622 | bool m_textureSwizzleSupport; |
2566 | 2623 | bool m_depthTextureSupport; |
2624 | bool m_timerQuerySupport; | |
2567 | 2625 | bool m_flip; |
2568 | 2626 | |
2569 | 2627 | uint64_t m_hash; |
r245308 | r245309 | |
2869 | 2927 | m_numPredefined = 0; |
2870 | 2928 | m_numSamplers = 0; |
2871 | 2929 | |
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 | ||
2881 | 2930 | const bool piqSupported = s_extension[Extension::ARB_program_interface_query].m_supported; |
2882 | 2931 | |
2883 | 2932 | BX_TRACE("Uniforms (%d):", activeUniforms); |
2884 | 2933 | for (int32_t ii = 0; ii < activeUniforms; ++ii) |
2885 | 2934 | { |
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 | ||
2886 | 2944 | GLenum gltype; |
2887 | 2945 | GLint num; |
2888 | 2946 | GLint loc; |
r245308 | r245309 | |
3210 | 3268 | BX_CHECK(0 != m_id, "Failed to generate texture id."); |
3211 | 3269 | GL_CHECK(glBindTexture(_target, m_id) ); |
3212 | 3270 | |
3213 | setSamplerState(_flags); | |
3214 | ||
3215 | 3271 | const TextureFormatInfo& tfi = s_textureFormat[_format]; |
3216 | m_fmt = tfi.m_fmt; | |
3272 | m_fmt = tfi.m_fmt; | |
3217 | 3273 | m_type = tfi.m_type; |
3218 | 3274 | |
3219 | 3275 | const bool compressed = isCompressed(TextureFormat::Enum(_format) ); |
r245308 | r245309 | |
3222 | 3278 | if (decompress) |
3223 | 3279 | { |
3224 | 3280 | 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; | |
3228 | 3284 | } |
3229 | 3285 | |
3286 | setSamplerState(_flags); | |
3287 | ||
3230 | 3288 | if (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGL) |
3231 | 3289 | && TextureFormat::BGRA8 == m_textureFormat |
3232 | 3290 | && GL_RGBA == m_fmt |
r245308 | r245309 | |
3591 | 3649 | |
3592 | 3650 | void TextureGL::setSamplerState(uint32_t _flags) |
3593 | 3651 | { |
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 | ||
3594 | 3668 | const uint32_t flags = (0 != (BGFX_SAMPLER_DEFAULT_FLAGS & _flags) ? m_flags : _flags) & BGFX_TEXTURE_SAMPLER_BITS_MASK; |
3595 | 3669 | if (flags != m_currentFlags) |
3596 | 3670 | { |
r245308 | r245309 | |
3611 | 3685 | GL_CHECK(glTexParameteri(target, GL_TEXTURE_WRAP_R, s_textureAddress[(flags&BGFX_TEXTURE_W_MASK)>>BGFX_TEXTURE_W_SHIFT]) ); |
3612 | 3686 | } |
3613 | 3687 | |
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) ); | |
3619 | 3692 | GL_CHECK(glTexParameteri(target, GL_TEXTURE_MIN_FILTER, minFilter) ); |
3620 | 3693 | if (0 != (flags & (BGFX_TEXTURE_MIN_ANISOTROPIC|BGFX_TEXTURE_MAG_ANISOTROPIC) ) |
3621 | 3694 | && 0.0f < s_renderGL->m_maxAnisotropy) |
r245308 | r245309 | |
4006 | 4079 | { |
4007 | 4080 | for (uint32_t ii = 0, num = g_caps.maxFBAttachments; ii < num; ++ii) |
4008 | 4081 | { |
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); | |
4012 | 4085 | } |
4013 | 4086 | |
4014 | 4087 | BGFX_FATAL(0 != fragData, Fatal::InvalidShader, "Unable to find and patch gl_FragData!"); |
r245308 | r245309 | |
4208 | 4281 | GL_CHECK(glGenFramebuffers(1, &m_fbo[1]) ); |
4209 | 4282 | GL_CHECK(glBindFramebuffer(GL_FRAMEBUFFER, m_fbo[1]) ); |
4210 | 4283 | |
4211 | for (uint32_t ii = 0, colorIdx = 0; ii < _num; ++ii) | |
4284 | colorIdx = 0; | |
4285 | for (uint32_t ii = 0; ii < _num; ++ii) | |
4212 | 4286 | { |
4213 | 4287 | TextureHandle handle = _handles[ii]; |
4214 | 4288 | if (isValid(handle) ) |
r245308 | r245309 | |
4356 | 4430 | int64_t captureElapsed = 0; |
4357 | 4431 | |
4358 | 4432 | 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) | |
4360 | 4435 | { |
4361 | 4436 | m_queries.begin(0, GL_TIME_ELAPSED); |
4362 | 4437 | } |
r245308 | r245309 | |
4401 | 4476 | ; |
4402 | 4477 | uint32_t blendFactor = 0; |
4403 | 4478 | |
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 | } | |
4406 | 4484 | PrimInfo prim = s_primInfo[primIndex]; |
4407 | 4485 | |
4408 | 4486 | uint32_t baseVertex = 0; |
r245308 | r245309 | |
4421 | 4499 | uint32_t statsNumPrimsRendered[BX_COUNTOF(s_primInfo)] = {}; |
4422 | 4500 | uint32_t statsNumInstances[BX_COUNTOF(s_primInfo)] = {}; |
4423 | 4501 | uint32_t statsNumIndices = 0; |
4502 | uint32_t statsKeyType[2] = {}; | |
4424 | 4503 | |
4425 | 4504 | if (0 == (_render->m_debug&BGFX_DEBUG_IFH) ) |
4426 | 4505 | { |
r245308 | r245309 | |
4435 | 4514 | for (int32_t item = 0, restartItem = numItems; item < numItems || restartItem < numItems;) |
4436 | 4515 | { |
4437 | 4516 | const bool isCompute = key.decode(_render->m_sortKeys[item], _render->m_viewRemap); |
4517 | statsKeyType[isCompute]++; | |
4518 | ||
4438 | 4519 | const bool viewChanged = 0 |
4439 | 4520 | || key.m_view != view |
4440 | 4521 | || item == numItems |
r245308 | r245309 | |
4794 | 4875 | && blendIndependentSupported |
4795 | 4876 | ; |
4796 | 4877 | |
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; | |
4799 | 4883 | |
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; | |
4804 | 4887 | |
4805 | const uint32_t equRGB = (equation )&0x7; | |
4806 | const uint32_t equA = (equation>>3)&0x7; | |
4807 | ||
4808 | 4888 | const uint32_t numRt = getNumRt(); |
4809 | 4889 | |
4810 | 4890 | if (!BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGL) |
r245308 | r245309 | |
4985 | 5065 | currentVao = id; |
4986 | 5066 | GL_CHECK(glBindVertexArray(id) ); |
4987 | 5067 | |
4988 | ProgramGL& program = m_program[programIdx]; | |
4989 | 5068 | program.add(hash); |
4990 | 5069 | |
4991 | 5070 | if (isValid(draw.m_vertexBuffer) ) |
r245308 | r245309 | |
5083 | 5162 | baseVertex = draw.m_startVertex; |
5084 | 5163 | const VertexBufferGL& vb = m_vertexBuffers[draw.m_vertexBuffer.idx]; |
5085 | 5164 | uint16_t decl = !isValid(vb.m_decl) ? draw.m_vertexDecl.idx : vb.m_decl.idx; |
5086 | const ProgramGL& program = m_program[programIdx]; | |
5087 | 5165 | program.bindAttributes(m_vertexDecls[decl], draw.m_startVertex); |
5088 | 5166 | |
5089 | 5167 | if (isValid(draw.m_instanceDataBuffer) ) |
r245308 | r245309 | |
5189 | 5267 | if (_render->m_debug & (BGFX_DEBUG_IFH|BGFX_DEBUG_STATS) ) |
5190 | 5268 | { |
5191 | 5269 | 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 | } | |
5197 | 5278 | |
5198 | 5279 | TextVideoMem& tvm = m_textVideoMem; |
5199 | 5280 | |
r245308 | r245309 | |
5236 | 5317 | ); |
5237 | 5318 | |
5238 | 5319 | double elapsedCpuMs = double(elapsed)*toMs; |
5239 | tvm.printf(10, pos++, 0x8e, " | |
5320 | tvm.printf(10, pos++, 0x8e, " Submitted: %4d (draw %4d, compute %4d) / CPU %3.4f [ms] %c GPU %3.4f [ms]" | |
5240 | 5321 | , _render->m_num |
5322 | , statsKeyType[0] | |
5323 | , statsKeyType[1] | |
5241 | 5324 | , elapsedCpuMs |
5242 | 5325 | , elapsedCpuMs > elapsedGpuMs ? '>' : '<' |
5243 | 5326 | , elapsedGpuMs |
5244 | 5327 | ); |
5245 | 5328 | for (uint32_t ii = 0; ii < BX_COUNTOF(s_primInfo); ++ii) |
5246 | 5329 | { |
5247 | tvm.printf(10, pos++, 0x8e, " % | |
5330 | tvm.printf(10, pos++, 0x8e, " %9s: %7d (#inst: %5d), submitted: %7d" | |
5248 | 5331 | , s_primName[ii] |
5249 | 5332 | , statsNumPrimsRendered[ii] |
5250 | 5333 | , statsNumInstances[ii] |
r245308 | r245309 | |
5257 | 5340 | tvm.printf(tvm.m_width-27, 0, 0x1f, " [F11 - RenderDoc capture] "); |
5258 | 5341 | } |
5259 | 5342 | |
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); | |
5263 | 5346 | |
5264 | 5347 | pos++; |
5265 | 5348 | tvm.printf(10, pos++, 0x8e, " State cache: "); |
r245308 | r245309 | |
---|---|---|
623 | 623 | BX_MACRO_BLOCK_BEGIN \ |
624 | 624 | /*BX_TRACE(#_call);*/ \ |
625 | 625 | _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); \ | |
629 | 629 | BX_MACRO_BLOCK_END |
630 | 630 | |
631 | 631 | #define IGNORE_GL_ERROR_CHECK(...) BX_NOOP() |
r245308 | r245309 | |
---|---|---|
218 | 218 | BX_STRINGIZE(__clang_minor__) "." \ |
219 | 219 | BX_STRINGIZE(__clang_patchlevel__) |
220 | 220 | #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 | |
222 | 224 | # define BX_COMPILER_NAME "MSVC 12.0" |
223 | 225 | # elif BX_COMPILER_MSVC >= 1700 |
224 | 226 | # define BX_COMPILER_NAME "MSVC 11.0" |
r245308 | r245309 | |
---|---|---|
30 | 30 | memset(histogram, 0, sizeof(uint16_t)*BX_RADIXSORT_HISTOGRAM_SIZE); |
31 | 31 | |
32 | 32 | 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) | |
36 | 33 | { |
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 | } | |
41 | 43 | } |
42 | 44 | |
43 | 45 | if (sorted) |
r245308 | r245309 | |
101 | 103 | memset(histogram, 0, sizeof(uint16_t)*BX_RADIXSORT_HISTOGRAM_SIZE); |
102 | 104 | |
103 | 105 | 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) | |
107 | 106 | { |
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 | } | |
112 | 116 | } |
113 | 117 | |
114 | 118 | if (sorted) |
r245308 | r245309 | |
---|---|---|
494 | 494 | } |
495 | 495 | buildoptions_cpp { |
496 | 496 | "-std=c++0x", |
497 | } | |
497 | } | |
498 | 498 | links { |
499 | 499 | "rt", |
500 | 500 | "dl", |
r245308 | r245309 | |
558 | 558 | } |
559 | 559 | buildoptions { |
560 | 560 | "-fPIC", |
561 | "-std=c++0x", | |
562 | 561 | "-no-canonical-prefixes", |
563 | 562 | "-Wa,--noexecstack", |
564 | 563 | "-fstack-protector", |
r245308 | r245309 | |
567 | 566 | "-Wunused-value", |
568 | 567 | "-Wundef", |
569 | 568 | } |
569 | buildoptions_cpp { | |
570 | "-std=c++0x", | |
571 | } | |
570 | 572 | linkoptions { |
571 | 573 | "-no-canonical-prefixes", |
572 | 574 | "-Wl,--no-undefined", |
r245308 | r245309 | |
670 | 672 | |
671 | 673 | configuration { "nacl or nacl-arm or pnacl" } |
672 | 674 | buildoptions { |
673 | "-std=c++0x", | |
674 | 675 | "-U__STRICT_ANSI__", -- strcasecmp, setenv, unsetenv,... |
675 | 676 | "-fno-stack-protector", |
676 | 677 | "-fdiagnostics-show-option", |
r245308 | r245309 | |
679 | 680 | "-Wunused-value", |
680 | 681 | "-Wundef", |
681 | 682 | } |
683 | buildoptions_cpp { | |
684 | "-std=c++0x", | |
685 | } | |
682 | 686 | includedirs { |
683 | 687 | "$(NACL_SDK_ROOT)/include", |
684 | 688 | path.join(bxDir, "include/compat/nacl"), |
r245308 | r245309 | |
831 | 835 | libdirs { path.join(_libDir, "lib/qnx-arm") } |
832 | 836 | -- includedirs { path.join(bxDir, "include/compat/qnx") } |
833 | 837 | buildoptions { |
834 | "-std=c++0x", | |
835 | 838 | "-Wno-psabi", -- note: the mangling of 'va_list' has changed in GCC 4.4.0 |
836 | 839 | "-Wunused-value", |
837 | 840 | "-Wundef", |
838 | 841 | } |
842 | buildoptions_cpp { | |
843 | "-std=c++0x", | |
844 | } | |
839 | 845 | |
840 | 846 | configuration { "rpi" } |
841 | 847 | targetdir (path.join(_buildDir, "rpi/bin")) |
r245308 | r245309 |
---|
Previous | 199869 Revisions | Next |