aboutsummaryrefslogtreecommitdiffstats
path: root/LibOVR/Src
diff options
context:
space:
mode:
Diffstat (limited to 'LibOVR/Src')
-rw-r--r--LibOVR/Src/CAPI/CAPI_DistortionRenderer.cpp6
-rwxr-xr-xLibOVR/Src/CAPI/CAPI_HMDState.cpp16
-rwxr-xr-xLibOVR/Src/CAPI/CAPI_HMDState.h4
-rw-r--r--LibOVR/Src/Displays/OVR_Win32_Dxgi_Display.h22
-rw-r--r--LibOVR/Src/Kernel/OVR_System.cpp155
-rwxr-xr-xLibOVR/Src/OVR_CAPI.cpp22
-rwxr-xr-xLibOVR/Src/OVR_Profile.cpp2
7 files changed, 225 insertions, 2 deletions
diff --git a/LibOVR/Src/CAPI/CAPI_DistortionRenderer.cpp b/LibOVR/Src/CAPI/CAPI_DistortionRenderer.cpp
index 4b61ba5..a4e9e0d 100644
--- a/LibOVR/Src/CAPI/CAPI_DistortionRenderer.cpp
+++ b/LibOVR/Src/CAPI/CAPI_DistortionRenderer.cpp
@@ -26,6 +26,7 @@ limitations under the License.
#include "CAPI_DistortionRenderer.h"
+#if !defined(HEADLESS_APP)
#if defined (OVR_OS_WIN32)
// TBD: Move to separate config file that handles back-ends.
@@ -35,6 +36,7 @@ limitations under the License.
#endif
#include "GL/CAPI_GL_DistortionRenderer.h"
+#endif /* !defined(HEADLESS_APP) */
namespace OVR { namespace CAPI {
@@ -46,6 +48,7 @@ namespace OVR { namespace CAPI {
DistortionRenderer::CreateFunc DistortionRenderer::APICreateRegistry[ovrRenderAPI_Count] =
{
+#if !defined(HEADLESS_APP)
0, // None
&GL::DistortionRenderer::Create,
0, // Android_GLES
@@ -58,6 +61,9 @@ DistortionRenderer::CreateFunc DistortionRenderer::APICreateRegistry[ovrRenderAP
0,
0
#endif
+#else /* !defined(HEADLESS_APP) */
+ 0 // None
+#endif /* !defined(HEADLESS_APP) */
};
DistortionRenderer::DistortionRenderer() :
diff --git a/LibOVR/Src/CAPI/CAPI_HMDState.cpp b/LibOVR/Src/CAPI/CAPI_HMDState.cpp
index 4aae646..7a00bf8 100755
--- a/LibOVR/Src/CAPI/CAPI_HMDState.cpp
+++ b/LibOVR/Src/CAPI/CAPI_HMDState.cpp
@@ -28,6 +28,7 @@ limitations under the License.
#include "../OVR_Profile.h"
#include "../Service/Service_NetClient.h"
+#if !defined(HEADLESS_APP)
#ifdef OVR_OS_WIN32
#include "../Displays/OVR_Win32_ShimFunctions.h"
@@ -41,6 +42,7 @@ limitations under the License.
#include "../Displays/OVR_Linux_SDKWindow.h" // For screen rotation
#endif
+#endif /* !defined(HEADLESS_APP) */
#include "Tracing/Tracing.h"
@@ -83,7 +85,9 @@ HMDState::HMDState(HMDInfo const & hmdInfo,
ScreenLatencyTracker(),
RenderState(),
pRenderer(),
+#if !defined(HEADLESS_APP)
pHSWDisplay(),
+#endif /* !defined(HEADLESS_APP) */
//LastGetStringValue(),
RenderingConfigured(false),
BeginFrameCalled(false),
@@ -136,6 +140,7 @@ HMDState::HMDState(HMDInfo const & hmdInfo,
BeginFrameThreadId = 0;
BeginFrameTimingCalled = false;
+#if !defined(HEADLESS_APP)
// Construct the HSWDisplay. We will later reconstruct it with a specific ovrRenderAPI type if the application starts using SDK-based rendering.
if(!pHSWDisplay)
{
@@ -168,6 +173,7 @@ HMDState::~HMDState()
OVR_FREE(pHmdDesc);
pHmdDesc = nullptr;
}
+#endif /* !defined(HEADLESS_APP) */
}
bool HMDState::InitializeSharedState()
@@ -279,6 +285,7 @@ HMDState* HMDState::CreateHMDState(NetClient* client, const HMDNetworkInfo& netI
return nullptr;
}
+#if !defined(HEADLESS_APP)
#ifdef OVR_OS_WIN32
OVR_DEBUG_LOG(("[HMDState] Setting up display shim"));
@@ -286,6 +293,7 @@ HMDState* HMDState::CreateHMDState(NetClient* client, const HMDNetworkInfo& netI
// so that this will happen before the D3D display object is created.
Win32::DisplayShim::GetInstance().Update(&hinfo.ShimInfo);
#endif
+#endif /* !defined(HEADLESS_APP) */
Ptr<Profile> pDefaultProfile = *ProfileManager::GetInstance()->GetDefaultUserProfile(&hinfo);
OVR_DEBUG_LOG(("[HMDState] Using profile %s", pDefaultProfile->GetValue(OVR_KEY_USER)));
@@ -385,6 +393,7 @@ void HMDState::SetEnabledHmdCaps(unsigned hmdCaps)
if ((EnabledHmdCaps ^ hmdCaps) & ovrHmdCap_NoMirrorToWindow)
{
+#if !defined(HEADLESS_APP)
#ifdef OVR_OS_WIN32
Win32::DisplayShim::GetInstance().UseMirroring = (hmdCaps & ovrHmdCap_NoMirrorToWindow) ?
false : true;
@@ -393,6 +402,7 @@ void HMDState::SetEnabledHmdCaps(unsigned hmdCaps)
::InvalidateRect((HWND)pWindow, 0, true);
}
#endif
+#endif /* !defined(HEADLESS_APP) */
}
// TBD: Should this include be only the rendering flags? Otherwise, bits that failed
@@ -895,11 +905,13 @@ bool HMDState::ConfigureRendering(ovrEyeRenderDesc eyeRenderDescOut[2],
// null -> shut down.
if (!apiConfig)
{
+#if !defined(HEADLESS_APP)
if (pHSWDisplay)
{
pHSWDisplay->Shutdown();
pHSWDisplay.Clear();
}
+#endif /* !defined(HEADLESS_APP) */
if (pRenderer)
pRenderer.Clear();
@@ -911,11 +923,13 @@ bool HMDState::ConfigureRendering(ovrEyeRenderDesc eyeRenderDescOut[2],
(apiConfig->Header.API != pRenderer->GetRenderAPI()))
{
// Shutdown old renderer.
+#if !defined(HEADLESS_APP)
if (pHSWDisplay)
{
pHSWDisplay->Shutdown();
pHSWDisplay.Clear();
}
+#endif /* !defined(HEADLESS_APP) */
if (pRenderer)
pRenderer.Clear();
@@ -948,6 +962,7 @@ bool HMDState::ConfigureRendering(ovrEyeRenderDesc eyeRenderDescOut[2],
return false;
}
+#if !defined(HEADLESS_APP)
// Setup the Health and Safety Warning display system.
if(pHSWDisplay && (pHSWDisplay->GetRenderAPIType() != apiConfig->Header.API)) // If we need to reconstruct the HSWDisplay for a different graphics API type, delete the existing display.
{
@@ -1024,6 +1039,7 @@ OVR_RESTORE_MSVC_WARNING()
}
}
#endif
+#endif /* !defined(HEADLESS_APP) */
return true;
}
diff --git a/LibOVR/Src/CAPI/CAPI_HMDState.h b/LibOVR/Src/CAPI/CAPI_HMDState.h
index 18342bb..c8b521e 100755
--- a/LibOVR/Src/CAPI/CAPI_HMDState.h
+++ b/LibOVR/Src/CAPI/CAPI_HMDState.h
@@ -37,7 +37,9 @@ limitations under the License.
#include "CAPI_HMDRenderState.h"
#include "CAPI_DistortionRenderer.h"
+#if !defined(HEADLESS_APP)
#include "CAPI_HSWDisplay.h"
+#endif /* !defined(HEADLESS_APP) */
#include "Service/Service_NetClient.h"
#include "Net/OVR_NetworkTypes.h"
@@ -294,8 +296,10 @@ public:
HMDRenderState RenderState;
Ptr<DistortionRenderer> pRenderer;
+#if !defined(HEADLESS_APP)
// Health and Safety Warning display.
Ptr<HSWDisplay> pHSWDisplay;
+#endif /* !defined(HEADLESS_APP) */
// Last cached value returned by ovrHmd_GetString/ovrHmd_GetStringArray.
char LastGetStringValue[256];
diff --git a/LibOVR/Src/Displays/OVR_Win32_Dxgi_Display.h b/LibOVR/Src/Displays/OVR_Win32_Dxgi_Display.h
index 4ae110b..fbabc6a 100644
--- a/LibOVR/Src/Displays/OVR_Win32_Dxgi_Display.h
+++ b/LibOVR/Src/Displays/OVR_Win32_Dxgi_Display.h
@@ -81,6 +81,8 @@ typedef BOOL (WINAPI *WinGetModuleHandleExW)( DWORD, LPCWSTR, HMODULE* );
typedef void* (WINAPI *WinDirect3DCreate9)(UINT SDKVersion);
typedef HRESULT (WINAPI *WinDirect3DCreate9Ex)(UINT SDKVersion, void** aDevice);
+#if !defined(HEADLESS_APP)
+
// Overridden DXGI entry points
typedef HRESULT (WINAPI *WinCreateDXGIFactory)(
__in REFIID riid,
@@ -98,6 +100,26 @@ typedef HRESULT (WINAPI *WinCreateDXGIFactory2)(
__out void **ppFactory
);
+#else /* !defined(HEADLESS_APP) */
+
+typedef HRESULT (WINAPI *WinCreateDXGIFactory)(
+ void ** riid,
+ void **ppFactory
+ );
+
+typedef HRESULT (WINAPI *WinCreateDXGIFactory1)(
+ void ** riid,
+ void **ppFactory
+ );
+
+typedef HRESULT (WINAPI *WinCreateDXGIFactory2)(
+ UINT flags,
+ const IID &riid,
+ void **ppFactory
+ );
+
+#endif /* !defined(HEADLESS_APP) */
+
// Application usermode callbacks from usermode driver. These
// functions are all provided by the calling application that uses
// the filter mode driver
diff --git a/LibOVR/Src/Kernel/OVR_System.cpp b/LibOVR/Src/Kernel/OVR_System.cpp
new file mode 100644
index 0000000..c8c7b87
--- /dev/null
+++ b/LibOVR/Src/Kernel/OVR_System.cpp
@@ -0,0 +1,155 @@
+/************************************************************************************
+
+Filename : OVR_System.cpp
+Content : General kernel initialization/cleanup, including that
+ of the memory allocator.
+Created : September 19, 2012
+Notes :
+
+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 "OVR_System.h"
+#include "OVR_Threads.h"
+#include "OVR_Timer.h"
+#include "../Displays/OVR_Display.h"
+#if !defined(HEADLESS_APP)
+#ifdef OVR_OS_WIN32
+#include "../Displays/OVR_Win32_ShimFunctions.h"
+#endif
+#endif /* !defined(HEADLESS_APP) */
+
+namespace OVR {
+
+#ifdef OVR_OS_WIN32
+extern bool anyRiftsInExtendedMode();
+#endif
+
+// Stack of destroy listeners (push/pop semantics)
+static SystemSingletonInternal *SystemShutdownListenerStack = 0;
+static Lock stackLock;
+static bool DisplayShimInitialized = false;
+
+void SystemSingletonInternal::PushDestroyCallbacks()
+{
+ Lock::Locker locker(&stackLock);
+
+ // Push listener onto the stack
+ NextSingleton = SystemShutdownListenerStack;
+ SystemShutdownListenerStack = this;
+}
+
+void System::DirectDisplayInitialize()
+{
+#if !defined(HEADLESS_APP)
+#ifdef OVR_OS_WIN32
+ // Set up display code for Windows
+ Win32::DisplayShim::GetInstance();
+
+ // This code will look for the first display. If it's a display
+ // that's extending the destkop, the code will assume we're in
+ // compatibility mode. Compatibility mode prevents shim loading
+ // and renders only to extended Rifts.
+ // If we find a display and it's application exclusive,
+ // we load the shim so we can render to it.
+ // If no display is available, we revert to whatever the
+ // driver tells us we're in
+
+ bool anyExtendedRifts = anyRiftsInExtendedMode() || Display::InCompatibilityMode( false );
+
+ DisplayShimInitialized = Win32::DisplayShim::GetInstance().Initialize(anyExtendedRifts);
+#endif
+#endif /* !defined(HEADLESS_APP) */
+}
+
+bool System::DirectDisplayEnabled()
+{
+ return DisplayShimInitialized;
+}
+
+// Initializes System core, installing allocator.
+void System::Init(Log* log, Allocator *palloc)
+{
+ if (!Allocator::GetInstance())
+ {
+ Log::SetGlobalLog(log);
+ Timer::initializeTimerSystem();
+ Allocator::setInstance(palloc);
+ Display::Initialize();
+ DirectDisplayInitialize();
+ }
+ else
+ {
+ OVR_DEBUG_LOG(("System::Init failed - duplicate call."));
+ }
+}
+
+void System::Destroy()
+{
+ if (Allocator::GetInstance())
+ {
+#if !defined(HEADLESS_APP)
+#ifdef OVR_OS_WIN32
+ Win32::DisplayShim::GetInstance().Shutdown();
+#endif
+#endif /* !defined(HEADLESS_APP) */
+
+ // Invoke all of the post-finish callbacks (normal case)
+ for (SystemSingletonInternal *listener = SystemShutdownListenerStack; listener; listener = listener->NextSingleton)
+ {
+ listener->OnThreadDestroy();
+ }
+
+#ifdef OVR_ENABLE_THREADS
+ // Wait for all threads to finish; this must be done so that memory
+ // allocator and all destructors finalize correctly.
+ Thread::FinishAllThreads();
+#endif
+
+ // Invoke all of the post-finish callbacks (normal case)
+ for (SystemSingletonInternal *next, *listener = SystemShutdownListenerStack; listener; listener = next)
+ {
+ next = listener->NextSingleton;
+
+ listener->OnSystemDestroy();
+ }
+
+ SystemShutdownListenerStack = 0;
+
+ // Shutdown heap and destroy SysAlloc singleton, if any.
+ Allocator::GetInstance()->onSystemShutdown();
+ Allocator::setInstance(0);
+
+ Timer::shutdownTimerSystem();
+ Log::SetGlobalLog(Log::GetDefaultLog());
+ }
+ else
+ {
+ OVR_DEBUG_LOG(("System::Destroy failed - System not initialized."));
+ }
+}
+
+// Returns 'true' if system was properly initialized.
+bool System::IsInitialized()
+{
+ return Allocator::GetInstance() != 0;
+}
+
+
+} // namespace OVR
diff --git a/LibOVR/Src/OVR_CAPI.cpp b/LibOVR/Src/OVR_CAPI.cpp
index d451ad8..c530f82 100755
--- a/LibOVR/Src/OVR_CAPI.cpp
+++ b/LibOVR/Src/OVR_CAPI.cpp
@@ -45,10 +45,12 @@ limitations under the License.
#include "Displays/OVR_Display.h"
+#if !defined(HEADLESS_APP)
#if defined(OVR_OS_WIN32)
#include "Displays/OVR_Win32_ShimFunctions.h"
#include <VersionHelpers.h>
#endif
+#endif /* !defined(HEADLESS_APP) */
// Forward decl to keep the callback static
@@ -174,6 +176,7 @@ static ovrBool CAPI_ovrInitializeCalled = ovrFalse;
static OVR::Service::NetClient* CAPI_pNetClient = nullptr;
+#if !defined(HEADLESS_APP)
ovrBool ovr_InitializeRenderingShim()
{
OVR::Display::Initialize();
@@ -191,6 +194,7 @@ OVR_PUBLIC_FUNCTION(ovrBool) ovr_InitializeRenderingShimVersion(int requestedMin
return ovr_InitializeRenderingShim();
}
+#endif /* !defined(HEADLESS_APP) */
// Write out to the log where the current running module is located on disk.
static void LogLocationOfThisModule()
@@ -443,6 +447,7 @@ OVR_PUBLIC_FUNCTION(ovrHmd) ovrHmd_Create(int index)
return hmds->pHmdDesc;
}
+#if !defined(HEADLESS_APP)
OVR_PUBLIC_FUNCTION(ovrBool) ovrHmd_AttachToWindow(ovrHmd hmddesc, void* window,
const ovrRecti* destMirrorRect,
@@ -471,6 +476,8 @@ OVR_PUBLIC_FUNCTION(ovrBool) ovrHmd_AttachToWindow(ovrHmd hmddesc, void* window,
return ovrTrue;
}
+#endif /* !defined(HEADLESS_APP) */
+
OVR_PUBLIC_FUNCTION(ovrHmd) ovrHmd_CreateDebug(ovrHmdType type)
{
if (!CAPI_ovrInitializeCalled)
@@ -494,6 +501,7 @@ OVR_PUBLIC_FUNCTION(void) ovrHmd_Destroy(ovrHmd hmddesc)
ThreadChecker::Scope checkScope(&hmds->RenderAPIThreadChecker, "ovrHmd_Destroy");
}
+#if !defined(HEADLESS_APP)
#ifdef OVR_OS_WIN32
if (hmds->pWindow)
{
@@ -503,6 +511,7 @@ OVR_PUBLIC_FUNCTION(void) ovrHmd_Destroy(ovrHmd hmddesc)
Win32::DisplayShim::GetInstance().hWindow = (HWND)0;
}
#endif
+#endif /* !defined(HEADLESS_APP) */
delete (HMDState*)hmddesc->Handle;
}
@@ -694,6 +703,7 @@ OVR_PUBLIC_FUNCTION(void) ovrHmd_EndFrame(ovrHmd hmddesc,
{
hmds->pRenderer->SaveGraphicsState();
+#if !defined(HEADLESS_APP)
// See if we need to show the HSWDisplay.
if (hmds->pHSWDisplay) // Until we know that these are valid, assume any of them can't be.
{
@@ -706,6 +716,7 @@ OVR_PUBLIC_FUNCTION(void) ovrHmd_EndFrame(ovrHmd hmddesc,
hmds->pHSWDisplay->Render(ovrEye_Right, &eyeTexture[ovrEye_Right]);
}
}
+#endif /* !defined(HEADLESS_APP) */
if (posTimewarpDesc)
hmds->pRenderer->SetPositionTimewarpDesc(*posTimewarpDesc);
@@ -725,6 +736,7 @@ OVR_PUBLIC_FUNCTION(void) ovrHmd_EndFrame(ovrHmd hmddesc,
hmds->BeginFrameIndex++; // Set frame index to the next value in case 0 is passed.
}
+#if !defined(HEADLESS_APP)
// Not exposed as part of public API
OVR_PUBLIC_FUNCTION(void) ovrHmd_RegisterPostDistortionCallback(ovrHmd hmddesc, PostDistortionCallback callback)
{
@@ -734,6 +746,7 @@ OVR_PUBLIC_FUNCTION(void) ovrHmd_RegisterPostDistortionCallback(ovrHmd hmddesc,
hmds->pRenderer->RegisterPostDistortionCallback(callback);
}
+#endif /* !defined(HEADLESS_APP) */
@@ -943,7 +956,11 @@ OVR_PUBLIC_FUNCTION(ovrEyeRenderDesc) ovrHmd_GetRenderDesc(ovrHmd hmddesc,
}
-#define OVR_OFFSET_OF(s, field) ((size_t)&((s*)0)->field)
+#if defined(OVR_CC_MSVC)
+ #define OVR_OFFSET_OF(s, field) ((size_t)&((s*)0)->field)
+#else
+ #define OVR_OFFSET_OF(s, field) (1)
+#endif
OVR_PUBLIC_FUNCTION(ovrBool) ovrHmd_CreateDistortionMeshDebug(ovrHmd hmddesc,
@@ -1123,6 +1140,8 @@ OVR_PUBLIC_FUNCTION(double) ovrHmd_GetMeasuredLatencyTest2(ovrHmd hmddesc)
// ***** Health and Safety Warning Display interface
//
+#if !defined(HEADLESS_APP)
+
OVR_PUBLIC_FUNCTION(void) ovrHmd_GetHSWDisplayState(ovrHmd hmddesc, ovrHSWDisplayState *hswDisplayState)
{
if (!hswDisplayState)
@@ -1155,6 +1174,7 @@ OVR_PUBLIC_FUNCTION(ovrBool) ovrHmd_DismissHSWDisplay(ovrHmd hmddesc)
return ovrFalse;
}
+#endif /* !defined(HEADLESS_APP) */
// -----------------------------------------------------------------------------------
// ***** Property Access
diff --git a/LibOVR/Src/OVR_Profile.cpp b/LibOVR/Src/OVR_Profile.cpp
index 273d551..bfbfd51 100755
--- a/LibOVR/Src/OVR_Profile.cpp
+++ b/LibOVR/Src/OVR_Profile.cpp
@@ -39,7 +39,7 @@ limitations under the License.
#ifdef OVR_OS_WIN32
#include "Kernel/OVR_Win32_IncludeWindows.h"
-#include <Shlobj.h>
+#include <shlobj.h>
#elif defined(OVR_OS_MS) // Other Microsoft OSs
// Nothing, thanks.
#else