Moved GLBufferObject::Extensions structure into osg::GL2Extensions
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14570 16af8721-9629-0410-8352-f15c8da7e697
This commit is contained in:
parent
69407f4054
commit
d02c0bdc49
@ -137,9 +137,9 @@ class WindowCaptureCallback : public osg::Camera::DrawCallback
|
|||||||
|
|
||||||
void read()
|
void read()
|
||||||
{
|
{
|
||||||
osg::GLBufferObject::Extensions* ext = osg::GLBufferObject::getExtensions(_gc->getState()->getContextID(),true);
|
osg::GL2Extensions* ext = osg::GL2Extensions::Get(_gc->getState()->getContextID(),true);
|
||||||
|
|
||||||
if (ext->isPBOSupported() && !_pboBuffer.empty())
|
if (ext->isPBOSupported && !_pboBuffer.empty())
|
||||||
{
|
{
|
||||||
if (_pboBuffer.size()==1)
|
if (_pboBuffer.size()==1)
|
||||||
{
|
{
|
||||||
@ -158,9 +158,9 @@ class WindowCaptureCallback : public osg::Camera::DrawCallback
|
|||||||
|
|
||||||
void readPixels();
|
void readPixels();
|
||||||
|
|
||||||
void singlePBO(osg::GLBufferObject::Extensions* ext);
|
void singlePBO(osg::GL2Extensions* ext);
|
||||||
|
|
||||||
void multiPBO(osg::GLBufferObject::Extensions* ext);
|
void multiPBO(osg::GL2Extensions* ext);
|
||||||
|
|
||||||
typedef std::vector< osg::ref_ptr<osg::Image> > ImageBuffer;
|
typedef std::vector< osg::ref_ptr<osg::Image> > ImageBuffer;
|
||||||
typedef std::vector< GLuint > PBOBuffer;
|
typedef std::vector< GLuint > PBOBuffer;
|
||||||
@ -325,7 +325,7 @@ void WindowCaptureCallback::ContextData::readPixels()
|
|||||||
_currentPboIndex = nextPboIndex;
|
_currentPboIndex = nextPboIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowCaptureCallback::ContextData::singlePBO(osg::GLBufferObject::Extensions* ext)
|
void WindowCaptureCallback::ContextData::singlePBO(osg::GL2Extensions* ext)
|
||||||
{
|
{
|
||||||
// std::cout<<"singelPBO( "<<_fileName<<" image "<<_currentImageIndex<<" "<<_currentPboIndex<<std::endl;
|
// std::cout<<"singelPBO( "<<_fileName<<" image "<<_currentImageIndex<<" "<<_currentPboIndex<<std::endl;
|
||||||
|
|
||||||
@ -403,7 +403,7 @@ void WindowCaptureCallback::ContextData::singlePBO(osg::GLBufferObject::Extensio
|
|||||||
_currentImageIndex = nextImageIndex;
|
_currentImageIndex = nextImageIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowCaptureCallback::ContextData::multiPBO(osg::GLBufferObject::Extensions* ext)
|
void WindowCaptureCallback::ContextData::multiPBO(osg::GL2Extensions* ext)
|
||||||
{
|
{
|
||||||
// std::cout<<"multiPBO( "<<_fileName<<" image "<<_currentImageIndex<<" "<<_currentPboIndex<<std::endl;
|
// std::cout<<"multiPBO( "<<_fileName<<" image "<<_currentImageIndex<<" "<<_currentPboIndex<<std::endl;
|
||||||
unsigned int nextImageIndex = (_currentImageIndex+1)%_imageBuffer.size();
|
unsigned int nextImageIndex = (_currentImageIndex+1)%_imageBuffer.size();
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
#define OSG_BUFFEROBJECT 1
|
#define OSG_BUFFEROBJECT 1
|
||||||
|
|
||||||
#include <osg/GL>
|
#include <osg/GL>
|
||||||
|
#include <osg/GL2Extensions>
|
||||||
#include <osg/Object>
|
#include <osg/Object>
|
||||||
#include <osg/buffered_value>
|
#include <osg/buffered_value>
|
||||||
#include <osg/FrameStamp>
|
#include <osg/FrameStamp>
|
||||||
@ -248,7 +249,7 @@ class OSG_EXPORT GLBufferObject : public Referenced
|
|||||||
|
|
||||||
void assign(BufferObject* bufferObject);
|
void assign(BufferObject* bufferObject);
|
||||||
|
|
||||||
bool isPBOSupported() const { return _extensions->isPBOSupported(); }
|
bool isPBOSupported() const { return _extensions->isPBOSupported; }
|
||||||
|
|
||||||
static GLBufferObject* createGLBufferObject(unsigned int contextID, const BufferObject* bufferObject);
|
static GLBufferObject* createGLBufferObject(unsigned int contextID, const BufferObject* bufferObject);
|
||||||
|
|
||||||
@ -258,7 +259,7 @@ class OSG_EXPORT GLBufferObject : public Referenced
|
|||||||
static void discardAllDeletedBufferObjects(unsigned int contextID);
|
static void discardAllDeletedBufferObjects(unsigned int contextID);
|
||||||
static void flushDeletedBufferObjects(unsigned int contextID,double currentTime, double& availbleTime);
|
static void flushDeletedBufferObjects(unsigned int contextID,double currentTime, double& availbleTime);
|
||||||
static void releaseGLBufferObject(unsigned int contextID, GLBufferObject* to);
|
static void releaseGLBufferObject(unsigned int contextID, GLBufferObject* to);
|
||||||
|
#if 0
|
||||||
/** Extensions class which encapsulates the querying of extensions and
|
/** Extensions class which encapsulates the querying of extensions and
|
||||||
* associated function pointers, and provide convenience wrappers to
|
* associated function pointers, and provide convenience wrappers to
|
||||||
* check for the extensions or use the associated functions.*/
|
* check for the extensions or use the associated functions.*/
|
||||||
@ -343,6 +344,7 @@ class OSG_EXPORT GLBufferObject : public Referenced
|
|||||||
* typically used when you have different extensions supported across graphics pipes
|
* typically used when you have different extensions supported across graphics pipes
|
||||||
* but need to ensure that they all use the same low common denominator extensions.*/
|
* but need to ensure that they all use the same low common denominator extensions.*/
|
||||||
static void setExtensions(unsigned int contextID,Extensions* extensions);
|
static void setExtensions(unsigned int contextID,Extensions* extensions);
|
||||||
|
#endif
|
||||||
|
|
||||||
bool hasAllBufferDataBeenRead() const;
|
bool hasAllBufferDataBeenRead() const;
|
||||||
|
|
||||||
@ -380,7 +382,7 @@ class OSG_EXPORT GLBufferObject : public Referenced
|
|||||||
unsigned int _frameLastUsed;
|
unsigned int _frameLastUsed;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Extensions* _extensions;
|
GL2Extensions* _extensions;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -719,10 +719,29 @@ class OSG_EXPORT GL2Extensions : public osg::Referenced
|
|||||||
void (GL_APIENTRY * glGetActiveAtomicCounterBufferiv)( GLuint program, GLuint bufferIndex, GLenum pname, GLint* params );
|
void (GL_APIENTRY * glGetActiveAtomicCounterBufferiv)( GLuint program, GLuint bufferIndex, GLenum pname, GLint* params );
|
||||||
void (GL_APIENTRY * glDispatchCompute)( GLuint numGroupsX, GLuint numGroupsY, GLuint numGroupsZ );
|
void (GL_APIENTRY * glDispatchCompute)( GLuint numGroupsX, GLuint numGroupsY, GLuint numGroupsZ );
|
||||||
|
|
||||||
|
// Buffer Object extensions
|
||||||
|
bool isBufferObjectSupported;
|
||||||
|
bool isPBOSupported;
|
||||||
|
bool isTBOSupported;
|
||||||
|
|
||||||
|
void (GL_APIENTRY * glGenBuffers) (GLsizei n, GLuint *buffers);
|
||||||
|
void (GL_APIENTRY * glBindBuffer) (GLenum target, GLuint buffer);
|
||||||
|
void (GL_APIENTRY * glBufferData) (GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage);
|
||||||
|
void (GL_APIENTRY * glBufferSubData) (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data);
|
||||||
|
void (GL_APIENTRY * glDeleteBuffers) (GLsizei n, const GLuint *buffers);
|
||||||
|
GLboolean (GL_APIENTRY * glIsBuffer) (GLuint buffer);
|
||||||
|
void (GL_APIENTRY * glGetBufferSubData) (GLenum target, GLintptr offset, GLsizeiptr size, GLvoid *data);
|
||||||
|
GLvoid* (GL_APIENTRY * glMapBuffer) (GLenum target, GLenum access);
|
||||||
|
GLvoid* (GL_APIENTRY * glMapBufferRange)(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access);
|
||||||
|
GLboolean (GL_APIENTRY * glUnmapBuffer) (GLenum target);
|
||||||
|
void (GL_APIENTRY * glGetBufferParameteriv) (GLenum target, GLenum pname, GLint *params);
|
||||||
|
void (GL_APIENTRY * glGetBufferPointerv) (GLenum target, GLenum pname, GLvoid* *params);
|
||||||
|
void (GL_APIENTRY * glBindBufferRange) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size);
|
||||||
|
void (GL_APIENTRY * glBindBufferBase) (GLenum target, GLuint index, GLuint buffer);
|
||||||
|
void (GL_APIENTRY * glTexBuffer) (GLenum target, GLenum internalFormat, GLuint buffer);
|
||||||
|
|
||||||
void (GL_APIENTRY * glMemoryBarrier)( GLbitfield barriers );
|
void (GL_APIENTRY * glMemoryBarrier)( GLbitfield barriers );
|
||||||
|
|
||||||
GLvoid* (GL_APIENTRY * glMapBufferRange)(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access);
|
|
||||||
void (GL_APIENTRY * glBindBufferBase)(GLenum target, GLuint index, GLuint buffer);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -121,7 +121,7 @@ class OSG_EXPORT TextureBuffer : public Texture
|
|||||||
_id(0),
|
_id(0),
|
||||||
_usageHint(usageHint)
|
_usageHint(usageHint)
|
||||||
{
|
{
|
||||||
_extensions = osg::GLBufferObject::getExtensions(contextID, true);
|
_extensions = osg::GL2Extensions::Get(contextID, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void bindBuffer(GLenum target);
|
void bindBuffer(GLenum target);
|
||||||
@ -134,7 +134,7 @@ class OSG_EXPORT TextureBuffer : public Texture
|
|||||||
public:
|
public:
|
||||||
GLuint _id;
|
GLuint _id;
|
||||||
GLenum _usageHint;
|
GLenum _usageHint;
|
||||||
osg::GLBufferObject::Extensions* _extensions;
|
osg::GL2Extensions* _extensions;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef osg::buffered_object<osg::ref_ptr<TextureBufferObject> > TextureBufferObjectList;
|
typedef osg::buffered_object<osg::ref_ptr<TextureBufferObject> > TextureBufferObjectList;
|
||||||
|
@ -51,7 +51,7 @@ void BufferIndexBinding::apply(State& state) const
|
|||||||
{
|
{
|
||||||
GLBufferObject* glObject
|
GLBufferObject* glObject
|
||||||
= _bufferObject->getOrCreateGLBufferObject(state.getContextID());
|
= _bufferObject->getOrCreateGLBufferObject(state.getContextID());
|
||||||
if (!glObject->_extensions->isUniformBufferObjectSupported())
|
if (!glObject->_extensions->isUniformBufferObjectSupported)
|
||||||
return;
|
return;
|
||||||
if (glObject->isDirty()) glObject->compileBuffer();
|
if (glObject->isDirty()) glObject->compileBuffer();
|
||||||
glObject->_extensions->glBindBufferRange(_target, _index,
|
glObject->_extensions->glBindBufferRange(_target, _index,
|
||||||
|
@ -64,7 +64,7 @@ GLBufferObject::GLBufferObject(unsigned int contextID, BufferObject* bufferObjec
|
|||||||
{
|
{
|
||||||
assign(bufferObject);
|
assign(bufferObject);
|
||||||
|
|
||||||
_extensions = GLBufferObject::getExtensions(contextID, true);
|
_extensions = GL2Extensions::Get(contextID, true);
|
||||||
|
|
||||||
if (glObjectID==0)
|
if (glObjectID==0)
|
||||||
{
|
{
|
||||||
@ -264,6 +264,7 @@ void GLBufferObject::setBufferDataHasBeenRead(const osg::BufferData* bd)
|
|||||||
++entry.numRead;
|
++entry.numRead;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// Extension support
|
// Extension support
|
||||||
@ -448,6 +449,7 @@ void GLBufferObject::Extensions::glTexBuffer( GLenum target, GLenum internalForm
|
|||||||
if ( _glTexBuffer ) _glTexBuffer( target, internalFormat, buffer );
|
if ( _glTexBuffer ) _glTexBuffer( target, internalFormat, buffer );
|
||||||
else OSG_WARN<<"Error: glTexBuffer not supported by OpenGL driver\n";
|
else OSG_WARN<<"Error: glTexBuffer not supported by OpenGL driver\n";
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
@ -1679,7 +1681,7 @@ void PixelDataBufferObject::bindBufferInWriteMode(State& state)
|
|||||||
//--------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------
|
||||||
void PixelDataBufferObject::unbindBuffer(unsigned int contextID) const
|
void PixelDataBufferObject::unbindBuffer(unsigned int contextID) const
|
||||||
{
|
{
|
||||||
GLBufferObject::Extensions* extensions = GLBufferObject::getExtensions(contextID,true);
|
GL2Extensions* extensions = GL2Extensions::Get(contextID, true);
|
||||||
|
|
||||||
switch(_mode[contextID])
|
switch(_mode[contextID])
|
||||||
{
|
{
|
||||||
|
@ -273,8 +273,27 @@ GL2Extensions::GL2Extensions(unsigned int contextID)
|
|||||||
setGLExtensionFuncPtr(glDispatchCompute, "glDispatchCompute" );
|
setGLExtensionFuncPtr(glDispatchCompute, "glDispatchCompute" );
|
||||||
|
|
||||||
setGLExtensionFuncPtr(glMemoryBarrier, "glMemoryBarrier", "glMemoryBarrierEXT" );
|
setGLExtensionFuncPtr(glMemoryBarrier, "glMemoryBarrier", "glMemoryBarrierEXT" );
|
||||||
|
|
||||||
|
setGLExtensionFuncPtr(glGenBuffers, "glGenBuffers","glGenBuffersARB");
|
||||||
|
setGLExtensionFuncPtr(glBindBuffer, "glBindBuffer","glBindBufferARB");
|
||||||
|
setGLExtensionFuncPtr(glBufferData, "glBufferData","glBufferDataARB");
|
||||||
|
setGLExtensionFuncPtr(glBufferSubData, "glBufferSubData","glBufferSubDataARB");
|
||||||
|
setGLExtensionFuncPtr(glDeleteBuffers, "glDeleteBuffers","glDeleteBuffersARB");
|
||||||
|
setGLExtensionFuncPtr(glIsBuffer, "glIsBuffer","glIsBufferARB");
|
||||||
|
setGLExtensionFuncPtr(glGetBufferSubData, "glGetBufferSubData","glGetBufferSubDataARB");
|
||||||
|
setGLExtensionFuncPtr(glMapBuffer, "glMapBuffer","glMapBufferARB");
|
||||||
setGLExtensionFuncPtr(glMapBufferRange, "glMapBufferRange" );
|
setGLExtensionFuncPtr(glMapBufferRange, "glMapBufferRange" );
|
||||||
|
setGLExtensionFuncPtr(glUnmapBuffer, "glUnmapBuffer","glUnmapBufferARB");
|
||||||
|
setGLExtensionFuncPtr(glGetBufferParameteriv, "glGetBufferParameteriv","glGetBufferParameterivARB");
|
||||||
|
setGLExtensionFuncPtr(glGetBufferPointerv, "glGetBufferPointerv","glGetBufferPointervARB");
|
||||||
|
setGLExtensionFuncPtr(glBindBufferRange, "glBindBufferRange");
|
||||||
setGLExtensionFuncPtr(glBindBufferBase, "glBindBufferBase", "glBindBufferBaseEXT", "glBindBufferBaseNV" );
|
setGLExtensionFuncPtr(glBindBufferBase, "glBindBufferBase", "glBindBufferBaseEXT", "glBindBufferBaseNV" );
|
||||||
|
setGLExtensionFuncPtr(glTexBuffer, "glTexBuffer","glTexBufferARB" );
|
||||||
|
|
||||||
|
isPBOSupported = OSG_GL3_FEATURES || osg::isGLExtensionSupported(contextID,"GL_ARB_pixel_buffer_object");
|
||||||
|
isUniformBufferObjectSupported = osg::isGLExtensionSupported(contextID, "GL_ARB_uniform_buffer_object");
|
||||||
|
isTBOSupported = osg::isGLExtensionSupported(contextID,"GL_ARB_texture_buffer_object");
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -661,7 +661,7 @@ void Geometry::compileGLObjects(RenderInfo& renderInfo) const
|
|||||||
{
|
{
|
||||||
State& state = *renderInfo.getState();
|
State& state = *renderInfo.getState();
|
||||||
unsigned int contextID = state.getContextID();
|
unsigned int contextID = state.getContextID();
|
||||||
GLBufferObject::Extensions* extensions = GLBufferObject::getExtensions(contextID, true);
|
GL2Extensions* extensions = state.get<GL2Extensions>();
|
||||||
if (!extensions) return;
|
if (!extensions) return;
|
||||||
|
|
||||||
typedef std::set<BufferObject*> BufferObjects;
|
typedef std::set<BufferObject*> BufferObjects;
|
||||||
|
@ -72,8 +72,8 @@ class WindowCaptureCallback : public osg::Camera::DrawCallback
|
|||||||
|
|
||||||
void read();
|
void read();
|
||||||
void readPixels();
|
void readPixels();
|
||||||
void singlePBO(osg::GLBufferObject::Extensions* ext);
|
void singlePBO(osg::GL2Extensions* ext);
|
||||||
void multiPBO(osg::GLBufferObject::Extensions* ext);
|
void multiPBO(osg::GL2Extensions* ext);
|
||||||
|
|
||||||
typedef std::vector< osg::ref_ptr<osg::Image> > ImageBuffer;
|
typedef std::vector< osg::ref_ptr<osg::Image> > ImageBuffer;
|
||||||
typedef std::vector< GLuint > PBOBuffer;
|
typedef std::vector< GLuint > PBOBuffer;
|
||||||
@ -218,9 +218,9 @@ void WindowCaptureCallback::ContextData::updateTimings(osg::Timer_t tick_start,
|
|||||||
|
|
||||||
void WindowCaptureCallback::ContextData::read()
|
void WindowCaptureCallback::ContextData::read()
|
||||||
{
|
{
|
||||||
osg::GLBufferObject::Extensions* ext = osg::GLBufferObject::getExtensions(_gc->getState()->getContextID(),true);
|
osg::GL2Extensions* ext = osg::GL2Extensions::Get(_gc->getState()->getContextID(),true);
|
||||||
|
|
||||||
if (ext->isPBOSupported() && !_pboBuffer.empty())
|
if (ext->isPBOSupported && !_pboBuffer.empty())
|
||||||
{
|
{
|
||||||
if (_pboBuffer.size()==1)
|
if (_pboBuffer.size()==1)
|
||||||
{
|
{
|
||||||
@ -275,7 +275,7 @@ void WindowCaptureCallback::ContextData::readPixels()
|
|||||||
_currentPboIndex = nextPboIndex;
|
_currentPboIndex = nextPboIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowCaptureCallback::ContextData::singlePBO(osg::GLBufferObject::Extensions* ext)
|
void WindowCaptureCallback::ContextData::singlePBO(osg::GL2Extensions* ext)
|
||||||
{
|
{
|
||||||
unsigned int nextImageIndex = (_currentImageIndex+1)%_imageBuffer.size();
|
unsigned int nextImageIndex = (_currentImageIndex+1)%_imageBuffer.size();
|
||||||
|
|
||||||
@ -350,7 +350,7 @@ void WindowCaptureCallback::ContextData::singlePBO(osg::GLBufferObject::Extensio
|
|||||||
_currentImageIndex = nextImageIndex;
|
_currentImageIndex = nextImageIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowCaptureCallback::ContextData::multiPBO(osg::GLBufferObject::Extensions* ext)
|
void WindowCaptureCallback::ContextData::multiPBO(osg::GL2Extensions* ext)
|
||||||
{
|
{
|
||||||
unsigned int nextImageIndex = (_currentImageIndex+1)%_imageBuffer.size();
|
unsigned int nextImageIndex = (_currentImageIndex+1)%_imageBuffer.size();
|
||||||
unsigned int nextPboIndex = (_currentPboIndex+1)%_pboBuffer.size();
|
unsigned int nextPboIndex = (_currentPboIndex+1)%_pboBuffer.size();
|
||||||
|
Loading…
Reference in New Issue
Block a user