aboutsummaryrefslogtreecommitdiffstats
path: root/LibOVR/Src/Util
diff options
context:
space:
mode:
Diffstat (limited to 'LibOVR/Src/Util')
-rw-r--r--LibOVR/Src/Util/GUIConsole.h51
-rw-r--r--LibOVR/Src/Util/Util_ImageWindow.cpp231
-rw-r--r--LibOVR/Src/Util/Util_ImageWindow.h9
-rw-r--r--LibOVR/Src/Util/Util_Interface.cpp8
-rw-r--r--LibOVR/Src/Util/Util_Interface.h6
-rw-r--r--LibOVR/Src/Util/Util_LatencyTest2Reader.cpp6
-rw-r--r--LibOVR/Src/Util/Util_LatencyTest2Reader.h6
-rw-r--r--LibOVR/Src/Util/Util_LatencyTest2State.h6
-rw-r--r--LibOVR/Src/Util/Util_Render_Stereo.cpp260
-rw-r--r--LibOVR/Src/Util/Util_Render_Stereo.h22
-rw-r--r--LibOVR/Src/Util/Util_SystemInfo.cpp289
-rw-r--r--LibOVR/Src/Util/Util_SystemInfo.h44
-rw-r--r--LibOVR/Src/Util/Util_SystemInfo_OSX.mm212
13 files changed, 918 insertions, 232 deletions
diff --git a/LibOVR/Src/Util/GUIConsole.h b/LibOVR/Src/Util/GUIConsole.h
new file mode 100644
index 0000000..a1b35ed
--- /dev/null
+++ b/LibOVR/Src/Util/GUIConsole.h
@@ -0,0 +1,51 @@
+/************************************************************************************
+
+Filename : GUIConsole.h
+Content : A stdout console window that runs alongside Windows GUI applications
+Created : Feb 4, 2013
+Authors : Brant Lewis
+
+Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved.
+
+Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License");
+you may not use the Oculus VR Rift SDK except in compliance with the License,
+which is provided at the time of installation or download, or which
+otherwise accompanies this software in either electronic or hard copy form.
+
+You may obtain a copy of the License at
+
+http://www.oculusvr.com/licenses/LICENSE-3.2
+
+Unless required by applicable law or agreed to in writing, the Oculus VR SDK
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+*************************************************************************************/
+
+#ifndef GUICONSOLE_H
+#define GUICONSOLE_H
+
+#include "../../Include/OVR_Kernel.h"
+
+#ifdef OVR_INTERNAL_USE
+
+#include <WinSock2.h>
+#include <WS2tcpip.h>
+#define WIN32_LEAN_AND_MEAN
+#include <Windows.h>
+
+class GUIConsole
+{
+public:
+ // constructors
+ GUIConsole();
+ ~GUIConsole();
+
+ // member variables
+ HANDLE hStdIn, hStdOut, hStdError;
+};
+#endif // #ifdef OVR_INTERNAL_USE
+
+#endif
diff --git a/LibOVR/Src/Util/Util_ImageWindow.cpp b/LibOVR/Src/Util/Util_ImageWindow.cpp
index d937a25..4c120f9 100644
--- a/LibOVR/Src/Util/Util_ImageWindow.cpp
+++ b/LibOVR/Src/Util/Util_ImageWindow.cpp
@@ -5,16 +5,16 @@ Content : An output object for windows that can display raw images for tes
Created : March 13, 2014
Authors : Dean Beeler
-Copyright : Copyright 2014 Oculus VR, Inc. All Rights reserved.
+Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved.
-Licensed under the Oculus VR Rift SDK License Version 3.1 (the "License");
+Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License");
you may not use the Oculus VR Rift SDK except in compliance with the License,
which is provided at the time of installation or download, or which
otherwise accompanies this software in either electronic or hard copy form.
You may obtain a copy of the License at
-http://www.oculusvr.com/licenses/LICENSE-3.1
+http://www.oculusvr.com/licenses/LICENSE-3.2
Unless required by applicable law or agreed to in writing, the Oculus VR SDK
distributed under the License is distributed on an "AS IS" BASIS,
@@ -52,6 +52,8 @@ namespace OVR { namespace Util {
ID2D1Factory* ImageWindow::pD2DFactory = NULL;
IDWriteFactory* ImageWindow::pDWriteFactory = NULL;
+HINSTANCE ImageWindow::hInstD2d1 = NULL;
+HINSTANCE ImageWindow::hInstDwrite = NULL;
// TODO(review): This appears to be (at present) necessary, the global list is accessed by the
@@ -103,24 +105,37 @@ LRESULT CALLBACK MainWndProc(
//return 0;
}
+
ImageWindow::ImageWindow( uint32_t width, uint32_t height ) :
- frontBufferMutex( new Mutex() )
+ hWindow(NULL),
+ pRT(NULL),
+ //resolution(),
+ frontBufferMutex( new Mutex() ),
+ frames(),
+ greyBitmap(NULL),
+ colorBitmap(NULL)
{
-
- HINSTANCE hInst = LoadLibrary( L"d2d1.dll" );
- HINSTANCE hInstWrite = LoadLibrary( L"Dwrite.dll" );
-
D2D1CreateFactoryFn createFactory = NULL;
DWriteCreateFactoryFn writeFactory = NULL;
- if( hInst )
+ if (!hInstD2d1)
+ {
+ hInstD2d1 = LoadLibraryW( L"d2d1.dll" );
+ }
+
+ if (!hInstD2d1)
+ {
+ hInstD2d1 = LoadLibraryW( L"Dwrite.dll" );
+ }
+
+ if( hInstD2d1 )
{
- createFactory = (D2D1CreateFactoryFn)GetProcAddress( hInst, "D2D1CreateFactory" );
+ createFactory = (D2D1CreateFactoryFn)GetProcAddress( hInstD2d1, "D2D1CreateFactory" );
}
- if( hInstWrite )
+ if( hInstDwrite )
{
- writeFactory = (DWriteCreateFactoryFn)GetProcAddress( hInstWrite, "DWriteCreateFactory" );
+ writeFactory = (DWriteCreateFactoryFn)GetProcAddress( hInstDwrite, "DWriteCreateFactory" );
}
// TODO: see note where globalWindow is declared.
@@ -129,29 +144,30 @@ ImageWindow::ImageWindow( uint32_t width, uint32_t height ) :
if( pD2DFactory == NULL && createFactory && writeFactory )
{
- createFactory(
+ // Create a Direct2D factory.
+ HRESULT hResult = createFactory(
D2D1_FACTORY_TYPE_MULTI_THREADED,
__uuidof(ID2D1Factory),
NULL,
- &pD2DFactory
+ &pD2DFactory // This will be AddRef'd for us.
);
+ OVR_ASSERT_AND_UNUSED(hResult == S_OK, hResult);
// Create a DirectWrite factory.
- writeFactory(
+ hResult = writeFactory(
DWRITE_FACTORY_TYPE_SHARED,
- __uuidof(pDWriteFactory),
- reinterpret_cast<IUnknown **>(&pDWriteFactory)
+ __uuidof(pDWriteFactory), // This probably should instead be __uuidof(IDWriteFactory)
+ reinterpret_cast<IUnknown **>(&pDWriteFactory) // This will be AddRef'd for us.
);
-
+ OVR_ASSERT_AND_UNUSED(hResult == S_OK, hResult);
}
resolution = D2D1::SizeU( width, height );
- SetWindowLongPtr( hWindow, GWLP_USERDATA, (LONG_PTR)this );
-
- pRT = NULL;
- greyBitmap = NULL;
- colorBitmap = NULL;
+ if (hWindow)
+ {
+ SetWindowLongPtr( hWindow, GWLP_USERDATA, (LONG_PTR)this );
+ }
}
ImageWindow::~ImageWindow()
@@ -185,83 +201,112 @@ ImageWindow::~ImageWindow()
delete frontBufferMutex;
- ShowWindow( hWindow, SW_HIDE );
- DestroyWindow( hWindow );
-}
-
-void ImageWindow::AssociateSurface( void* surface )
-{
- // Assume an IUnknown
- IUnknown* unknown = (IUnknown*)surface;
-
- IDXGISurface *pDxgiSurface = NULL;
- HRESULT hr = unknown->QueryInterface(&pDxgiSurface);
- if( hr == S_OK )
- {
- D2D1_RENDER_TARGET_PROPERTIES props =
- D2D1::RenderTargetProperties(
- D2D1_RENDER_TARGET_TYPE_DEFAULT,
- D2D1::PixelFormat(DXGI_FORMAT_UNKNOWN, D2D1_ALPHA_MODE_PREMULTIPLIED),
- 96,
- 96
- );
-
+ if (hWindow)
+ {
+ ShowWindow( hWindow, SW_HIDE );
+ DestroyWindow( hWindow );
+ }
- pRT = NULL;
- ID2D1RenderTarget* tmpTarget;
+ if (pD2DFactory)
+ {
+ pD2DFactory->Release();
+ pD2DFactory = NULL;
+ }
- hr = pD2DFactory->CreateDxgiSurfaceRenderTarget( pDxgiSurface, &props, &tmpTarget );
+ if (pDWriteFactory)
+ {
+ pDWriteFactory->Release();
+ pDWriteFactory = NULL;
+ }
- if( hr == S_OK )
- {
- DXGI_SURFACE_DESC desc = {0};
- pDxgiSurface->GetDesc( &desc );
- int width = desc.Width;
- int height = desc.Height;
-
- D2D1_SIZE_U size = D2D1::SizeU( width, height );
-
- D2D1_PIXEL_FORMAT pixelFormat = D2D1::PixelFormat(
- DXGI_FORMAT_A8_UNORM,
- D2D1_ALPHA_MODE_PREMULTIPLIED
- );
-
- D2D1_PIXEL_FORMAT colorPixelFormat = D2D1::PixelFormat(
- DXGI_FORMAT_B8G8R8A8_UNORM,
- D2D1_ALPHA_MODE_PREMULTIPLIED
- );
-
- D2D1_BITMAP_PROPERTIES bitmapProps;
- bitmapProps.dpiX = 96;
- bitmapProps.dpiY = 96;
- bitmapProps.pixelFormat = pixelFormat;
-
- D2D1_BITMAP_PROPERTIES colorBitmapProps;
- colorBitmapProps.dpiX = 96;
- colorBitmapProps.dpiY = 96;
- colorBitmapProps.pixelFormat = colorPixelFormat;
-
- HRESULT result = tmpTarget->CreateBitmap( size, bitmapProps, &greyBitmap );
- if( result != S_OK )
- {
- tmpTarget->Release();
- tmpTarget = NULL;
- }
+ if( hInstD2d1 )
+ {
+ FreeLibrary(hInstD2d1);
+ hInstD2d1 = NULL;
+ }
- if (tmpTarget)
- {
- result = tmpTarget->CreateBitmap(size, colorBitmapProps, &colorBitmap);
- if (result != S_OK)
- {
- tmpTarget->Release();
- tmpTarget = NULL;
- }
- }
- pRT = tmpTarget;
- }
+ if( hInstDwrite )
+ {
+ FreeLibrary(hInstDwrite);
+ hInstDwrite = NULL;
}
}
+void ImageWindow::AssociateSurface( void* surface )
+{
+ if (pD2DFactory)
+ {
+ // Assume an IUnknown
+ IUnknown* unknown = (IUnknown*)surface;
+
+ IDXGISurface *pDxgiSurface = NULL;
+ HRESULT hr = unknown->QueryInterface(&pDxgiSurface);
+ if( hr == S_OK )
+ {
+ D2D1_RENDER_TARGET_PROPERTIES props =
+ D2D1::RenderTargetProperties(
+ D2D1_RENDER_TARGET_TYPE_DEFAULT,
+ D2D1::PixelFormat(DXGI_FORMAT_UNKNOWN, D2D1_ALPHA_MODE_PREMULTIPLIED),
+ 96,
+ 96
+ );
+
+ pRT = NULL;
+ ID2D1RenderTarget* tmpTarget;
+
+ hr = pD2DFactory->CreateDxgiSurfaceRenderTarget( pDxgiSurface, &props, &tmpTarget );
+
+ if( hr == S_OK )
+ {
+ DXGI_SURFACE_DESC desc = {0};
+ pDxgiSurface->GetDesc( &desc );
+ int width = desc.Width;
+ int height = desc.Height;
+
+ D2D1_SIZE_U size = D2D1::SizeU( width, height );
+
+ D2D1_PIXEL_FORMAT pixelFormat = D2D1::PixelFormat(
+ DXGI_FORMAT_A8_UNORM,
+ D2D1_ALPHA_MODE_PREMULTIPLIED
+ );
+
+ D2D1_PIXEL_FORMAT colorPixelFormat = D2D1::PixelFormat(
+ DXGI_FORMAT_B8G8R8A8_UNORM,
+ D2D1_ALPHA_MODE_PREMULTIPLIED
+ );
+
+ D2D1_BITMAP_PROPERTIES bitmapProps;
+ bitmapProps.dpiX = 96;
+ bitmapProps.dpiY = 96;
+ bitmapProps.pixelFormat = pixelFormat;
+
+ D2D1_BITMAP_PROPERTIES colorBitmapProps;
+ colorBitmapProps.dpiX = 96;
+ colorBitmapProps.dpiY = 96;
+ colorBitmapProps.pixelFormat = colorPixelFormat;
+
+ HRESULT result = tmpTarget->CreateBitmap( size, bitmapProps, &greyBitmap );
+ if( result != S_OK )
+ {
+ tmpTarget->Release();
+ tmpTarget = NULL;
+ }
+
+ if (tmpTarget)
+ {
+ result = tmpTarget->CreateBitmap(size, colorBitmapProps, &colorBitmap);
+ if (result != S_OK)
+ {
+ tmpTarget->Release();
+ tmpTarget = NULL;
+ }
+ }
+ pRT = tmpTarget;
+ }
+ }
+ }
+}
+
void ImageWindow::Process()
{
if( pRT && greyBitmap )
diff --git a/LibOVR/Src/Util/Util_ImageWindow.h b/LibOVR/Src/Util/Util_ImageWindow.h
index 901626d..979dd93 100644
--- a/LibOVR/Src/Util/Util_ImageWindow.h
+++ b/LibOVR/Src/Util/Util_ImageWindow.h
@@ -7,14 +7,14 @@ Authors : Dean Beeler
Copyright : Copyright 2014 Oculus, Inc. All Rights reserved.
-Licensed under the Oculus VR Rift SDK License Version 3.1 (the "License");
+Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License");
you may not use the Oculus VR Rift SDK except in compliance with the License,
which is provided at the time of installation or download, or which
otherwise accompanies this software in either electronic or hard copy form.
You may obtain a copy of the License at
-http://www.oculusvr.com/licenses/LICENSE-3.1
+http://www.oculusvr.com/licenses/LICENSE-3.2
Unless required by applicable law or agreed to in writing, the Oculus VR SDK
distributed under the License is distributed on an "AS IS" BASIS,
@@ -155,6 +155,9 @@ private:
static int windowCount;
static ID2D1Factory* pD2DFactory;
static IDWriteFactory* pDWriteFactory;
+ static HINSTANCE hInstD2d1;
+ static HINSTANCE hInstDwrite;
+
};
#else
@@ -198,4 +201,4 @@ private:
}} // namespace OVR::Util
-#endif \ No newline at end of file
+#endif
diff --git a/LibOVR/Src/Util/Util_Interface.cpp b/LibOVR/Src/Util/Util_Interface.cpp
index d96423c..5090729 100644
--- a/LibOVR/Src/Util/Util_Interface.cpp
+++ b/LibOVR/Src/Util/Util_Interface.cpp
@@ -8,16 +8,16 @@ Content : Simple interface, utilised by internal demos,
Created : February 20, 2014
Authors : Tom Heath
-Copyright : Copyright 2014 Oculus VR, Inc. All Rights reserved.
+Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved.
-Licensed under the Oculus VR Rift SDK License Version 3.1 (the "License");
+Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License");
you may not use the Oculus VR Rift SDK except in compliance with the License,
which is provided at the time of installation or download, or which
otherwise accompanies this software in either electronic or hard copy form.
You may obtain a copy of the License at
-http://www.oculusvr.com/licenses/LICENSE-3.1
+http://www.oculusvr.com/licenses/LICENSE-3.2
Unless required by applicable law or agreed to in writing, the Oculus VR SDK
distributed under the License is distributed on an "AS IS" BASIS,
@@ -31,4 +31,4 @@ limitations under the License.
-//Files left in to ease its possible return...... \ No newline at end of file
+//Files left in to ease its possible return......
diff --git a/LibOVR/Src/Util/Util_Interface.h b/LibOVR/Src/Util/Util_Interface.h
index fbb7d25..ab08715 100644
--- a/LibOVR/Src/Util/Util_Interface.h
+++ b/LibOVR/Src/Util/Util_Interface.h
@@ -8,16 +8,16 @@ Content : Simple interface, utilised by internal demos,
Created : February 20, 2014
Authors : Tom Heath
-Copyright : Copyright 2014 Oculus VR, Inc. All Rights reserved.
+Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved.
-Licensed under the Oculus VR Rift SDK License Version 3.1 (the "License");
+Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License");
you may not use the Oculus VR Rift SDK except in compliance with the License,
which is provided at the time of installation or download, or which
otherwise accompanies this software in either electronic or hard copy form.
You may obtain a copy of the License at
-http://www.oculusvr.com/licenses/LICENSE-3.1
+http://www.oculusvr.com/licenses/LICENSE-3.2
Unless required by applicable law or agreed to in writing, the Oculus VR SDK
distributed under the License is distributed on an "AS IS" BASIS,
diff --git a/LibOVR/Src/Util/Util_LatencyTest2Reader.cpp b/LibOVR/Src/Util/Util_LatencyTest2Reader.cpp
index 493f779..e34bf19 100644
--- a/LibOVR/Src/Util/Util_LatencyTest2Reader.cpp
+++ b/LibOVR/Src/Util/Util_LatencyTest2Reader.cpp
@@ -5,16 +5,16 @@ Content : Shared functionality for the DK2 latency tester
Created : July 8, 2014
Authors : Volga Aksoy, Chris Taylor
-Copyright : Copyright 2014 Oculus VR, Inc. All Rights reserved.
+Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved.
-Licensed under the Oculus VR Rift SDK License Version 3.1 (the "License");
+Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License");
you may not use the Oculus VR Rift SDK except in compliance with the License,
which is provided at the time of installation or download, or which
otherwise accompanies this software in either electronic or hard copy form.
You may obtain a copy of the License at
-http://www.oculusvr.com/licenses/LICENSE-3.1
+http://www.oculusvr.com/licenses/LICENSE-3.2
Unless required by applicable law or agreed to in writing, the Oculus VR SDK
distributed under the License is distributed on an "AS IS" BASIS,
diff --git a/LibOVR/Src/Util/Util_LatencyTest2Reader.h b/LibOVR/Src/Util/Util_LatencyTest2Reader.h
index 57f70be..1863e62 100644
--- a/LibOVR/Src/Util/Util_LatencyTest2Reader.h
+++ b/LibOVR/Src/Util/Util_LatencyTest2Reader.h
@@ -5,16 +5,16 @@ Content : Shared functionality for the DK2 latency tester
Created : July 8, 2014
Authors : Volga Aksoy, Chris Taylor
-Copyright : Copyright 2014 Oculus VR, Inc. All Rights reserved.
+Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved.
-Licensed under the Oculus VR Rift SDK License Version 3.1 (the "License");
+Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License");
you may not use the Oculus VR Rift SDK except in compliance with the License,
which is provided at the time of installation or download, or which
otherwise accompanies this software in either electronic or hard copy form.
You may obtain a copy of the License at
-http://www.oculusvr.com/licenses/LICENSE-3.1
+http://www.oculusvr.com/licenses/LICENSE-3.2
Unless required by applicable law or agreed to in writing, the Oculus VR SDK
distributed under the License is distributed on an "AS IS" BASIS,
diff --git a/LibOVR/Src/Util/Util_LatencyTest2State.h b/LibOVR/Src/Util/Util_LatencyTest2State.h
index 3ea4e76..0b4ffd6 100644
--- a/LibOVR/Src/Util/Util_LatencyTest2State.h
+++ b/LibOVR/Src/Util/Util_LatencyTest2State.h
@@ -5,16 +5,16 @@ Content : Shared functionality for the DK2 latency tester
Created : July 8, 2014
Authors : Volga Aksoy, Chris Taylor
-Copyright : Copyright 2014 Oculus VR, Inc. All Rights reserved.
+Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved.
-Licensed under the Oculus VR Rift SDK License Version 3.1 (the "License");
+Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License");
you may not use the Oculus VR Rift SDK except in compliance with the License,
which is provided at the time of installation or download, or which
otherwise accompanies this software in either electronic or hard copy form.
You may obtain a copy of the License at
-http://www.oculusvr.com/licenses/LICENSE-3.1
+http://www.oculusvr.com/licenses/LICENSE-3.2
Unless required by applicable law or agreed to in writing, the Oculus VR SDK
distributed under the License is distributed on an "AS IS" BASIS,
diff --git a/LibOVR/Src/Util/Util_Render_Stereo.cpp b/LibOVR/Src/Util/Util_Render_Stereo.cpp
index 1389462..b5b9b8a 100644
--- a/LibOVR/Src/Util/Util_Render_Stereo.cpp
+++ b/LibOVR/Src/Util/Util_Render_Stereo.cpp
@@ -5,16 +5,16 @@ Content : Stereo rendering configuration implementation
Created : October 22, 2012
Authors : Michael Antonov, Andrew Reisse, Tom Forsyth
-Copyright : Copyright 2014 Oculus VR, Inc. All Rights reserved.
+Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved.
-Licensed under the Oculus VR Rift SDK License Version 3.1 (the "License");
+Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License");
you may not use the Oculus VR Rift SDK except in compliance with the License,
which is provided at the time of installation or download, or which
otherwise accompanies this software in either electronic or hard copy form.
You may obtain a copy of the License at
-http://www.oculusvr.com/licenses/LICENSE-3.1
+http://www.oculusvr.com/licenses/LICENSE-3.2
Unless required by applicable law or agreed to in writing, the Oculus VR SDK
distributed under the License is distributed on an "AS IS" BASIS,
@@ -38,21 +38,21 @@ char const* GetDebugNameEyeCupType ( EyeCupType eyeCupType )
{
switch ( eyeCupType )
{
- case EyeCup_DK1A: return "DK1 A"; break;
- case EyeCup_DK1B: return "DK1 B"; break;
- case EyeCup_DK1C: return "DK1 C"; break;
- case EyeCup_DKHD2A: return "DKHD2 A"; break;
- case EyeCup_OrangeA: return "Orange A"; break;
- case EyeCup_RedA: return "Red A"; break;
- case EyeCup_PinkA: return "Pink A"; break;
- case EyeCup_BlueA: return "Blue A"; break;
- case EyeCup_Delilah1A: return "Delilah 1 A"; break;
- case EyeCup_Delilah2A: return "Delilah 2 A"; break;
- case EyeCup_JamesA: return "James A"; break;
- case EyeCup_SunMandalaA: return "Sun Mandala A"; break;
- case EyeCup_DK2A: return "DK2 A"; break;
- case EyeCup_LAST: return "LAST"; break;
- default: OVR_ASSERT ( false ); return "Error"; break;
+ case EyeCup_DK1A: return "DK1 A";
+ case EyeCup_DK1B: return "DK1 B";
+ case EyeCup_DK1C: return "DK1 C";
+ case EyeCup_DKHD2A: return "DKHD2 A";
+ case EyeCup_OrangeA: return "Orange A";
+ case EyeCup_RedA: return "Red A";
+ case EyeCup_PinkA: return "Pink A";
+ case EyeCup_BlueA: return "Blue A";
+ case EyeCup_Delilah1A: return "Delilah 1 A";
+ case EyeCup_Delilah2A: return "Delilah 2 A";
+ case EyeCup_JamesA: return "James A";
+ case EyeCup_SunMandalaA: return "Sun Mandala A";
+ case EyeCup_DK2A: return "DK2 A";
+ case EyeCup_LAST: return "LAST";
+ default: OVR_ASSERT ( false ); return "Error";
}
}
@@ -60,17 +60,17 @@ char const* GetDebugNameHmdType ( HmdTypeEnum hmdType )
{
switch ( hmdType )
{
- case HmdType_None: return "None"; break;
- case HmdType_DK1: return "DK1"; break;
- case HmdType_DKProto: return "DK1 prototype"; break;
- case HmdType_DKHDProto: return "DK HD prototype 1"; break;
- case HmdType_DKHDProto566Mi: return "DK HD prototype 566 Mi"; break;
- case HmdType_DKHD2Proto: return "DK HD prototype 585"; break;
- case HmdType_CrystalCoveProto: return "Crystal Cove"; break;
- case HmdType_DK2: return "DK2"; break;
- case HmdType_Unknown: return "Unknown"; break;
- case HmdType_LAST: return "LAST"; break;
- default: OVR_ASSERT ( false ); return "Error"; break;
+ case HmdType_None: return "None";
+ case HmdType_DK1: return "DK1";
+ case HmdType_DKProto: return "DK1 prototype";
+ case HmdType_DKHDProto: return "DK HD prototype 1";
+ case HmdType_DKHDProto566Mi: return "DK HD prototype 566 Mi";
+ case HmdType_DKHD2Proto: return "DK HD prototype 585";
+ case HmdType_CrystalCoveProto: return "Crystal Cove";
+ case HmdType_DK2: return "DK2";
+ case HmdType_Unknown: return "Unknown";
+ case HmdType_LAST: return "LAST";
+ default: OVR_ASSERT ( false ); return "Error";
}
}
@@ -206,7 +206,7 @@ static StereoEyeParams CalculateStereoEyeParamsInternal ( StereoEye eyeType, Hmd
StereoEyeParams result;
result.Eye = eyeType;
- result.ViewAdjust = Matrix4f::Translation(virtualCameraOffset);
+ result.HmdToEyeViewOffset = Matrix4f::Translation(virtualCameraOffset);
result.Distortion = distortion;
result.DistortionViewport = distortedViewport;
result.Fov = fov;
@@ -790,6 +790,90 @@ static const int DMA_NumTrisPerEye = (DMA_GridSize)*(DMA_GridSize)*2;
+DistortionMeshVertexData DistortionMeshMakeVertex ( Vector2f screenNDC,
+ bool rightEye,
+ const HmdRenderInfo &hmdRenderInfo,
+ const DistortionRenderDesc &distortion, const ScaleAndOffset2D &eyeToSourceNDC )
+{
+ DistortionMeshVertexData result;
+
+ float xOffset = 0.0f;
+ if (rightEye)
+ {
+ xOffset = 1.0f;
+ }
+
+ Vector2f tanEyeAnglesR, tanEyeAnglesG, tanEyeAnglesB;
+ TransformScreenNDCToTanFovSpaceChroma ( &tanEyeAnglesR, &tanEyeAnglesG, &tanEyeAnglesB,
+ distortion, screenNDC );
+
+ result.TanEyeAnglesR = tanEyeAnglesR;
+ result.TanEyeAnglesG = tanEyeAnglesG;
+ result.TanEyeAnglesB = tanEyeAnglesB;
+
+ HmdShutterTypeEnum shutterType = hmdRenderInfo.Shutter.Type;
+ switch ( shutterType )
+ {
+ case HmdShutter_Global:
+ result.TimewarpLerp = 0.0f;
+ break;
+ case HmdShutter_RollingLeftToRight:
+ // Retrace is left to right - left eye goes 0.0 -> 0.5, then right goes 0.5 -> 1.0
+ result.TimewarpLerp = screenNDC.x * 0.25f + 0.25f;
+ if (rightEye)
+ {
+ result.TimewarpLerp += 0.5f;
+ }
+ break;
+ case HmdShutter_RollingRightToLeft:
+ // Retrace is right to left - right eye goes 0.0 -> 0.5, then left goes 0.5 -> 1.0
+ result.TimewarpLerp = 0.75f - screenNDC.x * 0.25f;
+ if (rightEye)
+ {
+ result.TimewarpLerp -= 0.5f;
+ }
+ break;
+ case HmdShutter_RollingTopToBottom:
+ // Retrace is top to bottom on both eyes at the same time.
+ result.TimewarpLerp = screenNDC.y * 0.5f + 0.5f;
+ break;
+ default: OVR_ASSERT ( false ); break;
+ }
+
+ // When does the fade-to-black edge start? Chosen heuristically.
+ const float fadeOutBorderFractionTexture = 0.3f;
+ const float fadeOutBorderFractionTextureInnerEdge = 0.1f;
+ const float fadeOutBorderFractionScreen = 0.1f;
+
+ // Fade out at texture edges.
+ // The furthest out will be the blue channel, because of chromatic aberration (true of any standard lens)
+ Vector2f sourceTexCoordBlueNDC = TransformTanFovSpaceToRendertargetNDC ( eyeToSourceNDC, tanEyeAnglesB );
+ if (rightEye)
+ {
+ // The inner edge of the eye texture is usually much more magnified, because it's right against the middle of the screen, not the FOV edge.
+ // So we want a different scaling factor for that. This code flips the texture NDC so that +1.0 is the inner edge
+ sourceTexCoordBlueNDC.x = -sourceTexCoordBlueNDC.x;
+ }
+ float edgeFadeIn = ( 1.0f / fadeOutBorderFractionTextureInnerEdge ) * ( 1.0f - sourceTexCoordBlueNDC.x ) ; // Inner
+ edgeFadeIn = Alg::Min ( edgeFadeIn, ( 1.0f / fadeOutBorderFractionTexture ) * ( 1.0f + sourceTexCoordBlueNDC.x ) ); // Outer
+ edgeFadeIn = Alg::Min ( edgeFadeIn, ( 1.0f / fadeOutBorderFractionTexture ) * ( 1.0f - sourceTexCoordBlueNDC.y ) ); // Upper
+ edgeFadeIn = Alg::Min ( edgeFadeIn, ( 1.0f / fadeOutBorderFractionTexture ) * ( 1.0f + sourceTexCoordBlueNDC.y ) ); // Lower
+
+ // Also fade out at screen edges. Since this is in pixel space, no need to do inner specially.
+ float edgeFadeInScreen = ( 1.0f / fadeOutBorderFractionScreen ) *
+ ( 1.0f - Alg::Max ( Alg::Abs ( screenNDC.x ), Alg::Abs ( screenNDC.y ) ) );
+ edgeFadeIn = Alg::Min ( edgeFadeInScreen, edgeFadeIn );
+
+ // Note - this is NOT clamped negatively.
+ // For rendering methods that interpolate over a coarse grid, we need the values to go negative for correct intersection with zero.
+ result.Shade = Alg::Min ( edgeFadeIn, 1.0f );
+ result.ScreenPosNDC.x = 0.5f * screenNDC.x - 0.5f + xOffset;
+ result.ScreenPosNDC.y = -screenNDC.y;
+
+ return result;
+}
+
+
void DistortionMeshDestroy ( DistortionMeshVertexData *pVertices, uint16_t *pTriangleMeshIndices )
{
OVR_FREE ( pVertices );
@@ -844,20 +928,9 @@ void DistortionMeshCreate( DistortionMeshVertexData **ppVertices, uint16_t **ppT
return;
}
- // When does the fade-to-black edge start? Chosen heuristically.
- const float fadeOutBorderFraction = 0.075f;
// Populate vertex buffer info
- float xOffset = 0.0f;
- float uOffset = 0.0f;
- OVR_UNUSED(uOffset);
-
- if (rightEye)
- {
- xOffset = 1.0f;
- uOffset = 0.5f;
- }
// First pass - build up raw vertex data.
DistortionMeshVertexData* pcurVert = *ppVertices;
@@ -881,59 +954,8 @@ void DistortionMeshCreate( DistortionMeshVertexData **ppVertices, uint16_t **ppT
screenNDC.x = Alg::Max ( -1.0f, Alg::Min ( screenNDC.x, 1.0f ) );
screenNDC.y = Alg::Max ( -1.0f, Alg::Min ( screenNDC.y, 1.0f ) );
- // From those screen positions, we then need (effectively) RGB UVs.
- // This is the function that actually matters when doing the distortion calculation.
- Vector2f tanEyeAnglesR, tanEyeAnglesG, tanEyeAnglesB;
- TransformScreenNDCToTanFovSpaceChroma ( &tanEyeAnglesR, &tanEyeAnglesG, &tanEyeAnglesB,
- distortion, screenNDC );
-
- pcurVert->TanEyeAnglesR = tanEyeAnglesR;
- pcurVert->TanEyeAnglesG = tanEyeAnglesG;
- pcurVert->TanEyeAnglesB = tanEyeAnglesB;
-
- HmdShutterTypeEnum shutterType = hmdRenderInfo.Shutter.Type;
- switch ( shutterType )
- {
- case HmdShutter_Global:
- pcurVert->TimewarpLerp = 0.0f;
- break;
- case HmdShutter_RollingLeftToRight:
- // Retrace is left to right - left eye goes 0.0 -> 0.5, then right goes 0.5 -> 1.0
- pcurVert->TimewarpLerp = screenNDC.x * 0.25f + 0.25f;
- if (rightEye)
- {
- pcurVert->TimewarpLerp += 0.5f;
- }
- break;
- case HmdShutter_RollingRightToLeft:
- // Retrace is right to left - right eye goes 0.0 -> 0.5, then left goes 0.5 -> 1.0
- pcurVert->TimewarpLerp = 0.75f - screenNDC.x * 0.25f;
- if (rightEye)
- {
- pcurVert->TimewarpLerp -= 0.5f;
- }
- break;
- case HmdShutter_RollingTopToBottom:
- // Retrace is top to bottom on both eyes at the same time.
- pcurVert->TimewarpLerp = screenNDC.y * 0.5f + 0.5f;
- break;
- default: OVR_ASSERT ( false ); break;
- }
-
- // Fade out at texture edges.
- // The furthest out will be the blue channel, because of chromatic aberration (true of any standard lens)
- Vector2f sourceTexCoordBlueNDC = TransformTanFovSpaceToRendertargetNDC ( eyeToSourceNDC, tanEyeAnglesB );
- float edgeFadeIn = ( 1.0f / fadeOutBorderFraction ) *
- ( 1.0f - Alg::Max ( Alg::Abs ( sourceTexCoordBlueNDC.x ), Alg::Abs ( sourceTexCoordBlueNDC.y ) ) );
- // Also fade out at screen edges.
- float edgeFadeInScreen = ( 2.0f / fadeOutBorderFraction ) *
- ( 1.0f - Alg::Max ( Alg::Abs ( screenNDC.x ), Alg::Abs ( screenNDC.y ) ) );
- edgeFadeIn = Alg::Min ( edgeFadeInScreen, edgeFadeIn );
-
- pcurVert->Shade = Alg::Max ( 0.0f, Alg::Min ( edgeFadeIn, 1.0f ) );
- pcurVert->ScreenPosNDC.x = 0.5f * screenNDC.x - 0.5f + xOffset;
- pcurVert->ScreenPosNDC.y = -screenNDC.y;
-
+ // From those screen positions, generate the vertex.
+ *pcurVert = DistortionMeshMakeVertex ( screenNDC, rightEye, hmdRenderInfo, distortion, eyeToSourceNDC );
pcurVert++;
}
}
@@ -1071,15 +1093,8 @@ void HeightmapMeshCreate( HeightmapMeshVertexData **ppVertices, uint16_t **ppTri
}
// Populate vertex buffer info
- //float xOffset = 0.0f; Not currently used.
- //float uOffset = 0.0f;
-
- //if (rightEye)
- //{
- // xOffset = 1.0f;
- // uOffset = 0.5f;
- //}
-
+ // float xOffset = (rightEye ? 1.0f : 0.0f); Currently disabled because its usage is disabled below.
+
// First pass - build up raw vertex data.
HeightmapMeshVertexData* pcurVert = *ppVertices;
@@ -1277,10 +1292,10 @@ PredictionValues PredictionGetDeviceValues ( const HmdRenderInfo &hmdRenderInfo,
return result;
}
-Matrix4f TimewarpComputePoseDelta ( Matrix4f const &renderedViewFromWorld, Matrix4f const &predictedViewFromWorld, Matrix4f const&eyeViewAdjust )
+Matrix4f TimewarpComputePoseDelta ( Matrix4f const &renderedViewFromWorld, Matrix4f const &predictedViewFromWorld, Matrix4f const&hmdToEyeViewOffset )
{
- Matrix4f worldFromPredictedView = (eyeViewAdjust * predictedViewFromWorld).InvertedHomogeneousTransform();
- Matrix4f matRenderFromNowStart = (eyeViewAdjust * renderedViewFromWorld) * worldFromPredictedView;
+ Matrix4f worldFromPredictedView = (hmdToEyeViewOffset * predictedViewFromWorld).InvertedHomogeneousTransform();
+ Matrix4f matRenderFromNowStart = (hmdToEyeViewOffset * renderedViewFromWorld) * worldFromPredictedView;
// The sensor-predicted orientations have: X=right, Y=up, Z=backwards.
// The vectors inside the mesh are in NDC to keep the shader simple: X=right, Y=down, Z=forwards.
@@ -1311,22 +1326,35 @@ Matrix4f TimewarpComputePoseDelta ( Matrix4f const &renderedViewFromWorld, Matri
return matRenderFromNowStart;
}
-Matrix4f TimewarpComputePoseDeltaPosition ( Matrix4f const &renderedViewFromWorld, Matrix4f const &predictedViewFromWorld, Matrix4f const&eyeViewAdjust )
+Matrix4f TimewarpComputePoseDeltaPosition ( Matrix4f const &renderedViewFromWorld, Matrix4f const &predictedViewFromWorld, Matrix4f const&hmdToEyeViewOffset )
{
- Matrix4f worldFromPredictedView = (eyeViewAdjust * predictedViewFromWorld).InvertedHomogeneousTransform();
- Matrix4f matRenderXform = (eyeViewAdjust * renderedViewFromWorld) * worldFromPredictedView;
+ Matrix4f worldFromPredictedView = (hmdToEyeViewOffset * predictedViewFromWorld).InvertedHomogeneousTransform();
+ Matrix4f matRenderXform = (hmdToEyeViewOffset * renderedViewFromWorld) * worldFromPredictedView;
return matRenderXform.Inverted();
}
TimewarpMachine::TimewarpMachine()
-{
+ : VsyncEnabled(false),
+ RenderInfo(),
+ CurrentPredictionValues(),
+ DistortionTimeCount(0),
+ DistortionTimeCurrentStart(0.0),
+ //DistortionTimes[],
+ DistortionTimeAverage(0.f),
+ //EyeRenderPoses[],
+ LastFramePresentFlushTime(0.0),
+ PresentFlushToPresentFlushSeconds(0.f),
+ NextFramePresentFlushTime(0.0)
+{
+ #if defined(OVR_BUILD_DEBUG)
+ memset(DistortionTimes, 0, sizeof(DistortionTimes));
+ #endif
+
for ( int i = 0; i < 2; i++ )
{
EyeRenderPoses[i] = Posef();
}
- DistortionTimeCount = 0;
- VsyncEnabled = false;
}
void TimewarpMachine::Reset(HmdRenderInfo& renderInfo, bool vsyncEnabled, double timeNow)
@@ -1431,6 +1459,14 @@ double TimewarpMachine::JustInTime_GetDistortionWaitUntilTime()
return LastFramePresentFlushTime + (float)( CurrentPredictionValues.PresentFlushToPresentFlush - howLongBeforePresent );
}
+double TimewarpMachine::JustInTime_AverageDistortionTime()
+{
+ if ( JustInTime_NeedDistortionTimeMeasurement() )
+ {
+ return 0.0;
+ }
+ return DistortionTimeAverage;
+}
bool TimewarpMachine::JustInTime_NeedDistortionTimeMeasurement() const
{
diff --git a/LibOVR/Src/Util/Util_Render_Stereo.h b/LibOVR/Src/Util/Util_Render_Stereo.h
index 2517c37..7770404 100644
--- a/LibOVR/Src/Util/Util_Render_Stereo.h
+++ b/LibOVR/Src/Util/Util_Render_Stereo.h
@@ -5,16 +5,16 @@ Content : Sample stereo rendering configuration classes.
Created : October 22, 2012
Authors : Michael Antonov, Tom Forsyth
-Copyright : Copyright 2014 Oculus VR, Inc. All Rights reserved.
+Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved.
-Licensed under the Oculus VR Rift SDK License Version 3.1 (the "License");
+Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License");
you may not use the Oculus VR Rift SDK except in compliance with the License,
which is provided at the time of installation or download, or which
otherwise accompanies this software in either electronic or hard copy form.
You may obtain a copy of the License at
-http://www.oculusvr.com/licenses/LICENSE-3.1
+http://www.oculusvr.com/licenses/LICENSE-3.2
Unless required by applicable law or agreed to in writing, the Oculus VR SDK
distributed under the License is distributed on an "AS IS" BASIS,
@@ -328,13 +328,18 @@ struct DistortionMeshVertexData
Vector2f TanEyeAnglesB;
};
+// If you just want a single point on the screen transformed.
+DistortionMeshVertexData DistortionMeshMakeVertex ( Vector2f screenNDC,
+ bool rightEye,
+ const HmdRenderInfo &hmdRenderInfo,
+ const DistortionRenderDesc &distortion, const ScaleAndOffset2D &eyeToSourceNDC );
void DistortionMeshCreate ( DistortionMeshVertexData **ppVertices, uint16_t **ppTriangleListIndices,
int *pNumVertices, int *pNumTriangles,
const StereoEyeParams &stereoParams, const HmdRenderInfo &hmdRenderInfo );
-// Generate distortion mesh for a eye. This version requires less data then stereoParms, supporting
-// dynamic change in render target viewport.
+// Generate distortion mesh for a eye.
+// This version requires less data then stereoParms, supporting dynamic change in render target viewport.
void DistortionMeshCreate( DistortionMeshVertexData **ppVertices, uint16_t **ppTriangleListIndices,
int *pNumVertices, int *pNumTriangles,
bool rightEye,
@@ -406,8 +411,8 @@ PredictionValues PredictionGetDeviceValues ( const HmdRenderInfo &hmdRenderInfo,
// (which may have been computed later on, and thus is more accurate), and this
// will return the matrix to pass to the timewarp distortion shader.
// TODO: deal with different handedness?
-Matrix4f TimewarpComputePoseDelta ( Matrix4f const &renderedViewFromWorld, Matrix4f const &predictedViewFromWorld, Matrix4f const&eyeViewAdjust );
-Matrix4f TimewarpComputePoseDeltaPosition ( Matrix4f const &renderedViewFromWorld, Matrix4f const &predictedViewFromWorld, Matrix4f const&eyeViewAdjust );
+Matrix4f TimewarpComputePoseDelta ( Matrix4f const &renderedViewFromWorld, Matrix4f const &predictedViewFromWorld, Matrix4f const&hmdToEyeViewOffset );
+Matrix4f TimewarpComputePoseDeltaPosition ( Matrix4f const &renderedViewFromWorld, Matrix4f const &predictedViewFromWorld, Matrix4f const&hmdToEyeViewOffset );
@@ -459,13 +464,14 @@ public:
bool JustInTime_NeedDistortionTimeMeasurement() const;
void JustInTime_BeforeDistortionTimeMeasurement(double timeNow);
void JustInTime_AfterDistortionTimeMeasurement(double timeNow);
+ double JustInTime_AverageDistortionTime(); // Just for profiling - use JustInTime_GetDistortionWaitUntilTime() for functionality.
private:
bool VsyncEnabled;
HmdRenderInfo RenderInfo;
PredictionValues CurrentPredictionValues;
- enum { NumDistortionTimes = 10 };
+ enum { NumDistortionTimes = 100 };
int DistortionTimeCount;
double DistortionTimeCurrentStart;
float DistortionTimes[NumDistortionTimes];
diff --git a/LibOVR/Src/Util/Util_SystemInfo.cpp b/LibOVR/Src/Util/Util_SystemInfo.cpp
new file mode 100644
index 0000000..0fca243
--- /dev/null
+++ b/LibOVR/Src/Util/Util_SystemInfo.cpp
@@ -0,0 +1,289 @@
+/************************************************************************************
+
+Filename : Util_SystemInfo.cpp
+Content : Various operations to get information about the system
+Created : September 26, 2014
+Author : Kevin Jenkins
+
+Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved.
+
+Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License");
+you may not use the Oculus VR Rift SDK except in compliance with the License,
+which is provided at the time of installation or download, or which
+otherwise accompanies this software in either electronic or hard copy form.
+
+You may obtain a copy of the License at
+
+http://www.oculusvr.com/licenses/LICENSE-3.2
+
+Unless required by applicable law or agreed to in writing, the Oculus VR SDK
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+************************************************************************************/
+
+#include "Util_SystemInfo.h"
+#include "../Kernel/OVR_Timer.h"
+#include "../Kernel/OVR_Threads.h"
+#include "../Kernel/OVR_Log.h"
+#include "../Kernel/OVR_Array.h"
+
+/*
+// Disabled, can't link RiftConfigUtil
+#ifdef OVR_OS_WIN32
+#define _WIN32_DCOM
+#include <comdef.h>
+#include <Wbemidl.h>
+
+# pragma comment(lib, "wbemuuid.lib")
+#endif
+*/
+
+
+namespace OVR { namespace Util {
+
+// From http://blogs.msdn.com/b/oldnewthing/archive/2005/02/01/364563.aspx
+#if defined (OVR_OS_WIN64) || defined (OVR_OS_WIN32)
+
+#pragma comment(lib, "version.lib")
+
+typedef BOOL(WINAPI *LPFN_ISWOW64PROCESS) (HANDLE, PBOOL);
+BOOL Is64BitWindows()
+{
+#if defined(_WIN64)
+ return TRUE; // 64-bit programs run only on Win64
+#elif defined(_WIN32)
+ // 32-bit programs run on both 32-bit and 64-bit Windows
+ // so must sniff
+ BOOL f64 = FALSE;
+ LPFN_ISWOW64PROCESS fnIsWow64Process;
+
+ fnIsWow64Process = (LPFN_ISWOW64PROCESS)GetProcAddress(GetModuleHandle(L"kernel32"), "IsWow64Process");
+ if (NULL != fnIsWow64Process)
+ {
+ return fnIsWow64Process(GetCurrentProcess(), &f64) && f64;
+ }
+ return FALSE;
+#else
+ return FALSE; // Win64 does not support Win16
+#endif
+}
+#endif
+
+const char * OSAsString()
+{
+#if defined (OVR_OS_IPHONE)
+ return "IPhone";
+#elif defined (OVR_OS_DARWIN)
+ return "Darwin";
+#elif defined (OVR_OS_MAC)
+ return "Mac";
+#elif defined (OVR_OS_BSD)
+ return "BSD";
+#elif defined (OVR_OS_WIN64) || defined (OVR_OS_WIN32)
+ if (Is64BitWindows())
+ return "Win64";
+ else
+ return "Win32";
+#elif defined (OVR_OS_ANDROID)
+ return "Android";
+#elif defined (OVR_OS_LINUX)
+ return "Linux";
+#elif defined (OVR_OS_BSD)
+ return "BSD";
+#else
+ return "Other";
+#endif
+}
+
+uint64_t GetGuidInt()
+{
+ uint64_t g = Timer::GetTicksNanos();
+
+ uint64_t lastTime, thisTime;
+ int j;
+ // Sleep a small random time, then use the last 4 bits as a source of randomness
+ for (j = 0; j < 8; j++)
+ {
+ lastTime = Timer::GetTicksNanos();
+ Thread::MSleep(1);
+ Thread::MSleep(0);
+ thisTime = Timer::GetTicksNanos();
+ uint64_t diff = thisTime - lastTime;
+ unsigned int diff4Bits = (unsigned int)(diff & 15);
+ diff4Bits <<= 32 - 4;
+ diff4Bits >>= j * 4;
+ ((char*)&g)[j] ^= diff4Bits;
+ }
+
+ return g;
+}
+String GetGuidString()
+{
+ uint64_t guid = GetGuidInt();
+
+ char buff[64];
+#if defined(OVR_CC_MSVC)
+ OVR_sprintf(buff, sizeof(buff), "%I64u", guid);
+#else
+ OVR_sprintf(buff, sizeof(buff), "%llu", (unsigned long long) guid);
+#endif
+ return String(buff);
+}
+
+const char * GetProcessInfo()
+{
+ #if defined (OVR_CPU_X86_64 )
+ return "64 bit";
+#elif defined (OVR_CPU_X86)
+ return "32 bit";
+#else
+ return "TODO";
+#endif
+}
+#ifdef OVR_OS_WIN32
+
+
+String OSVersionAsString()
+{
+ return GetSystemFileVersionString("\\kernel32.dll");
+}
+String GetSystemFileVersionString(String filePath)
+{
+ char strFilePath[MAX_PATH]; // Local variable
+ UINT sysDirLen = GetSystemDirectoryA(strFilePath, ARRAYSIZE(strFilePath));
+ if (sysDirLen != 0)
+ {
+ OVR_strcat(strFilePath, MAX_PATH, filePath.ToCStr());
+ return GetFileVersionString(strFilePath);
+ }
+ else
+ {
+ return "GetSystemDirectoryA failed";
+ }
+}
+// See http://stackoverflow.com/questions/940707/how-do-i-programatically-get-the-version-of-a-dll-or-exe-file
+String GetFileVersionString(String filePath)
+{
+ String result;
+
+ DWORD dwSize = GetFileVersionInfoSizeA(filePath.ToCStr(), NULL);
+ if (dwSize == 0)
+ {
+ OVR_DEBUG_LOG(("Error in GetFileVersionInfoSizeA: %d (for %s)", GetLastError(), filePath.ToCStr()));
+ result = filePath + " not found";
+ }
+ else
+ {
+ BYTE* pVersionInfo = new BYTE[dwSize];
+ if (!pVersionInfo)
+ {
+ OVR_DEBUG_LOG(("Out of memory allocating %d bytes (for %s)", dwSize, filePath.ToCStr()));
+ result = "Out of memory";
+ }
+ else
+ {
+ if (!GetFileVersionInfoA(filePath.ToCStr(), 0, dwSize, pVersionInfo))
+ {
+ OVR_DEBUG_LOG(("Error in GetFileVersionInfo: %d (for %s)", GetLastError(), filePath.ToCStr()));
+ result = "Cannot get version info";
+ }
+ else
+ {
+ VS_FIXEDFILEINFO* pFileInfo = NULL;
+ UINT pLenFileInfo = 0;
+ if (!VerQueryValue(pVersionInfo, TEXT("\\"), (LPVOID*)&pFileInfo, &pLenFileInfo))
+ {
+ OVR_DEBUG_LOG(("Error in VerQueryValue: %d (for %s)", GetLastError(), filePath.ToCStr()));
+ result = "File has no version info";
+ }
+ else
+ {
+ int major = (pFileInfo->dwFileVersionMS >> 16) & 0xffff;
+ int minor = (pFileInfo->dwFileVersionMS) & 0xffff;
+ int hotfix = (pFileInfo->dwFileVersionLS >> 16) & 0xffff;
+ int other = (pFileInfo->dwFileVersionLS) & 0xffff;
+
+ char str[128];
+ OVR::OVR_sprintf(str, 128, "%d.%d.%d.%d", major, minor, hotfix, other);
+
+ result = str;
+ }
+ }
+
+ delete[] pVersionInfo;
+ }
+ }
+
+ return result;
+}
+
+
+String GetDisplayDriverVersion()
+{
+ return GetSystemFileVersionString("\\OVRDisplay32.dll");
+}
+String GetCameraDriverVersion()
+{
+ return GetSystemFileVersionString("\\drivers\\OCUSBVID.sys");
+}
+
+// From http://stackoverflow.com/questions/9524309/enumdisplaydevices-function-not-working-for-me
+void GetGraphicsCardList( Array< String > &gpus)
+{
+ gpus.Clear();
+
+ DISPLAY_DEVICEA dd;
+
+ dd.cb = sizeof(dd);
+
+ DWORD deviceNum = 0;
+ while( EnumDisplayDevicesA(NULL, deviceNum, &dd, 0) ){
+ if (dd.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE)
+ gpus.PushBack(dd.DeviceString);
+ deviceNum++;
+ }
+}
+#else
+
+// used for driver files
+
+String GetFileVersionString(String /*filePath*/)
+{
+ return String();
+}
+
+String GetSystemFileVersionString(String /*filePath*/)
+{
+ return String();
+}
+
+String GetDisplayDriverVersion()
+{
+ return String();
+}
+
+String GetCameraDriverVersion()
+{
+ return String();
+}
+
+#ifdef OVR_OS_MAC
+ //use objective c source
+#else
+
+//todo linux, this requires searching /var/ files
+void GetGraphicsCardList(OVR::Array< OVR::String > &gpus)
+{
+ gpus.Clear();
+}
+String OSVersionAsString()
+{
+ return String();
+}
+#endif //OVR_OS_MAC
+#endif // WIN32
+
+} } // namespace OVR { namespace Util {
diff --git a/LibOVR/Src/Util/Util_SystemInfo.h b/LibOVR/Src/Util/Util_SystemInfo.h
new file mode 100644
index 0000000..14f07c0
--- /dev/null
+++ b/LibOVR/Src/Util/Util_SystemInfo.h
@@ -0,0 +1,44 @@
+/************************************************************************************
+
+Filename : Util_SystemInfo.h
+Content : Various operations to get information about the system
+Created : September 26, 2014
+Author : Kevin Jenkins
+
+Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved.
+
+Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License");
+you may not use the Oculus VR Rift SDK except in compliance with the License,
+which is provided at the time of installation or download, or which
+otherwise accompanies this software in either electronic or hard copy form.
+
+You may obtain a copy of the License at
+
+http://www.oculusvr.com/licenses/LICENSE-3.2
+
+Unless required by applicable law or agreed to in writing, the Oculus VR SDK
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+************************************************************************************/
+
+#include "../Kernel/OVR_String.h"
+#include "../Kernel/OVR_Types.h"
+#include "../Kernel/OVR_Array.h"
+
+namespace OVR { namespace Util {
+
+const char * OSAsString();
+String OSVersionAsString();
+uint64_t GetGuidInt();
+String GetGuidString();
+const char * GetProcessInfo();
+String GetFileVersionString(String filePath);
+String GetSystemFileVersionString(String filePath);
+String GetDisplayDriverVersion();
+String GetCameraDriverVersion();
+void GetGraphicsCardList(OVR::Array< OVR::String > &gpus);
+
+} } // namespace OVR { namespace Util { \ No newline at end of file
diff --git a/LibOVR/Src/Util/Util_SystemInfo_OSX.mm b/LibOVR/Src/Util/Util_SystemInfo_OSX.mm
new file mode 100644
index 0000000..8bc735b
--- /dev/null
+++ b/LibOVR/Src/Util/Util_SystemInfo_OSX.mm
@@ -0,0 +1,212 @@
+ /************************************************************************************
+
+
+
+ Filename : Util_SystemInfo_OSX.mm
+
+ Content : Various operations to get information about the mac system
+
+ Created : October 2, 2014
+
+
+
+ Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved.
+
+
+
+ Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License");
+
+ you may not use the Oculus VR Rift SDK except in compliance with the License,
+
+ which is provided at the time of installation or download, or which
+
+ otherwise accompanies this software in either electronic or hard copy form.
+
+
+
+ You may obtain a copy of the License at
+
+
+
+ http://www.oculusvr.com/licenses/LICENSE-3.2
+
+
+
+ Unless required by applicable law or agreed to in writing, the Oculus VR SDK
+
+ distributed under the License is distributed on an "AS IS" BASIS,
+
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+
+ See the License for the specific language governing permissions and
+
+ limitations under the License.
+
+
+
+ ************************************************************************************/
+
+
+
+#include "Util_SystemInfo.h"
+
+
+
+#include <Cocoa/Cocoa.h>
+
+
+
+#include <sys/sysctl.h>
+
+#include <sys/types.h>
+
+
+
+#include "../Kernel/OVR_String.h"
+
+#include "../Kernel/OVR_System.h"
+
+
+
+using namespace OVR;
+
+namespace OVR { namespace Util {
+
+
+
+//from http://opensource.apple.com/source/CF/CF-744/CFUtilities.c
+
+OVR::String OSVersionAsString(){
+
+
+
+ NSDictionary *systemVersionDictionary =
+
+ [NSDictionary dictionaryWithContentsOfFile:
+
+ @"/System/Library/CoreServices/SystemVersion.plist"];
+
+
+
+ NSString *systemVersion =
+
+ [systemVersionDictionary objectForKey:@"ProductVersion"];
+
+ return OVR::String([systemVersion UTF8String]);
+
+}
+
+
+
+
+
+//from http://www.starcoder.com/wordpress/2011/10/using-iokit-to-detect-graphics-hardware/
+
+void GetGraphicsCardList(Array< String > &gpus)
+
+{
+
+ // Check the PCI devices for video cards.
+
+ CFMutableDictionaryRef match_dictionary = IOServiceMatching("IOPCIDevice");
+
+
+
+ // Create a iterator to go through the found devices.
+
+ io_iterator_t entry_iterator;
+
+
+
+ if (IOServiceGetMatchingServices(kIOMasterPortDefault,
+
+ match_dictionary,
+
+ &entry_iterator) == kIOReturnSuccess)
+
+ {
+
+ // Actually iterate through the found devices.
+
+ io_registry_entry_t serviceObject;
+
+ while ((serviceObject = IOIteratorNext(entry_iterator)))
+
+ {
+
+ // Put this services object into a dictionary object.
+
+ CFMutableDictionaryRef serviceDictionary;
+
+ if (IORegistryEntryCreateCFProperties(serviceObject,
+
+ &serviceDictionary,
+
+ kCFAllocatorDefault,
+
+ kNilOptions) != kIOReturnSuccess)
+
+ {
+
+ // Failed to create a service dictionary, release and go on.
+
+ IOObjectRelease(serviceObject);
+
+ continue;
+
+ }
+
+
+
+ //
+
+ // that points to a CFDataRef.
+
+ const void *modelarr = CFDictionaryGetValue(serviceDictionary, CFSTR("model"));
+
+ if (modelarr != nil) {
+
+ if(CFGetTypeID(modelarr) == CFDataGetTypeID())
+
+ {
+
+ NSData *data = (__bridge NSData*)(CFDataRef)modelarr;
+
+ NSString *s = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
+
+ gpus.PushBack([s UTF8String]);
+
+ }
+
+ }
+
+
+
+ // Release the dictionary created by IORegistryEntryCreateCFProperties.
+
+ CFRelease(serviceDictionary);
+
+
+
+ // Release the serviceObject returned by IOIteratorNext.
+
+ IOObjectRelease(serviceObject);
+
+ }
+
+
+
+ // Release the entry_iterator created by IOServiceGetMatchingServices.
+
+ IOObjectRelease(entry_iterator);
+
+ }
+
+}
+
+
+
+} } // namespace OVR { namespace Util {
+
+
+