Пример #1
0
void Window::_setupObjectManager()
{
    if( !glewGetContext( ))
        return;

    _releaseObjectManager();

    Window*    sharedWindow = getSharedContextWindow();
    ObjectManager* sharedOM = sharedWindow ? sharedWindow->getObjectManager():0;

    if( sharedOM )
        _objectManager = new ObjectManager( sharedOM );
    else
        _objectManager = new ObjectManager( glewGetContext( ));
}
Пример #2
0
void Window::_setupObjectManager()
{
    if( !glewGetContext( ))
        return;

    _releaseObjectManager();

    const Window* sharedWindow = getSharedContextWindow();
    if( sharedWindow && sharedWindow != this )
        _objectManager = sharedWindow->_objectManager;
    else
    {
        util::ObjectManager om( glewGetContext( ));
        _objectManager = om;
    }
}
Пример #3
0
		~texture_internal()
		{
			if(id && glewGetContext())
			{
				glDeleteTextures(1, &id);
			}
		}
Пример #4
0
ObjectManager& ObjectManager::operator = ( const ObjectManager& rhs )
{
    if( this != &rhs )
        _impl = rhs._impl;
    LBASSERT( glewGetContext( ));
    return *this;
}
Пример #5
0
		~renderbuffer_internal()
		{
			if(id && glewGetContext())
			{
				glDeleteRenderbuffers(1, &id);
			}
		}
Пример #6
0
/**
 *  Function for creating and holding of shared context.
 *  Generation and uploading of new textures over some period with sleep time.
 */
void AsyncFetcher::run()
{
    EQASSERT( !_sharedContextWindow );
    _sharedContextWindow = initSharedContextWindow( _wnd );
    _outQueue.push( TextureId( )); // unlock pipe thread
    if( !_sharedContextWindow )
        return;

    _objectManager = new ObjectManager( glewGetContext( ));
    EQINFO << "async fetcher initialized: " << _wnd << std::endl;

    int i = 0;
    bool running = true;
    co::base::sleep( 1000 ); // imitate loading of the first texture
    while( running )
    {
        // generate new texture
        eq::util::Texture* tx = _objectManager->newEqTexture( ++i,
                                                              GL_TEXTURE_2D );
        tx->init( GL_RGBA8, 64, 64 );

        int j = 0;
        co::base::RNG rng;
        for( int y = 0; y < 64; ++y )
        {
            for( int x = 0; x < 64; ++x )
            {
                const GLbyte rnd = rng.get< uint8_t >() % 127;
                const GLbyte val = (x / 8) % 2 == (y / 8) % 2 ? rnd : 0;
                _tmpTexture[ j++ ] = val;
                _tmpTexture[ j++ ] = val;
                _tmpTexture[ j++ ] = val;
                _tmpTexture[ j++ ] = val;
            }
        }
        tx->upload( 64, 64, _tmpTexture );
        EQ_GL_CALL( glFinish( ));

        // add new texture to the pool
        _outQueue.push( TextureId( tx->getName( ), i ));

        // imitate hard work of loading something else
        co::base::sleep( rng.get< uint32_t >() % 5000u );

        // clean unused textures
        int keyToDelete = 0;
        while( _inQueue.tryPop( keyToDelete ))
        {
            if( keyToDelete )
            {
                EQWARN << "Deleting eq texture " << keyToDelete << std::endl;
                _objectManager->deleteEqTexture( keyToDelete );
            }
            else
                running = false;
        }
    }
    deleteSharedContextWindow( _wnd, &_sharedContextWindow, &_objectManager );
}
Пример #7
0
/**
 *  Function for creating and holding of shared context.
 *  Generation and uploading of new textures over some period with sleep time.
 */
void AsyncFetcher::run()
{
    LBASSERT( _sharedWindow );
    if( !_sharedWindow )
        return;

    _sharedWindow->makeCurrent();
    eq::util::ObjectManager objects( glewGetContext( ));
    lunchbox::Bufferb textureData( 64*64*4 );
    LBINFO << "async fetcher initialized" << std::endl;

    bool running = true;
    lunchbox::sleep( 1000 ); // imitate loading of the first texture
    for( uint8_t* i = 0; running; ++i )
    {
        // generate new texture
        eq::util::Texture* tx = objects.newEqTexture( i, GL_TEXTURE_2D );
        tx->init( GL_RGBA8, 64, 64 );

        int j = 0;
        lunchbox::RNG rng;
        for( int y = 0; y < 64; ++y )
        {
            for( int x = 0; x < 64; ++x )
            {
                const GLbyte rnd = rng.get< uint8_t >() % 127;
                const GLbyte val = (x / 8) % 2 == (y / 8) % 2 ? rnd : 0;
                textureData[ j++ ] = val;
                textureData[ j++ ] = val;
                textureData[ j++ ] = val;
                textureData[ j++ ] = val;
            }
        }
        tx->upload( 64, 64, textureData.getData( ));
        EQ_GL_CALL( glFinish( ));

        // add new texture to the pool
        _outQueue.push( TextureId( tx->getName(), i ));

        // imitate hard work of loading something else
        lunchbox::sleep( rng.get< uint32_t >() % 5000u );

        // clean unused textures
        const void* keyToDelete = 0;
        while( _inQueue.tryPop( keyToDelete ))
        {
            if( keyToDelete )
            {
                LBWARN << "Deleting eq texture " << keyToDelete << std::endl;
                objects.deleteEqTexture( keyToDelete );
            }
            else
                running = false;
        }
    }
    objects.deleteAll();
}
Пример #8
0
	version_check()
	{
		if(!glewGetContext())
		{
			k3d::log() << warning << "No context defined to determine Mesa version" << std::endl;
			return;
		}
	
		const k3d::string_t version(reinterpret_cast<const char*>(glGetString(GL_VERSION)));
		const k3d::string_t vendor(reinterpret_cast<const char*>(glGetString(GL_VENDOR)));
		k3d::log() << info << "OpenGL version: " << version << ", vendor: " << vendor << std::endl;

		try
		{
			if(vendor == "Tungsten Graphics, Inc" || vendor == "Mesa Project")
			{
				std::vector<k3d::string_t> tokens;
				boost::split(tokens, version, boost::is_any_of(" "));
				if(tokens.size() > 2 && tokens[1] == "Mesa")
				{
					const k3d::string_t version_number = tokens[2];
					std::vector<k3d::string_t> bad_tokens; // Strip off any trailing '-devel' and so on
					boost::split(bad_tokens, version_number, boost::is_any_of("-"));
					std::vector<k3d::string_t> version_tokens;
					boost::split(version_tokens, bad_tokens[0], boost::is_any_of("."));
					if(version_tokens.size() > 1)
					{
						const k3d::uint_t min_major = 7; // minimal major version
						const k3d::uint_t min_minor = 5; // minimal minor version
						const k3d::uint_t min_patch = 1; // minimal patch version
						const k3d::uint_t major = boost::lexical_cast<k3d::uint_t>(version_tokens[0]);
						const k3d::uint_t minor = boost::lexical_cast<k3d::uint_t>(version_tokens[1]);
						if(major < min_major || (major == min_major && minor < min_minor) || (major == min_major && minor == min_minor && (version_tokens.size() == 2 || boost::lexical_cast<k3d::uint_t>(version_tokens[2]) < min_patch)))
						{
							k3d::user_interface().nag_message(
								"MesaVersionCheck/1",
								k3d::ustring::from_utf8(k3d::string_cast(boost::format(_("Your OpenGL version is %1%.")) % version)),
								k3d::ustring::from_utf8(_("On your platform, Mesa versions earlier than 7.5.1 are known to cause problems with face selection. If you experience this, please upgrade your Mesa library. See http://bugs.freedesktop.org/show_bug.cgi?id=16866 for detailed information.")));
						}
					}
				}
			}
		}
		catch(std::runtime_error& E)
		{
			k3d::log() << warning << "error parsing mesa version: " << E.what() << std::endl;
		}
	}
