diff --git a/3rdparty/ocornut-imgui/imgui.cpp b/3rdparty/ocornut-imgui/imgui.cpp index eab90ad5b..bee941a49 100644 --- a/3rdparty/ocornut-imgui/imgui.cpp +++ b/3rdparty/ocornut-imgui/imgui.cpp @@ -602,6 +602,7 @@ #pragma clang diagnostic ignored "-Wmissing-noreturn" // warning : function xx could be declared with attribute 'noreturn' warning // GetDefaultFontData() asserts which some implementation makes it never return. #pragma clang diagnostic ignored "-Wdeprecated-declarations"// warning : 'xx' is deprecated: The POSIX name for this item.. // for strdup used in demo code (so user can copy & paste the code) #pragma clang diagnostic ignored "-Wint-to-void-pointer-cast" // warning : cast to 'void *' from smaller integer type 'int' +#pragma clang diagnostic ignored "-Wunused-function" // warning: 'xxxx' defined but not used #endif #ifdef __GNUC__ #pragma GCC diagnostic ignored "-Wunused-function" // warning: 'xxxx' defined but not used diff --git a/3rdparty/stb/stb_image.c b/3rdparty/stb/stb_image.c index 401895aed..ad26b74f5 100644 --- a/3rdparty/stb/stb_image.c +++ b/3rdparty/stb/stb_image.c @@ -5,6 +5,8 @@ # pragma GCC diagnostic ignored "-Wmaybe-uninitialized" # endif // __clang__ #elif defined(_MSC_VER) +# pragma warning(disable:4244) // warning C4244: '=': conversion from 'int' to 'stbi__uint16', possible loss of data +# pragma warning(disable:4245) // warning C4245: 'argument': conversion from 'int' to 'char', signed/unsigned mismatch # pragma warning(disable:4312) // warning C4312: 'type cast': conversion from '' to '' of greater size # pragma warning(disable:4456) // warning C4456: declaration of 'k' hides previous local declaration # pragma warning(disable:4457) // warning C4457: declaration of 'y' hides function parameter diff --git a/examples/01-cubes/cubes.cpp b/examples/01-cubes/cubes.cpp index 97cf60529..6854b4725 100644 --- a/examples/01-cubes/cubes.cpp +++ b/examples/01-cubes/cubes.cpp @@ -143,7 +143,7 @@ class ExampleCubes : public entry::AppI { float view[16]; bx::mtxQuatTranslationHMD(view, hmd->eye[0].rotation, eye); - bgfx::setViewTransform(0, view, hmd->eye[0].projection); + bgfx::setViewTransform(0, view, hmd->eye[0].projection, BGFX_VIEW_STEREO, hmd->eye[1].projection); // Set view 0 default viewport. // diff --git a/examples/02-metaballs/metaballs.cpp b/examples/02-metaballs/metaballs.cpp index f0f20e39c..f26e9e5af 100644 --- a/examples/02-metaballs/metaballs.cpp +++ b/examples/02-metaballs/metaballs.cpp @@ -577,7 +577,7 @@ class ExampleMetaballs : public entry::AppI { float view[16]; bx::mtxQuatTranslationHMD(view, hmd->eye[0].rotation, eye); - bgfx::setViewTransform(0, view, hmd->eye[0].projection); + bgfx::setViewTransform(0, view, hmd->eye[0].projection, BGFX_VIEW_STEREO, hmd->eye[1].projection); // Set view 0 default viewport. // diff --git a/examples/04-mesh/mesh.cpp b/examples/04-mesh/mesh.cpp index f7f8b7e96..d40df05a1 100644 --- a/examples/04-mesh/mesh.cpp +++ b/examples/04-mesh/mesh.cpp @@ -91,7 +91,7 @@ class ExampleMesh : public entry::AppI { float view[16]; bx::mtxQuatTranslationHMD(view, hmd->eye[0].rotation, eye); - bgfx::setViewTransform(0, view, hmd->eye[0].projection); + bgfx::setViewTransform(0, view, hmd->eye[0].projection, BGFX_VIEW_STEREO, hmd->eye[1].projection); // Set view 0 default viewport. // diff --git a/examples/05-instancing/instancing.cpp b/examples/05-instancing/instancing.cpp index 1a0f0b69c..342687629 100644 --- a/examples/05-instancing/instancing.cpp +++ b/examples/05-instancing/instancing.cpp @@ -160,7 +160,7 @@ class ExampleInstancing : public entry::AppI { float view[16]; bx::mtxQuatTranslationHMD(view, hmd->eye[0].rotation, eye); - bgfx::setViewTransform(0, view, hmd->eye[0].projection); + bgfx::setViewTransform(0, view, hmd->eye[0].projection, BGFX_VIEW_STEREO, hmd->eye[1].projection); // Set view 0 default viewport. // diff --git a/examples/06-bump/bump.cpp b/examples/06-bump/bump.cpp index da6cff3d7..2d9589231 100644 --- a/examples/06-bump/bump.cpp +++ b/examples/06-bump/bump.cpp @@ -225,7 +225,7 @@ class ExampleBump : public entry::AppI { float view[16]; bx::mtxQuatTranslationHMD(view, hmd->eye[0].rotation, eye); - bgfx::setViewTransform(0, view, hmd->eye[0].projection); + bgfx::setViewTransform(0, view, hmd->eye[0].projection, BGFX_VIEW_STEREO, hmd->eye[1].projection); // Set view 0 default viewport. // diff --git a/examples/12-lod/lod.cpp b/examples/12-lod/lod.cpp index c66db5a24..7e79c36b2 100644 --- a/examples/12-lod/lod.cpp +++ b/examples/12-lod/lod.cpp @@ -174,7 +174,7 @@ class ExampleLod : public entry::AppI { float view[16]; bx::mtxQuatTranslationHMD(view, hmd->eye[0].rotation, eye); - bgfx::setViewTransform(0, view, hmd->eye[0].projection); + bgfx::setViewTransform(0, view, hmd->eye[0].projection, BGFX_VIEW_STEREO, hmd->eye[1].projection); // Set view 0 default viewport. // diff --git a/examples/24-nbody/nbody.cpp b/examples/24-nbody/nbody.cpp index f04766a58..636d8f525 100644 --- a/examples/24-nbody/nbody.cpp +++ b/examples/24-nbody/nbody.cpp @@ -305,7 +305,7 @@ int _main_(int _argc, char** _argv) float tmp[16]; bx::mtxMul(tmp, view, viewHead); - bgfx::setViewTransform(0, tmp, hmd->eye[0].projection); + bgfx::setViewTransform(0, tmp, hmd->eye[0].projection, BGFX_VIEW_STEREO, hmd->eye[1].projection); // Set view 0 default viewport. // diff --git a/scripts/bgfx.lua b/scripts/bgfx.lua index e9906864b..a9685da33 100644 --- a/scripts/bgfx.lua +++ b/scripts/bgfx.lua @@ -57,6 +57,17 @@ function bgfxProject(_name, _kind, _defines) includedirs { "$(OVR_DIR)/LibOVR/Include", } + + configuration { "x32" } + libdirs { path.join("$(OVR_DIR)/LibOVR/Lib/Windows/Win32/Release", _ACTION) } + + configuration { "x64" } + libdirs { path.join("$(OVR_DIR)/LibOVR/Lib/Windows/x64/Release", _ACTION) } + + configuration { "x32 or x64" } + links { "libovr" } + + configuration {} end configuration { "Debug" } diff --git a/src/hmd_ovr.cpp b/src/hmd_ovr.cpp index e8d465e42..93733442a 100644 --- a/src/hmd_ovr.cpp +++ b/src/hmd_ovr.cpp @@ -13,7 +13,6 @@ namespace bgfx : m_hmd(NULL) , m_isenabled(false) , m_mirror(NULL) - , m_hmdFrameReady(-1) , m_frameIndex(0) , m_sensorSampleTime(0) { @@ -125,14 +124,6 @@ namespace bgfx } } - void OVR::commitEye(uint8_t _eye) - { - if (m_isenabled) - { - m_hmdFrameReady = ovr_CommitTextureSwapChain(m_hmd, m_eyeBuffers[_eye]->m_swapTextureChain); - } - } - bool OVR::swap(HMD& _hmd, bool originBottomLeft) { _hmd.flags = BGFX_HMD_NONE; @@ -144,11 +135,17 @@ namespace bgfx _hmd.deviceHeight = m_hmdDesc.Resolution.h; } - if (!m_isenabled || !OVR_SUCCESS(m_hmdFrameReady)) + if (!m_isenabled) { return false; } + // commit eyes to HMD + for (int eye = 0; eye < 2; eye++) + { + ovr_CommitTextureSwapChain(m_hmd, m_eyeBuffers[eye]->m_swapTextureChain); + } + _hmd.flags |= BGFX_HMD_RENDERING; // finish frame for current eye diff --git a/src/hmd_ovr.h b/src/hmd_ovr.h index f8d414495..525dcac90 100644 --- a/src/hmd_ovr.h +++ b/src/hmd_ovr.h @@ -72,7 +72,6 @@ namespace bgfx void renderEyeStart(uint8_t _eye); bool postReset(); void preReset(); - void commitEye(uint8_t _eye); bool swap(HMD& _hmd, bool originBottomLeft); void recenter(); void getEyePose(HMD& _hmd); @@ -84,7 +83,6 @@ namespace bgfx ovrPosef m_pose[2]; ovrVector3f m_hmdToEyeOffset[2]; ovrSizei m_hmdSize; - ovrResult m_hmdFrameReady; OVRBufferI *m_eyeBuffers[2]; OVRMirrorI *m_mirror; long long m_frameIndex; @@ -139,10 +137,6 @@ namespace bgfx _viewport->m_height = 0; } - void commitEye(uint8_t /*_eye*/) - { - } - void renderEyeStart(uint8_t /*_eye*/) { } diff --git a/src/image.cpp b/src/image.cpp index 9d337c3d4..2aa69de0a 100644 --- a/src/image.cpp +++ b/src/image.cpp @@ -252,24 +252,12 @@ namespace bgfx const uint16_t minBlockX = blockInfo.minBlockX; const uint16_t minBlockY = blockInfo.minBlockY; - _width = bx::uint16_max(blockWidth * minBlockX, ( (_width + blockWidth - 1) / blockWidth)*blockWidth); - _height = bx::uint16_max(blockHeight * minBlockY, ( (_height + blockHeight - 1) / blockHeight)*blockHeight); - _depth = bx::uint16_max(1, _depth); + _width = bx::uint16_max(blockWidth * minBlockX, ( (_width + blockWidth - 1) / blockWidth)*blockWidth); + _height = bx::uint16_max(blockHeight * minBlockY, ( (_height + blockHeight - 1) / blockHeight)*blockHeight); + _depth = bx::uint16_max(1, _depth); - uint8_t numMips = 0; - - for (uint32_t width = _width, height = _height, depth = _depth - ; blockWidth < width || blockHeight < height || 1 < depth - ; ++numMips) - { - width = bx::uint32_max(blockWidth * minBlockX, ( (width + blockWidth - 1) / blockWidth )*blockWidth); - height = bx::uint32_max(blockHeight * minBlockY, ( (height + blockHeight - 1) / blockHeight)*blockHeight); - depth = bx::uint32_max(1, depth); - - width >>= 1; - height >>= 1; - depth >>= 1; - } + uint32_t max = bx::uint32_max(_width, bx::uint32_max(_height, _depth) ); + uint8_t numMips = uint8_t(bx::flog2(float(max) ) ); return numMips; } diff --git a/src/renderer_d3d11.cpp b/src/renderer_d3d11.cpp index 6d21d1361..b8f49b01a 100644 --- a/src/renderer_d3d11.cpp +++ b/src/renderer_d3d11.cpp @@ -5077,8 +5077,6 @@ BX_PRAGMA_DIAGNOSTIC_POP(); if (m_ovr.isEnabled() ) { m_ovr.getViewport(eye, &viewState.m_rect); - // commit previous eye to HMD and start rendering new frame - m_ovr.commitEye(eye); m_ovr.renderEyeStart(eye); } else diff --git a/src/renderer_gl.cpp b/src/renderer_gl.cpp index 84afafbd5..edeabab46 100644 --- a/src/renderer_gl.cpp +++ b/src/renderer_gl.cpp @@ -5658,8 +5658,6 @@ namespace bgfx { namespace gl if (m_ovr.isEnabled() ) { m_ovr.getViewport(eye, &viewState.m_rect); - // commit previous eye to HMD and start rendering new frame - m_ovr.commitEye(eye); m_ovr.renderEyeStart(eye); } else