Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/origin/master' into release
Browse files Browse the repository at this point in the history
Conflicts:
	include/version.h
  • Loading branch information
febret committed Nov 9, 2015
2 parents 95bcfb1 + 7ca1013 commit dec9261
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 150 deletions.
94 changes: 37 additions & 57 deletions include/omega/GpuResource.h
Original file line number Diff line number Diff line change
@@ -1,29 +1,3 @@
/**************************************************************************************************
* THE OMEGA LIB PROJECT
*-------------------------------------------------------------------------------------------------
* Copyright 2010-2015 Electronic Visualization Laboratory, University of Illinois at Chicago
* Authors:
* Alessandro Febretti febret@gmail.com
*-------------------------------------------------------------------------------------------------
* Copyright (c) 2010-2015, Electronic Visualization Laboratory, University of Illinois at Chicago
* All rights reserved.
* Redistribution and use in source and binary forms, with or without modification, are permitted
* provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this list of conditions
* and the following disclaimer. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the documentation and/or other
* materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*************************************************************************************************/
/******************************************************************************
* THE OMEGA LIB PROJECT
*-----------------------------------------------------------------------------
Expand Down Expand Up @@ -82,44 +56,50 @@ typedef struct GLEWContextStruct GLEWContext;

namespace omega
{
///////////////////////////////////////////////////////////////////////////////////////////////
class OMEGA_API GpuContext: public ReferenceType
{
public:
static const unsigned int MaxContexts = 64;
enum TextureUnit {
TextureUnitInvalid = 0,
TextureUnit0 = GL_TEXTURE0,
TextureUnit1 = GL_TEXTURE1,
TextureUnit2 = GL_TEXTURE2,
TextureUnit3 = GL_TEXTURE3 };
///////////////////////////////////////////////////////////////////////////
class OMEGA_API GpuContext: public ReferenceType
{
public:
static const unsigned int MaxContexts = 64;
enum TextureUnit {
TextureUnitInvalid = 0,
TextureUnit0 = GL_TEXTURE0,
TextureUnit1 = GL_TEXTURE1,
TextureUnit2 = GL_TEXTURE2,
TextureUnit3 = GL_TEXTURE3 };

GpuContext(bool initializeGlew = true);
~GpuContext();
//! Initializes a GPU context. If the passed GLEW context is null,
//! a glew context will be created internally and GLEW will be
//! initialized by this contstructor.
//! @remarks This method needs to be called from within a valid OpenGL
//! context.
GpuContext(GLEWContext* ctx = NULL);
~GpuContext();

uint getId() { return myId; }
GLEWContext* getGlewContext() { return myGlewContext; }
uint getId() { return myId; }
GLEWContext* getGlewContext() { return myGlewContext; }
void makeCurrent();
//void setGlewContext(GLEWContext* ctx) { myGlewContext = ctx; }

private:
static uint mysNumContexts;
static Lock mysContextLock;
private:
static uint mysNumContexts;
static Lock mysContextLock;

uint myId;
GLEWContext* myGlewContext;
};
uint myId;
GLEWContext* myGlewContext;
bool myOwnGlewContext;
};

///////////////////////////////////////////////////////////////////////////////////////////////
class OMEGA_API GpuResource: public ReferenceType
{
public:
GpuResource(GpuContext* ctx): myContext(ctx) { }
GpuContext* getContext() { return myContext; }
virtual void dispose() = 0;
private:
GpuContext* myContext;
};
///////////////////////////////////////////////////////////////////////////////////////////////
class OMEGA_API GpuResource: public ReferenceType
{
public:
GpuResource(GpuContext* ctx): myContext(ctx) { }
GpuContext* getContext() { return myContext; }
virtual void dispose() = 0;
private:
GpuContext* myContext;
};
}; // namespace omega

#endif
1 change: 0 additions & 1 deletion src/displaySystems/Equalizer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ add_library(displaySystem_Equalizer SHARED
ChannelImpl.cpp
ConfigImpl.cpp
NodeImpl.cpp
PipeImpl.cpp
WindowImpl.cpp)

target_link_libraries(displaySystem_Equalizer ${EQUALIZER_LIBS} omega)
Expand Down
53 changes: 0 additions & 53 deletions src/displaySystems/Equalizer/PipeImpl.cpp

This file was deleted.

20 changes: 11 additions & 9 deletions src/displaySystems/Equalizer/WindowImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ using namespace std;

///////////////////////////////////////////////////////////////////////////////
WindowImpl::WindowImpl(eq::Pipe* parent):
eq::Window(parent), myPipe((PipeImpl*)parent),
eq::Window(parent),
myVisible(false), mySkipResize(false)
//myIndex(Vector2i::Zero())
{
Expand All @@ -61,6 +61,11 @@ omicron::Lock sInitLock;
///////////////////////////////////////////////////////////////////////////////
bool WindowImpl::configInit(const uint128_t& initID)
{
// Serialize window init execution since we are tinkering with x cursors on linux inside there.
sInitLock.lock();
bool res = Window::configInit(initID);
sInitLock.unlock();

// Get the tile index from the window name.
String name = getName();

Expand All @@ -78,15 +83,12 @@ bool WindowImpl::configInit(const uint128_t& initID)
if(app)
{
myRenderer = new Renderer(Engine::instance());
myRenderer->setGpuContext(myPipe->getGpuContext());
myGpuContext = new GpuContext(const_cast<GLEWContext*>(this->glewGetContext()));
myRenderer->setGpuContext(myGpuContext);
myRenderer->initialize();
}
else return false;

// Serialize window init execution since we are tinkering with x cursors on linux inside there.
sInitLock.lock();
bool res = Window::configInit(initID);
sInitLock.unlock();
oflog(Debug, "[WindowImpl::configInit] <%1%> done", %initID);
return res;
}
Expand Down Expand Up @@ -208,10 +210,10 @@ void WindowImpl::frameStart(const uint128_t& frameID, const uint32_t frameNumber
// NOTE: getting the glew context from the first window is correct since all
// windows attached to the same pape share the same Glew (and OpenGL) contexts.
// NOTE2: do NOT remove these two lines. rendering explodes if you do.
const GLEWContext* glewc = myRenderer->getGpuContext()->getGlewContext();
myRenderer->getGpuContext()->makeCurrent();
oassert(glewc != NULL);
const GLEWContext* glewc = myGpuContext->getGlewContext();
//myRenderer->getGpuContext()->setGlewContext(glewc);
myGpuContext->makeCurrent();
oassert(glewc != NULL);
glewSetContext(glewc);
}

Expand Down
22 changes: 1 addition & 21 deletions src/displaySystems/Equalizer/eqinternal.h
Original file line number Diff line number Diff line change
Expand Up @@ -168,24 +168,6 @@ class NodeImpl: public eq::Node
//FrameData myFrameData;
};

///////////////////////////////////////////////////////////////////////////////
//! @internal
class PipeImpl: public eq::Pipe
{
public:
//EIGEN_MAKE_ALIGNED_OPERATOR_NEW
public:
PipeImpl(eq::Node* parent);
GpuContext* getGpuContext() { return myGpuContext.get(); }

protected:
virtual ~PipeImpl();
virtual bool configInit(const uint128_t& initID);
private:
NodeImpl* myNode;
omicron::Ref<GpuContext> myGpuContext;
};

///////////////////////////////////////////////////////////////////////////////
//! @internal
//! A Window represents an on-screen or off-screen drawable. A drawable is a 2D rendering surface,
Expand All @@ -211,8 +193,8 @@ class WindowImpl: public eq::Window
bool processEvent(const eq::Event& event);

private:
PipeImpl* myPipe;
omicron::Ref<Renderer> myRenderer;
omicron::Ref<GpuContext> myGpuContext;
DisplayTileConfig* myTile;
bool myVisible;
Rect myCurrentRect;
Expand Down Expand Up @@ -262,8 +244,6 @@ class EqualizerNodeFactory: public eq::NodeFactory
{ return new ChannelImpl( parent ); }
virtual eq::Window* createWindow(eq::Pipe* parent)
{ return new WindowImpl(parent); }
virtual eq::Pipe* createPipe(eq::Node* parent)
{ return new PipeImpl(parent); }
virtual eq::Node* createNode( eq::Config* parent )
{ return new NodeImpl( parent ); }
};
Expand Down
21 changes: 12 additions & 9 deletions src/omega/GpuResource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,24 @@ uint GpuContext::mysNumContexts = 0;
Lock GpuContext::mysContextLock = Lock();

///////////////////////////////////////////////////////////////////////////////
GpuContext::GpuContext(bool initializeGlew)
GpuContext::GpuContext(GLEWContext* ctx)
{
mysContextLock.lock();
myId = mysNumContexts++;
myOwnGlewContext = false;
mysContextLock.lock();
myId = mysNumContexts++;

// Initialize Glew
myGlewContext = new GLEWContext();
glewSetContext(myGlewContext);
if(initializeGlew)
// Initialize Glew
myGlewContext = ctx;
if(myGlewContext == NULL)
{
myGlewContext = new GLEWContext();
myOwnGlewContext = true;
glewSetContext(myGlewContext);
oflog(Debug, "[GpuContext::GpuContext] <%1%> Glew init", %myId);
glewInit();
}

mysContextLock.unlock();
mysContextLock.unlock();
}

///////////////////////////////////////////////////////////////////////////////
Expand All @@ -59,6 +62,6 @@ void GpuContext::makeCurrent()
///////////////////////////////////////////////////////////////////////////////
GpuContext::~GpuContext()
{
delete myGlewContext;
if(myOwnGlewContext) delete myGlewContext;
myGlewContext = NULL;
}

0 comments on commit dec9261

Please sign in to comment.