Skip to content

Commit

Permalink
Remove channel FBO drawable; use window hint_drawable FBO instead
Browse files Browse the repository at this point in the history
  • Loading branch information
tribal-tec committed Feb 27, 2015
1 parent f35aad3 commit 3980118
Show file tree
Hide file tree
Showing 14 changed files with 47 additions and 241 deletions.
109 changes: 3 additions & 106 deletions eq/client/channel.cpp
Expand Up @@ -45,7 +45,6 @@
#include "window.h"

#include <eq/util/accum.h>
#include <eq/util/frameBufferObject.h>
#include <eq/util/objectManager.h>
#include <eq/fabric/commands.h>
#include <eq/fabric/frameData.h>
Expand Down Expand Up @@ -216,9 +215,6 @@ const DrawableConfig& Channel::getDrawableConfig() const
{
const Window* window = getWindow();
LBASSERT( window );
if( _impl->fbo )
return _impl->drawableConfig;

return window->getDrawableConfig();
}

Expand All @@ -235,9 +231,6 @@ bool Channel::configExit()
delete _impl->_dcProxy;
_impl->_dcProxy = 0;
#endif

delete _impl->fbo;
_impl->fbo = 0;
return true;
}

Expand All @@ -251,88 +244,15 @@ bool Channel::configInit( const uint128_t& )
_impl->_dcProxy = new dc::Proxy( this );
}
#endif
return _configInitFBO();
}

bool Channel::_configInitFBO()
{
const uint32_t drawable = getDrawable();
if( drawable == FB_WINDOW )
return true;

const Window* window = getWindow();
if( !window->getSystemWindow() ||
!GLEW_ARB_texture_non_power_of_two || !GLEW_EXT_framebuffer_object )
{
sendError( ERROR_FBO_UNSUPPORTED );
return false;
}

// needs glew initialized (see above)
_impl->fbo = new util::FrameBufferObject( glewGetContext( ));

int depthSize = 0;
if( drawable & FBO_DEPTH )
{
depthSize = window->getIAttribute( WindowSettings::IATTR_PLANES_DEPTH );
if( depthSize < 1 )
depthSize = 24;
}

int stencilSize = 0;
if( drawable & FBO_STENCIL )
{
stencilSize =
window->getIAttribute( WindowSettings::IATTR_PLANES_STENCIL );
if( stencilSize < 1 )
stencilSize = 1;
}

const PixelViewport& pvp = getNativePixelViewport();
const Error error = _impl->fbo->init( pvp.w, pvp.h,
window->getColorFormat(), depthSize,
stencilSize );
if( !error )
return true;

sendError( error.getCode( ));
delete _impl->fbo;
_impl->fbo = 0;
return false;
return true;
}

void Channel::_initDrawableConfig()
{
const Window* window = getWindow();
_impl->drawableConfig = window->getDrawableConfig();
if( !_impl->fbo )
return;

const util::Textures& colors = _impl->fbo->getColorTextures();
if( !colors.empty( ))
{
switch( colors.front()->getType( ))
{
case GL_FLOAT:
_impl->drawableConfig.colorBits = 32;
break;
case GL_HALF_FLOAT:
_impl->drawableConfig.colorBits = 16;
break;
case GL_UNSIGNED_INT_10_10_10_2:
_impl->drawableConfig.colorBits = 10;
break;

default:
LBUNIMPLEMENTED;
case GL_UNSIGNED_BYTE:
_impl->drawableConfig.colorBits = 8;
break;
}
}
}


void Channel::notifyViewportChanged()
{
const PixelViewport oldPVP = getPixelViewport();
Expand Down Expand Up @@ -515,11 +435,6 @@ Frustumf Channel::getScreenFrustum() const
-1.f, 1.f );
}

util::FrameBufferObject* Channel::getFrameBufferObject()
{
return _impl->fbo;
}

View* Channel::getView()
{
LB_TS_THREAD( _pipeThread );
Expand Down Expand Up @@ -580,26 +495,11 @@ void Channel::removeResultImageListener( ResultImageListener* listener )
//---------------------------------------------------------------------------
// apply convenience methods
//---------------------------------------------------------------------------
void Channel::applyFrameBufferObject()
{
LB_TS_THREAD( _pipeThread );
if( _impl->fbo )
{
const PixelViewport& pvp = getNativePixelViewport();
const Error error = _impl->fbo->resize( pvp.w, pvp.h );
if( error )
sendError( error.getCode( ));
_impl->fbo->bind();
}
else if( GLEW_EXT_framebuffer_object )
glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, 0 );
}