Пример #9
0
bool AccumBufferObject::init( const PixelViewport& pvp,
                              const GLuint textureFormat )
{
    _pvp = pvp;
    _texture = new Texture( GL_TEXTURE_RECTANGLE_ARB, glewGetContext( ));
    _texture->init( textureFormat, pvp.w, pvp.h );

    const Error error = FrameBufferObject::init( pvp.w, pvp.h,
                                                 GL_RGBA32F, 0, 0 );
    if( error )
    {
        exit();
        return false;
    }

    unbind();
    return true;
}
Пример #10
0
bool Window::configInitGL( const eq::uint128_t& )
{
    Pipe*     pipe     = static_cast<Pipe*>( getPipe() );
    Renderer* renderer = pipe->getRenderer();

    if( !renderer )
        return false;

    if( !GLEW_ARB_shader_objects )
    {
        sendError( ERROR_EVOLVE_ARB_SHADER_OBJECTS_MISSING );
        return false;
    }
    if( !GLEW_EXT_blend_func_separate )
    {
        sendError( ERROR_EVOLVE_EXT_BLEND_FUNC_SEPARATE_MISSING );
        return false;
    }
    if( !GLEW_ARB_multitexture )
    {
        sendError( ERROR_EVOLVE_ARB_MULTITEXTURE_MISSING );
        return false;
    }

    glEnable( GL_SCISSOR_TEST ); // needed to constrain channel viewport

    glClear( GL_COLOR_BUFFER_BIT );
    swapBuffers();
    glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );

    renderer->glewSetContext( glewGetContext( ));

    if( !renderer->loadShaders( ))
    {
        sendError( ERROR_EVOLVE_LOADSHADERS_FAILED );
        return false;
    }

    _loadLogo();
    return true;
}
Пример #11
0
    Impl( const uint32_t samplesPerRay,
          const uint32_t samplesPerPixel,
          const VolumeInformation& volInfo )
        : _framebufferTexture( GL_TEXTURE_RECTANGLE_ARB, glewGetContext( ))
        , _nSamplesPerRay( samplesPerRay )
        , _nSamplesPerPixel( samplesPerPixel )
        , _computedSamplesPerRay( samplesPerRay )
        , _volInfo( volInfo )
        , _transferFunctionTexture( 0 )
    {
        TransferFunction1D transferFunction;
        initTransferFunction( transferFunction );

        // TODO: Add the shaders from resource directory
        const int error = _shaders.loadShaders( ShaderData( vertRayCast_glsl,
                                                             fragRayCast_glsl ));
        if( error != GL_NO_ERROR )
            LBTHROW( std::runtime_error( "Can't load glsl shaders: " +
                                         eq::glError( error ) +
                                         where( __FILE__, __LINE__ )));
    }
