From: Tom Robinson Date: Wed, 5 Oct 2016 17:34:05 +0000 (+0100) Subject: VR: VR Enabled state used by all VR code X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=bf9c7700c5305440c2653abea6a365103fa5b81c;p=platform%2Fcore%2Fuifw%2Fdali-core.git VR: VR Enabled state used by all VR code Change-Id: If442fd2d57f533336c6a10edab3851342d29d2b3 --- diff --git a/dali/integration-api/vr-engine.h b/dali/integration-api/vr-engine.h index df436a6..e0f2edc 100644 --- a/dali/integration-api/vr-engine.h +++ b/dali/integration-api/vr-engine.h @@ -1,6 +1,7 @@ #ifndef DALI_VR_ENGINE_H #define DALI_VR_ENGINE_H +//todor licence #include #include @@ -12,20 +13,19 @@ class EglInterface; namespace Integration { -// using struct so in case of a need to pass more args only structure -// has to be modified. +// The Vr engine initialization parameters use a struct so in case of more args added, only this structure needs to be modified. namespace Vr { -struct VrEngineInitParams +struct VrEngineInitializeParams { - // screen settings + // Screen settings int screenWidth; int screenHeight; - // eye settings - uint32_t* fbos; // 2 values + // Eye settings + uint32_t* frameBufferObjects; ///< 2 values uint32_t* colorTextures; - uint32_t* depthTextures; // may be null + uint32_t* depthTextures; ///< May be null }; struct VrEngineEyePose @@ -37,7 +37,7 @@ struct VrEngineEyePose struct VrEngineRenderTargetInfo { int fbos[2]; - int colorTextures[2]; // if -1, then engine will create those buffers + int colorTextures[2]; ///< if -1, then engine will create these buffers int depthTextures[2]; }; } // Anonymous namespace @@ -49,6 +49,7 @@ class VrEngine { public: + //todor rename below enums enum EYE_ENUM { LEFT = 0, @@ -99,20 +100,24 @@ public: VrEngine() { } - virtual ~VrEngine() {} - virtual bool Initialize( Vr::VrEngineInitParams* initParams ) = 0; + virtual ~VrEngine() + { + } + + virtual bool Initialize( Vr::VrEngineInitializeParams* initializeParams ) = 0; + virtual void SetEnabled( bool enabled ) = 0; virtual void Start() = 0; virtual void Stop() = 0; virtual void PreRender() = 0; virtual void PostRender() = 0; virtual void SubmitFrame() = 0; - // client must perform output validation if necessary + // Client must perform output validation if necessary virtual bool Get( const int property, void* output, int count ) = 0; virtual bool Set( const int property, const void* input, int count ) = 0; - // helper functions + // Helper functions bool Get( int property, void* output ) { return Get( property, output, 1 ); @@ -125,7 +130,7 @@ public: inline bool Get( const int* properties, void** outputs, int count ) { - // fill output array + // Fill output array for( int i = 0; i < count; ++i ) { Get( properties[i], outputs[i], 1 ); @@ -135,7 +140,7 @@ public: inline bool Set( const int* properties, const void** inputs, int count ) { - // fill output array + // Fill output array for( int i = 0; i < count; ++i ) { return Set( properties[i], inputs[i], 1 ); diff --git a/dali/internal/common/core-impl.cpp b/dali/internal/common/core-impl.cpp index 3cebcf5..ecaf292 100644 --- a/dali/internal/common/core-impl.cpp +++ b/dali/internal/common/core-impl.cpp @@ -223,6 +223,7 @@ Core::~Core() delete mTextureCacheDispatcher; delete mUpdateManager; delete mRenderManager; + delete mVrManager; delete mRenderTaskProcessor; delete mGeometryBatcher; delete mTextureUploadedQueue; diff --git a/dali/internal/common/vr-manager-impl.cpp b/dali/internal/common/vr-manager-impl.cpp index 55fa16e..a709168 100644 --- a/dali/internal/common/vr-manager-impl.cpp +++ b/dali/internal/common/vr-manager-impl.cpp @@ -21,6 +21,8 @@ // EXTERNAL INCLUDES #include #include +//todor +#include namespace Dali { @@ -31,6 +33,7 @@ namespace Internal namespace { +//todor delete this #define GL(x) { x; int err = context.GetError(); if(err) { DALI_LOG_ERROR( "GL_ERROR: [%d] '%s', %x\n", __LINE__, #x, (unsigned)err);fflush(stderr);fflush(stdout);} else { /*DALI_LOG_ERROR("GL Call: %s\n", #x); fflush(stdout);*/} } // These dimensions must match those used by the Tizen VR engine. @@ -43,7 +46,8 @@ const Rect DEFAULT_VR_VIEWPORT_DIMENSIONS( 0, 0, 1024, 1024 ); VrManager::VrManager( Dali::Integration::VrEngine* vrEngine ) : mVrEngine( vrEngine ), mHeadNode( NULL ), - mEnabled( true ), + //mEnabled( true ), //todor default to false + mEnabled( false ), //todor default to false mEngineInitialized( false ) { } @@ -54,7 +58,9 @@ VrManager::~VrManager() void VrManager::SetEnabled( bool enabled ) { + std::cout << "todor: --------------------- VrManager::SetEnabled" << std::endl; mEnabled = enabled; + mVrEngine->SetEnabled( enabled ); } bool VrManager::IsEnabled() const @@ -98,8 +104,8 @@ void VrManager::PrepareRender( int surfaceWidth, int surfaceHeight ) if( !mEngineInitialized ) { // Initialise VR engine. - Dali::Integration::Vr::VrEngineInitParams params; - memset( ¶ms, 0, sizeof( Dali::Integration::Vr::VrEngineInitParams ) ); + Dali::Integration::Vr::VrEngineInitializeParams params; + memset( ¶ms, 0, sizeof( Dali::Integration::Vr::VrEngineInitializeParams ) ); params.screenWidth = surfaceWidth; params.screenHeight = surfaceHeight; @@ -124,12 +130,12 @@ bool VrManager::RenderEyes( Context& context, Dali::Camera::Type cameraType ) context.GetError(); // This reads all the required VR information in one go. - int leftFrameBufferObject(-1); - int rightFrameBufferObject(-1); - int leftTexture(-1); - int rightTexture(-1); - int bufferWidth(-1); - int bufferHeight(-1); + int leftFrameBufferObject( -1 ); + int rightFrameBufferObject( -1 ); + int leftTexture( -1 ); + int rightTexture( -1 ); + int bufferWidth( -1 ); + int bufferHeight( -1 ); static const int properties[] = { diff --git a/dali/internal/render/common/render-manager.cpp b/dali/internal/render/common/render-manager.cpp index c6bf827..36c32ed 100644 --- a/dali/internal/render/common/render-manager.cpp +++ b/dali/internal/render/common/render-manager.cpp @@ -542,6 +542,7 @@ bool RenderManager::Render( Integration::RenderStatus& status ) if( !mImpl->firstRenderCompleted || mImpl->renderersAdded ) { // This will perform pre-render steps with the Tizen VR Engine IF using Tizen VR. + //todor mImpl->vrManager.PrepareRender( mImpl->defaultSurfaceRect.width, mImpl->defaultSurfaceRect.height ); if( !mImpl->vrManager.IsEnabled() ) diff --git a/dali/internal/update/manager/update-manager.cpp b/dali/internal/update/manager/update-manager.cpp index 29427bb..1c0b1f1 100644 --- a/dali/internal/update/manager/update-manager.cpp +++ b/dali/internal/update/manager/update-manager.cpp @@ -966,6 +966,7 @@ unsigned int UpdateManager::Update( float elapsedSeconds, ForwardCompiledShadersToEventThread(); // Update the camera look direction from the VR eye pose. + //todor mImpl->vrManager.UpdateHeadOrientation(); // Although the scene-graph may not require an update, we still need to synchronize double-buffered