void Channel::applyBuffer()
{
LB_TS_THREAD( _pipeThread );
const Window* window = getWindow();
if( !_impl->fbo && window->getSystemWindow()->getFrameBufferObject() == 0 )
if( !window->getSystemWindow()->getFrameBufferObject( ))
{
EQ_GL_CALL( glReadBuffer( getReadBuffer( )));
EQ_GL_CALL( glDrawBuffer( getDrawBuffer( )));
Expand All @@ -615,10 +515,7 @@ void Channel::bindFrameBuffer()
if( !window->getSystemWindow( ))
return;

if( _impl->fbo )
applyFrameBufferObject();
else
window->bindFrameBuffer();
window->bindFrameBuffer();
}

void Channel::applyColorMask() const
Expand Down
14 changes: 1 addition & 13 deletions eq/client/channel.h
Expand Up @@ -119,9 +119,6 @@ class Channel : public fabric::Channel< Window, Channel >
/** const-version of getNativeView() @version 1.0 */
EQ_API const View* getNativeView() const;

/** @return the FBO used as an alternate frame buffer. @version 1.0*/
EQ_API util::FrameBufferObject* getFrameBufferObject();

/** @return a fixed unique color for this channel. @version 1.0 */
EQ_API const Vector3ub& getUniqueColor() const;

Expand Down Expand Up @@ -258,13 +255,7 @@ class Channel : public fabric::Channel< Window, Channel >
EQ_API virtual void applyOrthoTransform() const;

/**
* Apply the current alternate frame buffer.
* @version 1.0
*/
EQ_API virtual void applyFrameBufferObject();

/**
* Rebind the current alternate FBO of the channel or window.
* Rebind the window frame buffer.
* @version 1.0
*/
EQ_API void bindFrameBuffer();
Expand Down Expand Up @@ -591,9 +582,6 @@ class Channel : public fabric::Channel< Window, Channel >
/** Setup the current rendering context. */
void _overrideContext( RenderContext& context );

/** Initialize the FBO */
bool _configInitFBO();

/** Initialize the channel's drawable config. */
void _initDrawableConfig();

Expand Down
1 change: 0 additions & 1 deletion eq/client/compositor.cpp
Expand Up @@ -35,7 +35,6 @@
#include "windowSystem.h"

#include <eq/util/accum.h>
#include <eq/util/frameBufferObject.h>
#include <eq/util/objectManager.h>

#include <co/global.h>
Expand Down
1 change: 0 additions & 1 deletion eq/client/dc/proxy.cpp
Expand Up @@ -28,7 +28,6 @@
#include "../windowSystem.h"

#include <eq/fabric/drawableConfig.h>
#include <eq/util/frameBufferObject.h>
#include <eq/util/objectManager.h>
#include <eq/util/texture.h>

Expand Down
7 changes: 1 addition & 6 deletions eq/client/detail/channel.ipp
Expand Up @@ -48,7 +48,6 @@ class Channel
public:
Channel()
: state( STATE_STOPPED )
, fbo( 0 )
, initialSize( Vector2i::ZERO )
#ifdef EQUALIZER_USE_DEFLECT
, _dcProxy( 0 )
Expand All @@ -64,7 +63,6 @@ public:
{
framebufferImage.flush();
statistics->clear();
LBASSERT( !fbo );
}

void addResultImageListener( ResultImageListener* listener )
Expand Down Expand Up @@ -130,15 +128,12 @@ public:
}
}

/** The channel's drawable config (FBO). */
/** The channel's drawable config. */
DrawableConfig drawableConfig;

/** The configInit/configExit state. */
State state;

/** Used as an alternate drawable. */
util::FrameBufferObject* fbo;

/** A random, unique color for this channel. */
Vector3ub color;

Expand Down
25 changes: 0 additions & 25 deletions eq/fabric/channel.h
Expand Up @@ -36,20 +36,6 @@ template< class W, class C > class Channel : public Object
typedef LeafVisitor< C > Visitor; //!< The channel visitor type
typedef W Parent; //!< The parent window type

/**
* The drawable format defines the components used as an alternate drawable
* for this channel. If an alternate drawable is configured, the channel
* uses the appropriate targets in place of the window's frame buffer.
* @version 1.0
*/
enum Drawable
{
FB_WINDOW = LB_BIT_NONE, //!< Use the window's frame buffer
FBO_COLOR = LB_BIT1, //!< Use an FBO for color values
FBO_DEPTH = LB_BIT2, //!< Use an FBO for depth values
FBO_STENCIL = LB_BIT3 //!< Use an FBO for stencil values
};

/** @name Data Access */
//@{
/** @internal Initialize this channel (calls virtual methods) */
Expand Down Expand Up @@ -101,12 +87,6 @@ template< class W, class C > class Channel : public Object
*/
EQFABRIC_INL void setNearFar( const float nearPlane, const float farPlane );