Пример #12
0
//\brief
//	initialize the gl extension functions address.
static bool InitializeGlew()
{
	GLenum err;
	GLContext ctx;

	/* create OpenGL rendering context */
	InitContext(&ctx);
	if (GL_TRUE == CreateContext(&ctx))
	{
		std::cout << "Error: CreateContext failed" << std::endl;
		DestroyContext(&ctx);
		return false;
	}

	/* initialize GLEW */
	glewExperimental = GL_TRUE;
#ifdef GLEW_MX
	err = glewContextInit(glewGetContext());
#  ifdef _WIN32
	err = err || wglewContextInit(wglewGetContext());
#  elif !defined(__APPLE__) && !defined(__HAIKU__) || defined(GLEW_APPLE_GLX)
	err = err || glxewContextInit(glxewGetContext());
#  endif
#else
	err = glewInit();
#endif
	if (GLEW_OK != err)
	{
		std::cout << "Error [main]: glewInit failed: " << glewGetErrorString(err) << std::endl;
		DestroyContext(&ctx);
		return false;
	}

	DestroyContext(&ctx);
	return true;
}
Пример #13
0
int main (int argc, char** argv)
{
  GLuint err;
  struct createParams params = 
  {
#if defined(__OSMESA__)
    -1,  /* bit depth */
#elif defined(_WIN32)
    -1,  /* pixelformat */
#elif !defined(__HAIKU__) && !defined(__APPLE__) || defined(GLEW_APPLE_GLX)
    "",  /* display */
    -1,  /* visual */
#endif
    0,   /* major */
    0,   /* minor */
    0,   /* profile mask */
    0    /* flags */
  };

  if (glewParseArgs(argc-1, argv+1, &params))
  {
    fprintf(stderr, "Usage: glewinfo "
#if defined(__OSMESA__)
#elif defined(_WIN32)
	    "[-pf <pixelformat>] "
#elif !defined(__HAIKU__) && !defined(__APPLE__) || defined(GLEW_APPLE_GLX)
	    "[-display <display>] "
	    "[-visual <visual id>] "
#endif
	    "[-version <OpenGL version>] "
	    "[-profile core|compatibility] "
	    "[-flag debug|forward]"
	    "\n");
    return 1;
  }

  if (GL_TRUE == glewCreateContext(&params))
  {
    fprintf(stderr, "Error: glewCreateContext failed\n");
    glewDestroyContext();
    return 1;
  }
  glewExperimental = GL_TRUE;
#ifdef GLEW_MX
  err = glewContextInit(glewGetContext());
#if defined(__OSMESA__)
  err = err || osmewContextInit(osmewGetContext());
#elif defined(_WIN32)
  err = err || wglewContextInit(wglewGetContext());
#elif !defined(__HAIKU__) && !defined(__APPLE__) || defined(GLEW_APPLE_GLX)
  err = err || glxewContextInit(glxewGetContext());
#endif

#else
  err = glewInit();
#endif
  if (GLEW_OK != err)
  {
    fprintf(stderr, "Error [main]: glewInit failed: %s\n", glewGetErrorString(err));
    glewDestroyContext();
    return 1;
  }
#if defined(_WIN32)
#if defined(_MSC_VER) && (_MSC_VER >= 1400)
  if (fopen_s(&f, "glewinfo.txt", "w") != 0)
    f = stdout;
#else
  f = fopen("glewinfo.txt", "w");
#endif /* _MSC_VER */
  if (f == NULL) f = stdout;
#else
  f = stdout;
#endif /* _WIN32 */
  fprintf(f, "---------------------------\n");
  fprintf(f, "    GLEW Extension Info\n");
  fprintf(f, "---------------------------\n\n");
  fprintf(f, "GLEW version %s\n", glewGetString(GLEW_VERSION));
#if defined(__OSMESA__)
  fprintf(f, "Reporting capabilitiees of OSMesa\n");
#elif defined(_WIN32)
  fprintf(f, "Reporting capabilities of pixelformat %d\n", params.pixelformat);
#elif !defined(__APPLE__) || defined(GLEW_APPLE_GLX)
  fprintf(f, "Reporting capabilities of display %s, visual 0x%x\n", 
    params.display == NULL ? getenv("DISPLAY") : params.display, params.visual);
#endif /* __OSMESA__ */
  fprintf(f, "Running on a %s from %s\n", 
	  glGetString(GL_RENDERER), glGetString(GL_VENDOR));
  fprintf(f, "OpenGL version %s is supported\n", glGetString(GL_VERSION));
  glewInfo();
#if defined(__OSMESA__)
  osmewInfo();
#elif defined(_WIN32)
  wglewInfo();
#else
  glxewInfo();
#endif /* __OSMESA__ */
  if (f != stdout) fclose(f);
  glewDestroyContext();
  return 0;
}
Пример #14
0
int
main (int argc, char** argv)
{
  GLenum err;
  GLContext ctx;

  /* ---------------------------------------------------------------------- */
  /* parse arguments */
  if (GL_TRUE == ParseArgs(argc-1, argv+1))
  {
#if defined(_WIN32)
    fprintf(stderr, "Usage: visualinfo [-a] [-s] [-h] [-pf <id>]\n");
    fprintf(stderr, "        -a: show all visuals\n");
    fprintf(stderr, "        -s: display to stdout instead of visualinfo.txt\n");
    fprintf(stderr, "        -pf <id>: use given pixelformat\n");
    fprintf(stderr, "        -h: this screen\n");
#else
    fprintf(stderr, "Usage: visualinfo [-h] [-display <display>] [-visual <id>]\n");
    fprintf(stderr, "        -h: this screen\n");
    fprintf(stderr, "        -display <display>: use given display\n");
    fprintf(stderr, "        -visual <id>: use given visual\n");
#endif
    return 1;
  }

  /* ---------------------------------------------------------------------- */
  /* create OpenGL rendering context */
  InitContext(&ctx);
  if (GL_TRUE == CreateContext(&ctx))
  {
    fprintf(stderr, "Error: CreateContext failed\n");
    DestroyContext(&ctx);
    return 1;
  }

  /* ---------------------------------------------------------------------- */
  /* initialize GLEW */
  glewExperimental = GL_TRUE;
#ifdef GLEW_MX
  err = glewContextInit(glewGetContext());
#  ifdef _WIN32
  err = err || wglewContextInit(wglewGetContext());
#  elif !defined(__APPLE__) || defined(GLEW_APPLE_GLX)
  err = err || glxewContextInit(glxewGetContext());
#  endif
#else
  err = glewInit();
#endif
  if (GLEW_OK != err)
  {
    fprintf(stderr, "Error [main]: glewInit failed: %s\n", glewGetErrorString(err));
    DestroyContext(&ctx);
    return 1;
  }

  /* ---------------------------------------------------------------------- */
  /* open file */
#if defined(_WIN32)
  if (!displaystdout)
    file = fopen("visualinfo.txt", "w");
  if (file == NULL)
    file = stdout;
#else
  file = stdout;
#endif

  /* ---------------------------------------------------------------------- */
  /* output header information */
  /* OpenGL extensions */
  fprintf(file, "OpenGL vendor string: %s\n", glGetString(GL_VENDOR));
  fprintf(file, "OpenGL renderer string: %s\n", glGetString(GL_RENDERER));
  fprintf(file, "OpenGL version string: %s\n", glGetString(GL_VERSION));
  fprintf(file, "OpenGL extensions (GL_): \n");
  PrintExtensions((char*)glGetString(GL_EXTENSIONS));
  /* GLU extensions */
  fprintf(file, "GLU version string: %s\n", gluGetString(GLU_VERSION));
  fprintf(file, "GLU extensions (GLU_): \n");
  PrintExtensions((char*)gluGetString(GLU_EXTENSIONS));

  /* ---------------------------------------------------------------------- */
  /* extensions string */
#if defined(_WIN32)
  /* WGL extensions */
  if (WGLEW_ARB_extensions_string || WGLEW_EXT_extensions_string)
  {
    fprintf(file, "WGL extensions (WGL_): \n");
    PrintExtensions(wglGetExtensionsStringARB ?
                    (char*)wglGetExtensionsStringARB(ctx.dc) :
            (char*)wglGetExtensionsStringEXT());
  }
#elif defined(__APPLE__) && !defined(GLEW_APPLE_GLX)

#else
  /* GLX extensions */
  fprintf(file, "GLX extensions (GLX_): \n");
  PrintExtensions(glXQueryExtensionsString(glXGetCurrentDisplay(),
                                           DefaultScreen(glXGetCurrentDisplay())));
#endif

  /* ---------------------------------------------------------------------- */
  /* enumerate all the formats */
  VisualInfo(&ctx);

  /* ---------------------------------------------------------------------- */
  /* release resources */
  DestroyContext(&ctx);
  if (file != stdout)
    fclose(file);
  return 0;
}
Пример #15
0
void Channel::_testDepthAssemble()
{
    glGetError(); // reset

    //----- setup constant data
    const eq::Images& images = _frame.getImages();
    eq::Image* image  = images[ 0 ];
    LBASSERT( image );

    const eq::PixelViewport& pvp    = getPixelViewport();
    const eq::Vector2i offset( pvp.x, pvp.y );

    eq::Vector2i area;
    area.x() = pvp.w;

    lunchbox::Clock clock;
    eq::util::ObjectManager& glObjects = getObjectManager();
    const GLEWContext* glewContext = glewGetContext();

    //----- test depth-based assembly algorithms
    for( unsigned i = 0; i < NUM_IMAGES; ++i )
    {
        image = images[ i ];
        LBASSERT( image );
        image->setPixelViewport( pvp );
    }

    area.y() = pvp.h;

    for( uint64_t i = 0; i < NUM_IMAGES; ++i )
    {
        _draw( co::uint128_t( i ) );

        // fill depth & color image
        image = images[ i ];

        LBCHECK( image->allocDownloader( eq::Frame::BUFFER_COLOR,
                                         EQ_COMPRESSOR_TRANSFER_RGBA_TO_BGRA,
                                         glewContext ));

        LBCHECK( image->allocDownloader( eq::Frame::BUFFER_DEPTH,
                             EQ_COMPRESSOR_TRANSFER_DEPTH_TO_DEPTH_UNSIGNED_INT,
                                         glewContext ));

        image->clearPixelData( eq::Frame::BUFFER_COLOR );
        image->clearPixelData( eq::Frame::BUFFER_DEPTH );

        image->startReadback( eq::Frame::BUFFER_COLOR | eq::Frame::BUFFER_DEPTH,
                              pvp, eq::Zoom::NONE, glObjects );
        image->finishReadback( glObjects.glewGetContext( ));
        LBASSERT( image->hasPixelData( eq::Frame::BUFFER_COLOR ));
        LBASSERT( image->hasPixelData( eq::Frame::BUFFER_DEPTH ));

        if( i == NUM_IMAGES-1 )
            _saveImage( image,"EQ_COMPRESSOR_DATATYPE_DEPTH_UNSIGNED_INT",
                              "depthAssemble" );

        // benchmark
        eq::Compositor::ImageOp op;
        op.channel = this;
        op.buffers = eq::Frame::BUFFER_COLOR | eq::Frame::BUFFER_DEPTH;
        op.offset  = offset;

        // fixed-function
        std::stringstream formatType;
        formatType << "depth, GL1.1, " << i+1 << " images";

        clock.reset();
        for( unsigned j = 0; j <= i; ++j )
            eq::Compositor::assembleImageDB_FF( images[j], op );

        float msec = clock.getTimef();
        _sendEvent( ASSEMBLE, msec, area, formatType.str(), 0, 0 );

        // GLSL
        if( GLEW_VERSION_2_0 )
        {
            formatType.str("");
            formatType << "depth, GLSL,  " << i+1 << " images";

            clock.reset();
            for( unsigned j = 0; j <= i; ++j )
                eq::Compositor::assembleImageDB_GLSL( images[j], op );
            msec = clock.getTimef();
            _sendEvent( ASSEMBLE, msec, area, formatType.str(), 0, 0 );
        }

        // CPU
        formatType.str("");
        formatType << "depth, CPU,   " << i+1 << " images";

        std::vector< eq::Frame* > frames;
        frames.push_back( &_frame );

        clock.reset();
        eq::Compositor::assembleFramesCPU( frames, this );
        msec = clock.getTimef();
        _sendEvent( ASSEMBLE, msec, area, formatType.str(), 0, 0 );
    }
}
Пример #16
0
void Channel::_testDepthAssemble()
{
    //----- setup constant data
    const eq::Images& images = _frame.getImages();
    eq::Image* image  = images[ 0 ];
    LBASSERT( image );

    eq::Config* config = getConfig();
    const eq::PixelViewport& pvp    = getPixelViewport();
    const eq::Vector2i offset( pvp.x, pvp.y );

    ConfigEvent event = _createConfigEvent();
    event.area.x() = pvp.w;

    lunchbox::Clock clock;
    eq::Window::ObjectManager* glObjects = getObjectManager();
    const GLEWContext* glewContext = glewGetContext();

    //----- test depth-based assembly algorithms
    for( unsigned i = 0; i < NUM_IMAGES; ++i )
    {
        image = images[ i ];
        LBASSERT( image );
        image->setPixelViewport( pvp );
    }

    event.area.y() = pvp.h;

    for( unsigned i = 0; i < NUM_IMAGES; ++i )
    {
        _draw( i );

        // fill depth & color image
        image = images[ i ];

        LBCHECK( image->allocDownloader( eq::Frame::BUFFER_COLOR, 
                                         EQ_COMPRESSOR_TRANSFER_RGBA_TO_BGRA, 
                                         glewContext ));

        LBCHECK( image->allocDownloader( eq::Frame::BUFFER_DEPTH, 
                             EQ_COMPRESSOR_TRANSFER_DEPTH_TO_DEPTH_UNSIGNED_INT,
                                         glewContext ));

        image->clearPixelData( eq::Frame::BUFFER_COLOR );
        image->clearPixelData( eq::Frame::BUFFER_DEPTH );

        image->startReadback( eq::Frame::BUFFER_COLOR | eq::Frame::BUFFER_DEPTH,
                              pvp, eq::Zoom::NONE, glObjects );
        image->finishReadback( eq::Zoom::NONE, glObjects->glewGetContext( ));

        if( i == NUM_IMAGES-1 )
            _saveImage( image,"EQ_COMPRESSOR_DATATYPE_DEPTH_UNSIGNED_INT",
                              "depthAssemble" );

        // benchmark
        eq::Compositor::ImageOp op;
        op.channel = this;
        op.buffers = eq::Frame::BUFFER_COLOR | eq::Frame::BUFFER_DEPTH;
        op.offset  = offset;

        // fixed-function
        event.data.type = ConfigEvent::ASSEMBLE;
        snprintf( event.formatType, 32, "depth, GL1.1, %d images", i+1 ); 

        clock.reset();
        for( unsigned j = 0; j <= i; ++j )
            eq::Compositor::assembleImageDB_FF( images[j], op );

        event.msec = clock.getTimef();
        config->sendEvent( event );

        // GLSL
        if( GLEW_VERSION_2_0 )
        {
            snprintf( event.formatType, 32, "depth, GLSL,  %d images", i+1 ); 

            clock.reset();
            for( unsigned j = 0; j <= i; ++j )
                eq::Compositor::assembleImageDB_GLSL( images[j], op );
            event.msec = clock.getTimef();
            config->sendEvent( event );
        }

        // CPU
        snprintf( event.formatType, 32, "depth, CPU,   %d images", i+1 ); 

        std::vector< eq::Frame* > frames;
        frames.push_back( &_frame );

        clock.reset();
        eq::Compositor::assembleFramesCPU( frames, this );
        event.msec = clock.getTimef();
        config->sendEvent( event );
    }
}
Пример #17
0
void Channel::_testFormats( float applyZoom )
{
    //----- setup constant data
    const eq::Images& images = _frame.getImages();
    eq::Image*        image  = images[ 0 ];
    LBASSERT( image );

    Config* config = static_cast< Config* >( getConfig( ));
    const eq::PixelViewport& pvp = getPixelViewport();
    const eq::Vector2i offset( pvp.x, pvp.y );
    const eq::Zoom zoom( applyZoom, applyZoom );

    lunchbox::Clock clock;
    eq::Window::ObjectManager* glObjects = getObjectManager();

    //----- test all default format/type combinations
    ConfigEvent event = _createConfigEvent();
    glGetError();
    for( uint32_t i=0; _enums[i].internalFormatString; ++i )
    {
        const uint32_t internalFormat = _enums[i].internalFormat;
        image->flush();
        image->setInternalFormat( eq::Frame::BUFFER_COLOR, internalFormat );
        image->setQuality( eq::Frame::BUFFER_COLOR, 0.f );
        image->setAlphaUsage( false );

        const GLEWContext* glewContext = glewGetContext();
        std::vector< uint32_t > names;
        image->findTransferers( eq::Frame::BUFFER_COLOR, glewContext, names );

        for( std::vector< uint32_t >::const_iterator j = names.begin();
             j != names.end(); ++j )
        {
            _draw( 0 );

            // setup
            event.formatType[31] = '\0';
            event.data.type = ConfigEvent::READBACK;

            image->allocDownloader( eq::Frame::BUFFER_COLOR, *j, glewContext );
            image->setPixelViewport( pvp );

            const uint32_t outputToken = 
                image->getExternalFormat( eq::Frame::BUFFER_COLOR );
            snprintf( event.formatType, 32, "%s/%x/%x", 
                _enums[i].internalFormatString, outputToken, *j );


            // read
            glFinish();
            size_t nLoops = 0;
            clock.reset();
            while( clock.getTime64() < 100 /*ms*/ )
            {
                image->startReadback( eq::Frame::BUFFER_COLOR, pvp, zoom,
                                      glObjects );
                image->finishReadback( zoom, glObjects->glewGetContext( ));
                ++nLoops;
            }
            glFinish();
            event.msec = clock.getTimef() / float( nLoops );

            const eq::PixelData& pixels =
                image->getPixelData( eq::Frame::BUFFER_COLOR );
            event.area.x() = pixels.pvp.w;             
            event.area.y() = pixels.pvp.h;
            event.dataSizeGPU = pixels.pvp.getArea() * _enums[i].pixelSize;
            event.dataSizeCPU = 
            image->getPixelDataSize( eq::Frame::BUFFER_COLOR );

            GLenum error = glGetError();
            if( error != GL_NO_ERROR )
                event.msec = -static_cast<float>( error );
            config->sendEvent( event );

            // write
            eq::Compositor::ImageOp op;
            op.channel = this;
            op.buffers = eq::Frame::BUFFER_COLOR;
            op.offset = offset;
            op.zoom = zoom;

            event.data.type = ConfigEvent::ASSEMBLE;
            event.dataSizeCPU = 
                image->getPixelDataSize( eq::Frame::BUFFER_COLOR );

            clock.reset();
            eq::Compositor::assembleImage( image, op );
            event.msec = clock.getTimef();

            const eq::PixelData& pixelA =
                image->getPixelData( eq::Frame::BUFFER_COLOR );
            event.area.x() = pixelA.pvp.w; 
            event.area.y() = pixelA.pvp.h;
            event.dataSizeGPU =
                image->getPixelDataSize( eq::Frame::BUFFER_COLOR );

            error = glGetError();
            
            if( error != GL_NO_ERROR )
                event.msec = -static_cast<float>( error );
            config->sendEvent( event );
        }
    }
}
Пример #18
0
void Channel::_testFormats( float applyZoom )
{
    glGetError(); // reset

    //----- setup constant data
    const eq::Images& images = _frame.getImages();
    eq::Image*        image  = images[ 0 ];
    LBASSERT( image );

    const eq::PixelViewport& pvp = getPixelViewport();
    const eq::Vector2i offset( pvp.x, pvp.y );
    const eq::Zoom zoom( applyZoom, applyZoom );

    lunchbox::Clock clock;
    eq::util::ObjectManager& glObjects = getObjectManager();

    //----- test all default format/type combinations
    for( uint32_t i=0; _enums[i].internalFormatString; ++i )
    {
        const uint32_t internalFormat = _enums[i].internalFormat;
        image->flush();
        image->setInternalFormat( eq::Frame::BUFFER_COLOR, internalFormat );
        image->setQuality( eq::Frame::BUFFER_COLOR, 0.f );
        image->setAlphaUsage( false );

        const GLEWContext* glewContext = glewGetContext();
        const std::vector< uint32_t >& names =
            image->findTransferers( eq::Frame::BUFFER_COLOR, glewContext );

        for( std::vector< uint32_t >::const_iterator j = names.begin();
             j != names.end(); ++j )
        {
            _draw( co::uint128_t( ));

            image->allocDownloader( eq::Frame::BUFFER_COLOR, *j, glewContext );
            image->setPixelViewport( pvp );

            const uint32_t outputToken =
                image->getExternalFormat( eq::Frame::BUFFER_COLOR );
            std::stringstream formatType;
            formatType << std::hex << *j << ':'
                       << _enums[i].internalFormatString << '/' << outputToken
                       << std::dec;
            // read
            glFinish();
            size_t nLoops = 0;
            try
            {
                clock.reset();
                while( clock.getTime64() < 100 /*ms*/ )
                {
                    image->startReadback( eq::Frame::BUFFER_COLOR, pvp, zoom,
                                          glObjects );
                    image->finishReadback( glObjects.glewGetContext( ));
                    ++nLoops;
                }
                glFinish();
                const float msec = clock.getTimef() / float( nLoops );
                const GLenum error = glGetError(); // release mode
                if( error != GL_NO_ERROR )
                    throw eq::GLException( error );

                const eq::PixelData& pixels =
                    image->getPixelData( eq::Frame::BUFFER_COLOR );
                const eq::Vector2i area( pixels.pvp.w, pixels.pvp.h );
                const uint64_t dataSizeGPU = area.x() * area.y() *
                                             _enums[i].pixelSize;
                const uint64_t dataSizeCPU =
                    image->getPixelDataSize( eq::Frame::BUFFER_COLOR );

                _sendEvent( READBACK, msec, area, formatType.str(), dataSizeGPU,
                            dataSizeCPU );
            }
            catch( const eq::GLException& e )
            {
                _sendEvent( READBACK, -static_cast<float>( e.glError ),
                            eq::Vector2i(), formatType.str(), 0, 0 );
                continue;
            }

            // write
            eq::Compositor::ImageOp op;
            op.channel = this;
            op.buffers = eq::Frame::BUFFER_COLOR;
            op.offset = offset;
            op.zoom = zoom;

            const uint64_t dataSizeCPU =
                image->getPixelDataSize( eq::Frame::BUFFER_COLOR );
            try
            {
                clock.reset();
                eq::Compositor::assembleImage( image, op );
                glFinish();
                const float msec = clock.getTimef() / float( nLoops );
                const GLenum error = glGetError(); // release mode
                if( error != GL_NO_ERROR )
                    throw eq::Exception( error );

                const eq::PixelData& pixels =
                    image->getPixelData( eq::Frame::BUFFER_COLOR );
                const eq::Vector2i area( pixels.pvp.w, pixels.pvp.h );
                const uint64_t dataSizeGPU =
                    image->getPixelDataSize( eq::Frame::BUFFER_COLOR );
                _sendEvent( ASSEMBLE, msec, area, formatType.str(), dataSizeGPU,
                            dataSizeCPU );
            }
            catch( const eq::GLException& e ) // debug mode
            {
                _sendEvent( ASSEMBLE, -static_cast<float>( e.glError ),
                            eq::Vector2i(), formatType.str(), 0, 0 );
            }
        }
    }
}
Пример #19
0
bool Channel::_initAccum()
{
    View* view = static_cast< View* >( getNativeView( ));
    if( !view ) // Only alloc accum for dest
        return true;

    const eq::Eye eye = getEye();
    Accum& accum = _accum[ lunchbox::getIndexOfLastBit( eye ) ];

    if( accum.buffer ) // already done
        return true;

    if( accum.step == -1 ) // accum init failed last time
        return false;

    // Check unsupported cases
    if( !eq::util::Accum::usesFBO( glewGetContext( )))
    {
        for( size_t i = 0; i < eq::NUM_EYES; ++i )
        {
            if( _accum[ i ].buffer )
            {
                LBWARN << "glAccum-based accumulation does not support "
                       << "stereo, disabling idle anti-aliasing."
                       << std::endl;
                for( size_t j = 0; j < eq::NUM_EYES; ++j )
                {
                    delete _accum[ j ].buffer;
                    _accum[ j ].buffer = 0;
                    _accum[ j ].step = -1;
                }

                view->setIdleSteps( 0 );
                return false;
            }
        }
    }

    // set up accumulation buffer
    accum.buffer = new eq::util::Accum( glewGetContext( ));
    const eq::PixelViewport& pvp = getPixelViewport();
    LBASSERT( pvp.isValid( ));

    if( !accum.buffer->init( pvp, getWindow()->getColorFormat( )) ||
        accum.buffer->getMaxSteps() < 256 )
    {
        LBWARN <<"Accumulation buffer initialization failed, "
               << "idle AA not available." << std::endl;
        delete accum.buffer;
        accum.buffer = 0;
        accum.step = -1;
        return false;
    }

    // else
    LBVERB << "Initialized "
           << (accum.buffer->usesFBO() ? "FBO accum" : "glAccum")
           << " buffer for " << getName() << " " << getEye()
           << std::endl;

    view->setIdleSteps( accum.buffer ? 256 : 0 );
    return true;
}
Пример #20
0
void Channel::frameAssemble( const eq::uint128_t&, const eq::Frames& frames )
{
    _startAssemble();

    eq::PixelViewport  coveredPVP;
    eq::ImageOps       dbImages;
    eq::Zoom           zoom( eq::Zoom::NONE );

    // Make sure all frames are ready and gather some information on them
    for( eq::Frame* frame : frames )
    {
        {
            eq::ChannelStatistics stat( eq::Statistic::CHANNEL_FRAME_WAIT_READY,
                                        this );
            frame->waitReady( );
        }
        for( eq::Image* image : frame->getImages( ))
        {
            eq::ImageOp op( frame, image );
            op.offset = frame->getOffset();
            const eq::Range& range = image->getContext().range;
            if( range == eq::Range::ALL ) // 2D frame, assemble directly
                eq::Compositor::assembleImage( op, this );
            else
            {
                dbImages.emplace_back( op );
                zoom = frame->getZoom();
                coveredPVP.merge( image->getPixelViewport() + frame->getOffset());
            }
        }
    }
    if( dbImages.empty( ))
    {
        resetAssemblyState();
        return;
    }

    // calculate correct image sequence
    const bool dbCompose = _image.getContext().range != eq::Range::ALL;
    coveredPVP.intersect( getPixelViewport( ));
    if( dbCompose && coveredPVP.hasArea( ))
    {
        eq::ImageOp op;
        op.image = &_image;
        op.buffers = eq::Frame::BUFFER_COLOR;
        op.zoom = zoom;
        op.offset = eq::Vector2i( coveredPVP.x, coveredPVP.y );
        dbImages.emplace_back( op );
    }

    _orderImages( dbImages );

    // check if current image is in proper position, read back if not
    if( dbCompose )
    {
        if( _bgColor == eq::Vector3f() && dbImages.front().image == &_image)
            dbImages.erase( dbImages.begin( ));
        else if( coveredPVP.hasArea())
        {
            eq::util::ObjectManager& glObjects = getObjectManager();
            eq::PixelViewport pvp = getRegion();
            pvp.intersect( coveredPVP );

            // Update range
            eq::Range range( 1.f, 0.f );
            for( const eq::ImageOp& op : dbImages )
            {
                const eq::Range& r = op.image->getContext().range;
                range.start = std::min( range.start, r.start );
                range.end = std::max( range.end, r.end );
            }
            eq::RenderContext context = _image.getContext();
            context.range = range;

            if( _image.startReadback( eq::Frame::BUFFER_COLOR, pvp, context,
                                      zoom, glObjects ))
            {
                _image.finishReadback( glewGetContext( ));
            }
            clearViewport( coveredPVP );
        }
    }

    glEnable( GL_BLEND );
    LBASSERT( GLEW_EXT_blend_func_separate );
    glBlendFuncSeparate( GL_ONE, GL_SRC_ALPHA, GL_ZERO, GL_SRC_ALPHA );

    eq::Compositor::blendImages( dbImages, this, 0 );
    resetAssemblyState();
}
Пример #21
0
bool Renderer::init( co::Object* initData )
{
    _state = new State( glewGetContext( ));
    return seq::Renderer::init( initData );
}
Пример #22
0
int main (void)
#endif
{
  GLuint err;

#if defined(_WIN32) || !defined(__APPLE__) || defined(GLEW_APPLE_GLX)
  char* display = NULL;
  int visual = -1;

  if (glewParseArgs(argc-1, argv+1, &display, &visual))
  {
#if defined(_WIN32)
    fprintf(stderr, "Usage: glewinfo [-pf <id>]\n");
#else
    fprintf(stderr, "Usage: glewinfo [-display <display>] [-visual <id>]\n");
#endif
    return 1;
  }
#endif

#if defined(_WIN32)
  if (GL_TRUE == glewCreateContext(&visual))
#elif defined(__APPLE__) && !defined(GLEW_APPLE_GLX)
  if (GL_TRUE == glewCreateContext())
#else
  if (GL_TRUE == glewCreateContext(display, &visual))
#endif
  {
    fprintf(stderr, "Error: glewCreateContext failed\n");
    glewDestroyContext();
    return 1;
  }
  glewExperimental = GL_TRUE;
#ifdef GLEW_MX
  err = glewContextInit(glewGetContext());
#ifdef _WIN32
  err = err || wglewContextInit(wglewGetContext());
#elif !defined(__APPLE__) || defined(GLEW_APPLE_GLX)
  err = err || glxewContextInit(glxewGetContext());
#endif

#else
  err = glewInit();
#endif
  if (GLEW_OK != err)
  {
    fprintf(stderr, "Error [main]: glewInit failed: %s\n", glewGetErrorString(err));
    glewDestroyContext();
    return 1;
  }
#if defined(_WIN32)
  f = fopen("glewinfo.txt", "w");
  if (f == NULL) f = stdout;
#else
  f = stdout;
#endif
  fprintf(f, "---------------------------\n");
  fprintf(f, "    GLEW Extension Info\n");
  fprintf(f, "---------------------------\n\n");
  fprintf(f, "GLEW version %s\n", glewGetString(GLEW_VERSION));
#if defined(_WIN32)
  fprintf(f, "Reporting capabilities of pixelformat %d\n", visual);
#elif !defined(__APPLE__) || defined(GLEW_APPLE_GLX)
  fprintf(f, "Reporting capabilities of display %s, visual 0x%x\n", 
    display == NULL ? getenv("DISPLAY") : display, visual);
#endif
  fprintf(f, "Running on a %s from %s\n", 
	  glGetString(GL_RENDERER), glGetString(GL_VENDOR));
  fprintf(f, "OpenGL version %s is supported\n", glGetString(GL_VERSION));
  glewInfo();
#if defined(_WIN32)
  wglewInfo();
#else
  glxewInfo();
#endif
  if (f != stdout) fclose(f);
  glewDestroyContext();
  return 0;
}
Пример #23
0
void Channel::_testTiledOperations()
{
    //----- setup constant data
    const eq::Images& images = _frame.getImages();
    LBASSERT( images[0] );

    eq::Config* config = getConfig();
    const eq::PixelViewport& pvp    = getPixelViewport();
    const eq::Vector2i     offset( pvp.x, pvp.y );

    ConfigEvent event = _createConfigEvent();
    event.area.x() = pvp.w;

    lunchbox::Clock clock;
    eq::Window::ObjectManager* glObjects = getObjectManager();
    const GLEWContext* glewContext = glewGetContext();

    //----- test tiled assembly algorithms
    eq::PixelViewport subPVP = pvp;
    subPVP.h /= NUM_IMAGES;

    for( unsigned i = 0; i < NUM_IMAGES; ++i )
    {
        LBASSERT( images[ i ] );
        images[ i ]->setPixelViewport( subPVP );
    }

    for( unsigned tiles = 0; tiles < NUM_IMAGES; ++tiles )
    {
        _draw( 0 );

        event.area.y() = subPVP.h * (tiles+1);

        //---- readback of 'tiles' depth images
        event.data.type = ConfigEvent::READBACK;
        snprintf( event.formatType, 32, "%d depth tiles", tiles+1 ); 

        event.msec = 0;
        for( unsigned j = 0; j <= tiles; ++j )
        {
            subPVP.y = pvp.y + j * subPVP.h;
            eq::Image* image = images[ j ];
            LBCHECK( image->allocDownloader( eq::Frame::BUFFER_DEPTH, 
                             EQ_COMPRESSOR_TRANSFER_DEPTH_TO_DEPTH_UNSIGNED_INT,
                                             glewContext ));
            image->clearPixelData( eq::Frame::BUFFER_DEPTH );

            clock.reset();
            image->startReadback( eq::Frame::BUFFER_DEPTH, subPVP,
                                  eq::Zoom::NONE, glObjects );
            image->finishReadback( eq::Zoom::NONE, glObjects->glewGetContext( ));
            event.msec += clock.getTimef();
            
        }

        config->sendEvent( event );

        if( tiles == NUM_IMAGES-1 )
            for( unsigned j = 0; j <= tiles; ++j )
                _saveImage( images[j],
                            "EQ_COMPRESSOR_DATATYPE_DEPTH_UNSIGNED_INT",
                            "tiles" );

        //---- readback of 'tiles' color images
        event.data.type = ConfigEvent::READBACK;
        snprintf( event.formatType, 32, "%d color tiles", tiles+1 );

        event.msec = 0;
        for( unsigned j = 0; j <= tiles; ++j )
        {
            subPVP.y = pvp.y + j * subPVP.h;
            eq::Image* image = images[ j ];

            LBCHECK( image->allocDownloader( eq::Frame::BUFFER_COLOR, 
                                            EQ_COMPRESSOR_TRANSFER_RGBA_TO_BGRA,
                                              glewContext ));
            image->clearPixelData( eq::Frame::BUFFER_COLOR );

            clock.reset();
            image->startReadback( eq::Frame::BUFFER_COLOR, subPVP,
                                  eq::Zoom::NONE, glObjects );
            image->finishReadback( eq::Zoom::NONE, glObjects->glewGetContext( ));
            event.msec += clock.getTimef();
        }
        config->sendEvent( event );

        if( tiles == NUM_IMAGES-1 )
            for( unsigned j = 0; j <= tiles; ++j )
                _saveImage( images[j],"EQ_COMPRESSOR_DATATYPE_BGRA","tiles" );

        //---- benchmark assembly operations
        subPVP.y = pvp.y + tiles * subPVP.h;

        eq::Compositor::ImageOp op;
        op.channel = this;
        op.buffers = eq::Frame::BUFFER_COLOR | eq::Frame::BUFFER_DEPTH;
        op.offset  = offset;

        // fixed-function
        event.data.type = ConfigEvent::ASSEMBLE;
        snprintf( event.formatType, 32, "tiles, GL1.1, %d images", tiles+1 ); 

        clock.reset();
        for( unsigned j = 0; j <= tiles; ++j )
            eq::Compositor::assembleImage( images[j], op );

        event.msec = clock.getTimef();
        config->sendEvent( event );

        // CPU
        snprintf( event.formatType, 32, "tiles, CPU,   %d images", tiles+1 ); 

        std::vector< eq::Frame* > frames;
        frames.push_back( &_frame );

        clock.reset();
        eq::Compositor::assembleFramesCPU( frames, this );
        event.msec = clock.getTimef();
        config->sendEvent( event );
    }
}
Пример #24
0
ObjectManager::ObjectManager( const ObjectManager& shared )
        : _impl( shared._impl )
{
    LBASSERT( _impl );
    LBASSERT( glewGetContext( ));
}
Пример #25
0
void GPUAsyncLoader::_update3DTexture()
{
    if( !_storageTexture3D )
    {
        LBERROR << "Can't update 3D texture size - 3D texture is not initialized" << std::endl;
        return;
    }

    if( _bytesNumNew != 1 && _bytesNumNew != 2  )
    {
        LBERROR << "Can't update 3D texture size - only 1 or 2 bytes per value is currently allowed" << std::endl;
        return;
    }

    if( !_cacheIndexNew )
    {
        LBERROR << "GPUAsyncLoader is not initialized with _cacheIndexNew properly" << std::endl;
        return;
    }

    if(  _cacheIndex &&
        *_cacheIndex == *_cacheIndexNew &&
         _bytesNum   ==  _bytesNumNew )
        return;

    _cacheIndex = _cacheIndexNew;
    _bytesNum   = _bytesNumNew;

    const uint32_t blockSize = hlpFuncs::cubed( _cacheIndex->getBlockDim() );
    _compressedBS   = _ramPool->getDataHDDIO()->getMaxBlockSize();
    _uncompressedBS = blockSize*_bytesNum;
    LBWARN << "Compressed BS: " << _compressedBS << " Uncompressed BS: " << _uncompressedBS << std::endl;
    LBASSERT( _compressedBS <= _uncompressedBS );

    EQ_GL_CALL( glBindTexture( GL_TEXTURE_3D, _storageTexture3D ));

    glTexParameteri( GL_TEXTURE_3D, GL_TEXTURE_WRAP_S    , GL_CLAMP_TO_EDGE );
    glTexParameteri( GL_TEXTURE_3D, GL_TEXTURE_WRAP_T    , GL_CLAMP_TO_EDGE );
    glTexParameteri( GL_TEXTURE_3D, GL_TEXTURE_WRAP_R    , GL_CLAMP_TO_EDGE );
    glTexParameteri( GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_LINEAR        );
    glTexParameteri( GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_LINEAR        );

    const Vec3_ui32 cacheDim = _cacheIndex->totalCacheTextureDim();
    LBWARN << "trying to create 3D texture of the size: " << cacheDim
           << ((_bytesNum==2)?" x2 bytes":" x1 byte") << std::endl;

    GLint internalFormat3D = (_bytesNum == 2) ? GL_ALPHA16        : GL_ALPHA;
    _byteFormat3D          = (_bytesNum == 2) ? GL_UNSIGNED_SHORT : GL_UNSIGNED_BYTE;
    EQ_GL_CALL( glTexImage3D(   GL_TEXTURE_3D,
                                0, internalFormat3D, cacheDim.w, cacheDim.h, cacheDim.d,
                                0, GL_ALPHA, _byteFormat3D, 0 ));

    // init volume tree from window
    Node* pipe = dynamic_cast<Node*>(getWindow()->getNode());
    LBASSERT( pipe );
    _volumeTree = pipe->getVolumeTree();
    LBASSERT( _volumeTree );

    _pbo = PboSPtr( new eq::util::PixelBufferObject( glewGetContext(), false ));

    if( !_pbo->setup( _uncompressedBS, GL_WRITE_ONLY_ARB ))
        LBERROR << "PBO initialization failed: " << _pbo->getError() << std::endl;

    // check that PBO has proper size
    _pbo->bind();
    int pboSize = 0;
    glGetBufferParameteriv( GL_PIXEL_UNPACK_BUFFER, GL_BUFFER_SIZE, (GLint*)&pboSize ); 
    if( (uint32_t)pboSize != _uncompressedBS )
        LBERROR << "PBO allocation failed" << std::endl;
    _pbo->unbind();

    _decompressor = Decompressors::select( _ramPool->getDataHDDIO(), _volumeTree, _pbo, _cacheIndex->capacity() );

    EQ_GL_CALL( glFinish( ));
}
Пример #26
0
void Channel::_testTiledOperations()
{
    glGetError(); // reset

    //----- setup constant data
    const eq::Images& images = _frame.getImages();
    LBASSERT( images[0] );

    const eq::PixelViewport& pvp    = getPixelViewport();
    const eq::Vector2i     offset( pvp.x, pvp.y );

    eq::Vector2i area;
    area.x() = pvp.w;

    lunchbox::Clock clock;
    eq::util::ObjectManager& glObjects = getObjectManager();
    const GLEWContext* glewContext = glewGetContext();

    //----- test tiled assembly algorithms
    eq::PixelViewport subPVP = pvp;
    subPVP.h /= NUM_IMAGES;

    for( unsigned i = 0; i < NUM_IMAGES; ++i )
    {
        LBASSERT( images[ i ] );
        images[ i ]->setPixelViewport( subPVP );
    }

    for( unsigned tiles = 0; tiles < NUM_IMAGES; ++tiles )
    {
        EQ_GL_CALL( _draw( co::uint128_t( )));
        area.y() = subPVP.h * (tiles+1);

        //---- readback of 'tiles' depth images
        std::stringstream formatType;
        formatType << tiles+1 << " depth tiles";

        float msec = 0;
        for( unsigned j = 0; j <= tiles; ++j )
        {
            subPVP.y = pvp.y + j * subPVP.h;
            eq::Image* image = images[ j ];
            LBCHECK( image->allocDownloader( eq::Frame::BUFFER_DEPTH,
                             EQ_COMPRESSOR_TRANSFER_DEPTH_TO_DEPTH_UNSIGNED_INT,
                                             glewContext ));
            image->clearPixelData( eq::Frame::BUFFER_DEPTH );

            clock.reset();
            image->startReadback( eq::Frame::BUFFER_DEPTH, subPVP,
                                  eq::Zoom::NONE, glObjects );
            image->finishReadback( glObjects.glewGetContext( ));
            msec += clock.getTimef();
        }

        _sendEvent( READBACK, msec, area, formatType.str(), 0, 0 );

        if( tiles == NUM_IMAGES-1 )
            for( unsigned j = 0; j <= tiles; ++j )
                _saveImage( images[j],
                            "EQ_COMPRESSOR_DATATYPE_DEPTH_UNSIGNED_INT",
                            "tiles" );

        //---- readback of 'tiles' color images
        formatType.str("");
        formatType << tiles+1 << " color tiles";

        msec = 0;
        for( unsigned j = 0; j <= tiles; ++j )
        {
            subPVP.y = pvp.y + j * subPVP.h;
            eq::Image* image = images[ j ];

            LBCHECK( image->allocDownloader( eq::Frame::BUFFER_COLOR,
                                            EQ_COMPRESSOR_TRANSFER_RGBA_TO_BGRA,
                                              glewContext ));
            image->clearPixelData( eq::Frame::BUFFER_COLOR );

            clock.reset();
            image->startReadback( eq::Frame::BUFFER_COLOR, subPVP,
                                  eq::Zoom::NONE, glObjects );
            image->finishReadback( glObjects.glewGetContext( ));
            msec += clock.getTimef();
        }
        _sendEvent( READBACK, msec, area, formatType.str(), 0, 0 );

        if( tiles == NUM_IMAGES-1 )
            for( unsigned j = 0; j <= tiles; ++j )
                _saveImage( images[j],"EQ_COMPRESSOR_DATATYPE_BGRA","tiles" );

        //---- benchmark assembly operations
        subPVP.y = pvp.y + tiles * subPVP.h;

        eq::Compositor::ImageOp op;
        op.channel = this;
        op.buffers = eq::Frame::BUFFER_COLOR | eq::Frame::BUFFER_DEPTH;
        op.offset  = offset;

        // fixed-function
        formatType.str("");
        formatType << "tiles, GL1.1, " << tiles+1 << " images";

        clock.reset();
        for( unsigned j = 0; j <= tiles; ++j )
            eq::Compositor::assembleImage( images[j], op );

        msec = clock.getTimef();
        _sendEvent( ASSEMBLE, msec, area, formatType.str(), 0, 0 );

        // CPU
        formatType.str("");
        formatType << "tiles, CPU,   " << tiles+1 << " images";

        std::vector< eq::Frame* > frames;
        frames.push_back( &_frame );

        clock.reset();
        eq::Compositor::assembleFramesCPU( frames, this );
        msec = clock.getTimef();
        _sendEvent( ASSEMBLE, msec, area, formatType.str(), 0, 0 );
    }
}