Browse Source

Merge branch 'master' of cane:bkaradzic/bgfx

Branimir Karadžić 9 years ago
parent
commit
ea4a0d24af

+ 1 - 0
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

+ 2 - 0
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

+ 1 - 1
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.
 				//

+ 1 - 1
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.
 				//

+ 1 - 1
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.
 				//

+ 1 - 1
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.
 					//

+ 1 - 1
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.
 				//

+ 1 - 1
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.
 				//

+ 1 - 1
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.
 				//

+ 11 - 0
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" }

+ 7 - 10
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

+ 0 - 6
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*/)
 		{
 		}

+ 5 - 17
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);
-
-		uint8_t numMips = 0;
+		_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);
 
-		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;
 	}

+ 0 - 2
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

+ 0 - 2
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