/**
* @return the channel's framebuffer attachment configuration.
* @version 1.0
*/
uint32_t getDrawable() const { return _drawable; }

/**
* Perform a depth-first traversal of this channel.
*
Expand Down Expand Up @@ -361,8 +341,6 @@ template< class W, class C > class Channel : public Object
/** @internal @sa Serializable::setDirty() */
EQFABRIC_INL virtual void setDirty( const uint64_t bits );

void setDrawable( const uint32_t drawable ); //!< @internal

/** @name Render context access */
//@{
/** @internal Override the channel's native render context. */
Expand Down Expand Up @@ -436,9 +414,6 @@ template< class W, class C > class Channel : public Object
/** String attributes. */
std::string _sAttributes[SATTR_ALL];

/** An alternate drawable config. */
uint32_t _drawable;

/** Overdraw limiter */
Vector2i _maxSize;

Expand Down
37 changes: 2 additions & 35 deletions eq/fabric/channel.ipp
Expand Up @@ -47,7 +47,6 @@ template< class W, class C >
Channel< W, C >::Channel( W* parent )
: _window( parent )
, _context( &_data.nativeContext )
, _drawable( FB_WINDOW )
, _maxSize( Vector2i::ZERO )
{
memset( _iAttributes, 0xff, IATTR_ALL * sizeof( int32_t ));
Expand All @@ -61,7 +60,6 @@ Channel< W, C >::Channel( const Channel& from )
, _window( from._window )
, _data( from._data )
, _context( &_data.nativeContext )
, _drawable( from._drawable )
, _maxSize( from._maxSize )
{
_window->_addChannel( static_cast< C* >( this ));
Expand Down Expand Up @@ -127,8 +125,7 @@ void Channel< W, C >::serialize( co::DataOStream& os, const uint64_t dirtyBits )
os << _data.nativeContext.vp << _data.nativeContext.pvp
<< _data.fixedVP << _maxSize;
if( dirtyBits & DIRTY_MEMBER )
os << _drawable << _data.nativeContext.view
<< _data.nativeContext.overdraw;
os << _data.nativeContext.view << _data.nativeContext.overdraw;
if( dirtyBits & DIRTY_FRUSTUM )
os << _data.nativeContext.frustum;
if( dirtyBits & DIRTY_CAPABILITIES )
Expand Down Expand Up @@ -158,8 +155,7 @@ void Channel< W, C >::deserialize( co::DataIStream& is,
sizeof( _data.fixedVP ) +sizeof( _maxSize ));
}
if( dirtyBits & DIRTY_MEMBER )
is >> _drawable >> _data.nativeContext.view
>> _data.nativeContext.overdraw;
is >> _data.nativeContext.view >> _data.nativeContext.overdraw;
if( dirtyBits & DIRTY_FRUSTUM )
is >> _data.nativeContext.frustum;
if( dirtyBits & DIRTY_CAPABILITIES )
Expand Down Expand Up @@ -276,13 +272,6 @@ void Channel< W, C >::setNearFar( const float nearPlane, const float farPlane )
}
}

template< class W, class C >
void Channel< W, C >::setDrawable( const uint32_t drawable )
{
_drawable = drawable;
setDirty( DIRTY_MEMBER );
}

template< class W, class C >
void Channel< W, C >::setViewVersion( const co::ObjectVersion& view )
{
Expand Down Expand Up @@ -400,28 +389,6 @@ std::ostream& operator << ( std::ostream& os,
os << "viewport " << pvp << std::endl;
}


const uint32_t drawable = channel.getDrawable();
if( drawable != C::FB_WINDOW )
{
os << "drawable [";

if ((drawable & C::FBO_COLOR) != 0 )
{
os << " FBO_COLOR";
}

if ((drawable & C::FBO_DEPTH) != 0)
{
os << " FBO_DEPTH";
}
if ((drawable & C::FBO_STENCIL) != 0)
{
os << " FBO_STENCIL";
}

os << " ]" << std::endl;
}
os << lunchbox::exdent << "}" << std::endl << lunchbox::enableHeader
<< lunchbox::enableFlush;

Expand Down
2 changes: 0 additions & 2 deletions eq/server/channel.h
Expand Up @@ -136,8 +136,6 @@ class Channel : public fabric::Channel< Window, Channel >
{ fabric::Channel< Window, Channel >::setIAttribute( attr, value );}
void setSAttribute( const SAttribute attr, const std::string& value )
{ fabric::Channel< Window, Channel >::setSAttribute( attr, value );}
void setDrawable( const uint32_t drawable )
{ fabric::Channel< Window, Channel >::setDrawable( drawable ); }
//@}

/**
Expand Down

0 comments on commit 3980118

Please sign in to comment.