void SharedLock::ReleaseLock(Lock* plock) { OVR_UNUSED(plock); OVR_ASSERT(plock == toLock()); int oldUseCount, oldUseCount_tmp; do { oldUseCount = UseCount; OVR_ASSERT(oldUseCount != (int)LockInitMarker); if (oldUseCount == 1) { // Initialize marker int tmp_one = 1; int tmp_LockInitMarker = LockInitMarker; if (UseCount.compare_exchange_strong(tmp_one, LockInitMarker)) { Destruct<Lock>(toLock()); do { } while (!UseCount.compare_exchange_weak(tmp_LockInitMarker, 0)); return; } continue; } oldUseCount_tmp = oldUseCount; } while (!UseCount.compare_exchange_weak(oldUseCount_tmp, oldUseCount - 1, std::memory_order_relaxed)); }
void SharedLock::ReleaseLock(Lock* plock) { OVR_UNUSED(plock); OVR_ASSERT((plock = toLock()) != 0); int oldUseCount; do { oldUseCount = UseCount; OVR_ASSERT(oldUseCount != LockInitMarker); if (oldUseCount == 1) { // Initialize marker if (AtomicOps<int>::CompareAndSet_Sync(&UseCount, 1, LockInitMarker)) { Destruct<Lock>(toLock()); do { } while (!AtomicOps<int>::CompareAndSet_Sync(&UseCount, LockInitMarker, 0)); return; } continue; } } while (!AtomicOps<int>::CompareAndSet_NoSync(&UseCount, oldUseCount, oldUseCount - 1)); }
//============================== // OvrSliderComponent::OnTouchRelative eMsgStatus OvrSliderComponent::OnTouchRelative( OvrGuiSys & guiSys, VrFrame const & vrFrame, VRMenuObject * self, VRMenuEvent const & event ) { OVR_UNUSED( vrFrame ); return MSG_STATUS_CONSUMED; }
ULONG WINAPI OVRRiftForContext(PVOID context, HANDLE driverHandle) { OVR_UNUSED( driverHandle ); OVR::Win32::DisplayShim* con = (OVR::Win32::DisplayShim*)context; return con->ChildUid; }
bool DeviceManagerImpl::Initialize(DeviceBase* parent) { OVR_UNUSED(parent); if (!pCreateDesc || !pCreateDesc->pLock) return false; return true; }
//============================== // OvrSliderComponent::SetCaretPoseFromFrac void OvrSliderComponent::SetCaretPoseFromFrac( OvrVRMenuMgr & menuMgr, VRMenuObject * self, float const frac ) { OVR_UNUSED( frac ); VRMenuObject * caret = menuMgr.ToObject( self->ChildHandleForId( menuMgr, ScrubberId ) ); if ( caret != NULL ) { Posef curPose = CaretBasePose; float range = MaxValue - MinValue; float frac = floor( SliderFrac * range ) / range; curPose.Position += ( LocalSlideDelta * -0.5f ) + LocalSlideDelta * frac; caret->SetLocalPose( curPose ); } // find the fill object and scale it menuHandle_t fillHandle = Menu.HandleForId( menuMgr, FillId ); VRMenuObject * fillObj = menuMgr.ToObject( fillHandle ); if ( fillObj != NULL ) { Vector4f clipUVs( 0.0f, 1.0f - SliderFrac, 1.0f, 1.0f ); VRMenuSurface & surf = fillObj->GetSurface( 0 ); surf.SetClipUVs( clipUVs ); //LOG( "SliderFrac = %.2f", SliderFrac ); //LOG( "Setting clip UVs to ( %.2f, %.2f, %.2f, %.2f )", clipUVs.x, clipUVs.y, clipUVs.z, clipUVs.w ); } }
void OvrVideoMenu::Open_Impl( OvrGuiSys & guiSys ) { OVR_UNUSED( guiSys ); ButtonCoolDown = BUTTON_COOL_DOWN_SECONDS; OpenTime = vrapi_GetTimeInSeconds(); }
//============================== // OvrSliderComponent::OnInit eMsgStatus OvrSliderComponent::OnInit( OvrGuiSys & guiSys, VrFrame const & vrFrame, VRMenuObject * self, VRMenuEvent const & event ) { OVR_UNUSED( vrFrame ); OVR_UNUSED( event ); // find the starting offset of the caret //LOG( "OvrSliderComponent - VRMENU_EVENT_INIT" ); VRMenuObject * caret = guiSys.GetVRMenuMgr().ToObject( self->ChildHandleForId( guiSys.GetVRMenuMgr(), ScrubberId ) ); if ( caret != NULL ) { CaretBasePose = caret->GetLocalPose(); } SetCaretPoseFromFrac( guiSys.GetVRMenuMgr(), self, SliderFrac ); UpdateText( guiSys.GetVRMenuMgr(), self, BubbleId ); return MSG_STATUS_ALIVE; }
//------------------------------------------------------------------------------------- // ***** Texture // Texture::Texture(RenderParams* rp, int fmt, const Sizei texSize, ID3D1xSamplerState* sampler, int samples) : pParams(rp), Tex(NULL), TexSv(NULL), TexRtv(NULL), TexDsv(NULL), TextureSize(texSize), Sampler(sampler), Samples(samples) { OVR_UNUSED(fmt); }
void PerformanceTimer::Shutdown() { DeleteCriticalSection(&TimeCS); #if defined(OVR_OS_WIN32) // Desktop Windows only MMRESULT mmr = timeEndPeriod(1); OVR_ASSERT(TIMERR_NOERROR == mmr); OVR_UNUSED(mmr); #endif }
bool MutexImpl::IsLockedByAnotherThread(Mutex* pmutex) { OVR_UNUSED(pmutex); // There could be multiple interpretations of IsLocked with respect to current thread if (LockCount == 0) return 0; if (pthread_self() != LockedBy) return 1; return 0; }
RenderDevice::RenderDevice(const Render::RendererParams& p, HWND win, HGLRC gl) : GL::RenderDevice(p) , Window(win) , WglContext(gl) , PreFullscreen(0, 0, 0, 0) , HMonitor(0) , FSDesktop(0, 0, 0, 0) { OVR_UNUSED(p); }
void HIDDevice::OnOverlappedEvent(HANDLE hevent) { OVR_UNUSED(hevent); OVR_ASSERT(hevent == ReadOverlapped.hEvent); if (processReadResult()) { // Proceed to read again. initializeRead(); } }
void MutexImpl::Unlock(Mutex* pmutex) { OVR_UNUSED(pmutex); OVR_ASSERT(pthread_self() == LockedBy && LockCount > 0); //unsigned lockCount; LockCount--; //lockCount = LockCount; pthread_mutex_unlock(&SMutex); }
//----------------------------------------------------------------------------- void HIDDevice::closeDevice(bool wasUnplugged) { OVR_UNUSED(wasUnplugged); OVR_ASSERT(DeviceHandle >= 0); HIDManager->DevManager->pThread->RemoveSelectFd(this,-1); hid_close(DeviceHandle); DeviceHandle = NULL; LogText("OVR::Linux::HIDDevice - HID Device Closed '%s'\n", DevDesc.Path.ToCStr()); }
Matrix4f OvrSceneView::GetEyeProjectionMatrix( const int eye, const float fovDegreesX, const float fovDegreesY ) const { OVR_UNUSED( eye ); // We may want to make per-eye projection matrices if we move away from nearly-centered lenses. // Use an infinite projection matrix because, except for things right up against the near plane, // it provides better precision: // "Tightening the Precision of Perspective Rendering" // Paul Upchurch, Mathieu Desbrun // Journal of Graphics Tools, Volume 16, Issue 1, 2012 return ovrMatrix4f_CreateProjectionFov( fovDegreesX, fovDegreesY, 0.0f, 0.0f, Znear, 0.0f ); }
void RefCountNTSImplCore::checkInvalidDelete(RefCountNTSImplCore *pmem) { #ifdef OVR_BUILD_DEBUG if (pmem->RefCount != 0) { OVR_DEBUG_LOG( ("Invalid delete call on ref-counted object at %p. Please use Release()", pmem) ); OVR_ASSERT(0); } #else OVR_UNUSED( pmem ); #endif }
void MMapFree(void* memory, size_t size) { #if defined(OVR_OS_MS) OVR_UNUSED(size); VirtualFree(memory, 0, MEM_RELEASE); #elif defined(OVR_OS_MAC) || defined(OVR_OS_UNIX) size_t pageSize = getpagesize(); size = (((size + (pageSize - 1)) / pageSize) * pageSize); munmap(memory, size); // Must supply the size to munmap. #endif }
String VideoBrowser::GetPanelTitle( OvrGuiSys & guiSys, const OvrMetaDatum & panelData ) const { OVR_UNUSED( guiSys ); const OvrVideosMetaDatum * const videosDatum = static_cast< const OvrVideosMetaDatum * const >( &panelData ); if ( videosDatum != NULL ) { String outStr; Videos.GetLocale().GetString( videosDatum->Title.ToCStr(), videosDatum->Title.ToCStr(), outStr ); return outStr; } return String(); }
void PerformanceTimer::Initialize() { ::InitializeCriticalSection(&TimeCS); MMTimeWrapCounter = 0; getFrequency(); #if defined(OVR_OS_WIN32) // Desktop Windows only // Set Vista flag. On Vista, we can just use QPC() without all the extra work OSVERSIONINFOEXW ver; ZeroMemory(&ver, sizeof(OSVERSIONINFOEXW)); ver.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXW); ver.dwMajorVersion = 6; // Vista+ DWORDLONG condMask = 0; VER_SET_CONDITION(condMask, VER_MAJORVERSION, VER_GREATER_EQUAL); // VerifyVersionInfo returns true if the OS meets the conditions set above UsingVistaOrLater = ::VerifyVersionInfoW(&ver, VER_MAJORVERSION, condMask) != 0; #else UsingVistaOrLater = true; #endif if (!UsingVistaOrLater) { #if defined(OVR_OS_WIN32) // Desktop Windows only // The following has the effect of setting the NT timer resolution (NtSetTimerResolution) to 1 millisecond. MMRESULT mmr = timeBeginPeriod(1); OVR_ASSERT(TIMERR_NOERROR == mmr); OVR_UNUSED(mmr); #endif #if defined(OVR_BUILD_DEBUG) && defined(OVR_OS_WIN32) HMODULE hNtDll = ::LoadLibraryW(L"NtDll.dll"); if (hNtDll) { pNtQueryTimerResolution = (NtQueryTimerResolutionType)::GetProcAddress(hNtDll, "NtQueryTimerResolution"); //pNtSetTimerResolution = (NtSetTimerResolutionType)::GetProcAddress(hNtDll, "NtSetTimerResolution"); if (pNtQueryTimerResolution) { ULONG MinimumResolution; // in 100-ns units ULONG MaximumResolution; ULONG ActualResolution; pNtQueryTimerResolution(&MinimumResolution, &MaximumResolution, &ActualResolution); OVR_DEBUG_LOG(("NtQueryTimerResolution = Min %ld us, Max %ld us, Current %ld us", MinimumResolution / 10, MaximumResolution / 10, ActualResolution / 10)); } ::FreeLibrary(hNtDll); } #endif } }
void Log::DefaultLogOutput(const char* formattedText, LogMessageType messageType, int bufferSize) { bool debug = IsDebugMessage(messageType); OVR_UNUSED(bufferSize); #if defined(OVR_OS_WIN32) // Under Win32, output regular messages to console if it exists; debug window otherwise. static DWORD dummyMode; static bool hasConsole = (GetStdHandle(STD_OUTPUT_HANDLE) != INVALID_HANDLE_VALUE) && (GetConsoleMode(GetStdHandle(STD_OUTPUT_HANDLE), &dummyMode)); if (!hasConsole || debug) { ::OutputDebugStringA(formattedText); } fputs(formattedText, stdout); #elif defined(OVR_OS_MS) // Any other Microsoft OSs ::OutputDebugStringA(formattedText); #elif defined(OVR_OS_ANDROID) // To do: use bufferSize to deal with the case that Android has a limited output length. __android_log_write(ANDROID_LOG_INFO, "OVR", formattedText); #else fputs(formattedText, stdout); #endif if (messageType == Log_Error) { #if defined(OVR_OS_WIN32) if (!ReportEventA(hEventSource, EVENTLOG_ERROR_TYPE, 0, 0, NULL, 1, 0, &formattedText, NULL)) { OVR_ASSERT(false); } #elif defined(OVR_OS_MS) // Any other Microsoft OSs // TBD #elif defined(OVR_OS_ANDROID) // TBD #elif defined(OVR_OS_MAC) || defined(OVR_OS_LINUX) syslog(LOG_ERR, "%s", formattedText); #else // TBD #endif } // Just in case. OVR_UNUSED2(formattedText, debug); }
void MutexImpl::Unlock(Mutex* pmutex) { OVR_UNUSED(pmutex); LockCount--; // Release mutex if ((Recursive ? ReleaseMutex(hMutexOrSemaphore) : ReleaseSemaphore(hMutexOrSemaphore, 1, NULL)) != 0) { // This used to call Wait handlers if LockCount == 0. } }
void OculusWorldDemoApp::OnMouseMove(int x, int y, int modifiers) { OVR_UNUSED(y); if(modifiers & Mod_MouseRelative) { // Get Delta int dx = x; // Apply to rotation. Subtract for right body frame rotation, // since yaw rotation is positive CCW when looking down on XZ plane. ThePlayer.BodyYaw -= (Sensitivity * dx) / 360.0f; } }
void OvrVideoMenu::OnItemEvent_Impl( OvrGuiSys & guiSys, ovrFrameInput const & vrFrame, VRMenuId_t const itemId, VRMenuEvent const & event ) { OVR_UNUSED( vrFrame ); OVR_UNUSED( event ); const double now = vrapi_GetTimeInSeconds(); if ( ButtonCoolDown <= 0.0f && (now - OpenTime > 0.5)) { ButtonCoolDown = BUTTON_COOL_DOWN_SECONDS; Oculus360Videos * videos = static_cast< Oculus360Videos* >( guiSys.GetApp()->GetAppInterface() ); if ( itemId.Get() == ID_BROWSER_BUTTON.Get() ) { videos->SetMenuState( Oculus360Videos::MENU_BROWSER ); } else if ( itemId.Get( ) == ID_VIDEO_BUTTON.Get( ) ) { videos->SeekTo( 0 ); } } }
bool ShaderBase::SetUniformBool(const char* name, int n, const bool* v) { OVR_UNUSED(n); for(unsigned i = 0; i < UniformReflSize; i++) { if (!strcmp(UniformRefl[i].Name, name)) { memcpy(UniformData + UniformRefl[i].Offset, v, UniformRefl[i].Size); return 1; } } return 0; }
//------------------------------------------------------------------------------------- // ***** Texture // Texture::Texture(RenderDevice* ren, int fmt, int w, int h) : Ren(ren), Tex(NULL), TexSv(NULL), TexRtv(NULL), TexDsv(NULL), Sampler(NULL), Width(w), Height(h), Samples(0) { OVR_UNUSED(fmt); Sampler = Ren->GetSamplerState(0); }
bool GamepadManager::GetGamepadState(UInt32 index, GamepadState* pState) { // For now we just support one gamepad. OVR_UNUSED(index); if (!bStateChanged) { return false; } bStateChanged = false; // State.Debug(); *pState = State; return true; }
void DeviceManager::displayReconfigurationCallBack (CGDirectDisplayID display, CGDisplayChangeSummaryFlags flags, void *userInfo) { DeviceManager* manager = reinterpret_cast<DeviceManager*>(userInfo); OVR_UNUSED(manager); if (flags & kCGDisplayAddFlag) { LogText("Display Added, id = %d\n", int(display)); manager->EnumerateDevices<HMDDevice>(); } else if (flags & kCGDisplayRemoveFlag) { LogText("Display Removed, id = %d\n", int(display)); manager->EnumerateDevices<HMDDevice>(); } }
// Returns global high-resolution application timer in seconds. double Timer::GetSeconds() { if(useFakeSeconds) return FakeSeconds; // Choreographer vsync timestamp is based on. struct timespec tp; const int status = clock_gettime(CLOCK_MONOTONIC, &tp); #ifdef OVR_BUILD_DEBUG if (status != 0) { OVR_DEBUG_LOG(("clock_gettime status=%i", status )); } #else OVR_UNUSED(status); #endif return (double)tp.tv_sec; }
uint64_t Timer::GetTicksNanos() { if (useFakeSeconds) return (uint64_t) (FakeSeconds * NanosPerSecond); // Choreographer vsync timestamp is based on. struct timespec tp; const int status = clock_gettime(CLOCK_MONOTONIC, &tp); #ifdef OVR_BUILD_DEBUG if (status != 0) { OVR_DEBUG_LOG(("clock_gettime status=%i", status )); } #else OVR_UNUSED(status); #endif const uint64_t result = (uint64_t)tp.tv_sec * (uint64_t)(1000 * 1000 * 1000) + uint64_t(tp.tv_nsec); return result; }