Merge pull request #469 from mp3butcher/imagebinding3
immutable storage for ImageLess Texture
This commit is contained in:
commit
dbe722bda1
@ -555,7 +555,17 @@ class OSG_EXPORT GLExtensions : public osg::Referenced
|
||||
isNonPowerOfTwoTextureMipMappedSupported;
|
||||
}
|
||||
|
||||
void (GL_APIENTRY * glTexStorage2D) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);
|
||||
///immutable texture storage and texture view
|
||||
void (GL_APIENTRY * glTexStorage1D) (GLenum target, GLsizei numMipmapLevels, GLenum internalformat, GLsizei width);
|
||||
void (GL_APIENTRY * glTextureStorage1D) (GLuint texture, GLsizei numMipmapLevels, GLenum internalformat, GLsizei width);
|
||||
void (GL_APIENTRY * glTexStorage2D) (GLenum target, GLsizei numMipmapLevels, GLenum internalformat, GLsizei width, GLsizei height);
|
||||
void (GL_APIENTRY * glTextureStorage2D) (GLuint texture, GLsizei numMipmapLevels, GLenum internalformat, GLsizei width, GLsizei height);
|
||||
void (GL_APIENTRY * glTexStorage3D) ( GLenum target, GLsizei numMipmapLevels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
|
||||
void (GL_APIENTRY * glTextureStorage3D) ( GLuint texture, GLsizei numMipmapLevels,GLenum internalformat,GLsizei width,GLsizei height,GLsizei depth);
|
||||
void (GL_APIENTRY * glTexStorage2DMultisample) ( GLenum target, GLsizei numSamples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations);
|
||||
void (GL_APIENTRY * glTexStorage3DMultisample) ( GLenum target, GLsizei numSamples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations);
|
||||
void (GL_APIENTRY * glTextureView) ( GLuint texture, GLenum target, GLuint orig, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers);
|
||||
|
||||
void (GL_APIENTRY * glCompressedTexImage2D) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data);
|
||||
void (GL_APIENTRY * glCompressedTexSubImage2D) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data);
|
||||
void (GL_APIENTRY * glGetCompressedTexImage) (GLenum target, GLint level, GLvoid *data);
|
||||
@ -574,8 +584,6 @@ class OSG_EXPORT GLExtensions : public osg::Referenced
|
||||
|
||||
void (GL_APIENTRY * glTexImage3D) ( GLenum target, GLint level, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
|
||||
void (GL_APIENTRY * glTexSubImage3D) ( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels);
|
||||
void (GL_APIENTRY * glTexStorage3D) ( GLenum target, GLsizei numMipmapLevels,GLenum sizedInternalFormat,GLsizei width,GLsizei height,GLsizei depth);
|
||||
void (GL_APIENTRY * glTextureStorage3D) ( GLuint texture, GLsizei numMipmapLevels,GLenum sizedInternalFormat,GLsizei width,GLsizei height,GLsizei depth);
|
||||
|
||||
void (GL_APIENTRY * glCopyTexSubImage3D) ( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height );
|
||||
void (GL_APIENTRY * glCompressedTexImage3D) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data);
|
||||
|
@ -913,18 +913,6 @@ GLExtensions::GLExtensions(unsigned int in_contextID):
|
||||
{
|
||||
maxTextureSize = osg_max_size;
|
||||
}
|
||||
|
||||
setGLExtensionFuncPtr(glTexStorage2D,"glTexStorage2D","glTexStorage2DARB", validContext);
|
||||
setGLExtensionFuncPtr(glCompressedTexImage2D,"glCompressedTexImage2D","glCompressedTexImage2DARB", validContext);
|
||||
setGLExtensionFuncPtr(glCompressedTexSubImage2D,"glCompressedTexSubImage2D","glCompressedTexSubImage2DARB", validContext);
|
||||
setGLExtensionFuncPtr(glGetCompressedTexImage,"glGetCompressedTexImage","glGetCompressedTexImageARB", validContext);;
|
||||
setGLExtensionFuncPtr(glTexImage2DMultisample, "glTexImage2DMultisample", "glTexImage2DMultisampleARB", validContext);
|
||||
|
||||
setGLExtensionFuncPtr(glTexParameterIiv, "glTexParameterIiv", "glTexParameterIivARB", "glTexParameterIivEXT", validContext);
|
||||
setGLExtensionFuncPtr(glTexParameterIuiv, "glTexParameterIuiv", "glTexParameterIuivARB", "glTexParameterIuivEXT", validContext);
|
||||
|
||||
setGLExtensionFuncPtr(glBindImageTexture, "glBindImageTexture", "glBindImageTextureARB", validContext);
|
||||
|
||||
isTextureMaxLevelSupported = (glVersion >= 1.2f);
|
||||
|
||||
isTextureStorageEnabled = validContext && ((glVersion >= 4.2f) || isGLExtensionSupported(contextID, "GL_ARB_texture_storage"));
|
||||
@ -939,6 +927,27 @@ GLExtensions::GLExtensions(unsigned int in_contextID):
|
||||
}
|
||||
}
|
||||
|
||||
setGLExtensionFuncPtr(glTexStorage1D,"glTexStorage1D","glTexStorage1DARB", validContext);
|
||||
setGLExtensionFuncPtr(glTextureStorage1D,"glTextureStorage1D","glTextureStorage1DARB", validContext);
|
||||
setGLExtensionFuncPtr(glTexStorage2D,"glTexStorage2D","glTexStorage2DARB", validContext);
|
||||
setGLExtensionFuncPtr(glTextureStorage2D,"glTextureStorage2D","glTextureStorage2DARB", validContext);
|
||||
setGLExtensionFuncPtr(glTexStorage3D, "glTexStorage3D","glTexStorage3DEXT", validContext);
|
||||
setGLExtensionFuncPtr(glTextureStorage3D, "glTextureStorage3D","glTextureStorage3DEXT", validContext);
|
||||
setGLExtensionFuncPtr(glTexStorage2DMultisample, "glTextureStorage2DMultisample","glTextureStorage2DMultisampleEXT", validContext);
|
||||
setGLExtensionFuncPtr(glTexStorage3DMultisample, "glTextureStorage3DMultisample","glTextureStorage3DMultisampleEXT", validContext);
|
||||
setGLExtensionFuncPtr(glTextureView, "glTextureView","glTextureViewEXT", validContext);
|
||||
|
||||
setGLExtensionFuncPtr(glCompressedTexImage2D,"glCompressedTexImage2D","glCompressedTexImage2DARB", validContext);
|
||||
setGLExtensionFuncPtr(glCompressedTexSubImage2D,"glCompressedTexSubImage2D","glCompressedTexSubImage2DARB", validContext);
|
||||
setGLExtensionFuncPtr(glGetCompressedTexImage,"glGetCompressedTexImage","glGetCompressedTexImageARB", validContext);;
|
||||
setGLExtensionFuncPtr(glTexImage2DMultisample, "glTexImage2DMultisample", "glTexImage2DMultisampleARB", validContext);
|
||||
|
||||
setGLExtensionFuncPtr(glTexParameterIiv, "glTexParameterIiv", "glTexParameterIivARB", "glTexParameterIivEXT", validContext);
|
||||
setGLExtensionFuncPtr(glTexParameterIuiv, "glTexParameterIuiv", "glTexParameterIuivARB", "glTexParameterIuivEXT", validContext);
|
||||
|
||||
setGLExtensionFuncPtr(glBindImageTexture, "glBindImageTexture", "glBindImageTextureARB", validContext);
|
||||
|
||||
|
||||
// Texture3D extensions
|
||||
isTexture3DFast = validContext && (OSG_GL3_FEATURES || isGLExtensionSupported(contextID,"GL_EXT_texture3D"));
|
||||
|
||||
@ -950,8 +959,6 @@ GLExtensions::GLExtensions(unsigned int in_contextID):
|
||||
|
||||
setGLExtensionFuncPtr(glTexImage3D, "glTexImage3D","glTexImage3DEXT", validContext);
|
||||
setGLExtensionFuncPtr(glTexSubImage3D, "glTexSubImage3D","glTexSubImage3DEXT", validContext);
|
||||
setGLExtensionFuncPtr(glTexStorage3D, "glTexStorage3D","glTexStorage3DEXT", validContext);
|
||||
setGLExtensionFuncPtr(glTextureStorage3D, "glTextureStorage3D","glTextureStorage3DEXT", validContext);
|
||||
|
||||
setGLExtensionFuncPtr(glCompressedTexImage3D, "glCompressedTexImage3D","glCompressedTexImage3DARB", validContext);
|
||||
setGLExtensionFuncPtr(glCompressedTexSubImage3D, "glCompressedTexSubImage3D","glCompressedTexSubImage3DARB", validContext);
|
||||
@ -1385,4 +1392,3 @@ bool GLExtensions::getFragDataLocation( const char* fragDataName, GLuint& locati
|
||||
location = loc;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -235,9 +235,14 @@ void Texture1D::apply(State& state) const
|
||||
textureObject->bind(state);
|
||||
|
||||
applyTexParameters(GL_TEXTURE_1D,state);
|
||||
|
||||
// no image present, but dimensions are set so lets create the texture
|
||||
glTexImage1D( GL_TEXTURE_1D, 0, _internalFormat,
|
||||
GLExtensions * extensions = state.get<GLExtensions>();
|
||||
bool useTexStorrage = extensions->isTextureStorageEnabled;
|
||||
// no image present, but dimensions at set so lets create the texture
|
||||
if(useTexStorrage)
|
||||
extensions->glTexStorage1D( GL_TEXTURE_1D, (_numMipmapLevels >0)?_numMipmapLevels:1, _internalFormat,
|
||||
_textureWidth);
|
||||
else
|
||||
glTexImage1D( GL_TEXTURE_1D, 0, _internalFormat,
|
||||
_textureWidth, _borderWidth,
|
||||
_sourceFormat ? _sourceFormat : _internalFormat,
|
||||
_sourceType ? _sourceType : GL_UNSIGNED_BYTE,
|
||||
|
@ -298,8 +298,14 @@ void Texture2D::apply(State& state) const
|
||||
|
||||
applyTexParameters(GL_TEXTURE_2D,state);
|
||||
|
||||
GLExtensions * extensions = state.get<GLExtensions>();
|
||||
bool useTexStorrage = extensions->isTextureStorageEnabled;
|
||||
// no image present, but dimensions at set so lets create the texture
|
||||
glTexImage2D( GL_TEXTURE_2D, 0, _internalFormat,
|
||||
if(useTexStorrage)
|
||||
extensions->glTexStorage2D( GL_TEXTURE_2D, (_numMipmapLevels >0)?_numMipmapLevels:1, _internalFormat,
|
||||
_textureWidth, _textureHeight);
|
||||
else
|
||||
glTexImage2D( GL_TEXTURE_2D, 0, _internalFormat,
|
||||
_textureWidth, _textureHeight, _borderWidth,
|
||||
_sourceFormat ? _sourceFormat : _internalFormat,
|
||||
_sourceType ? _sourceType : GL_UNSIGNED_BYTE,
|
||||
@ -497,4 +503,3 @@ void Texture2D::allocateMipmap(State& state) const
|
||||
state.haveAppliedTextureAttribute(state.getActiveTextureUnit(), this);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -113,8 +113,12 @@ void Texture2DMultisample::apply(State& state) const
|
||||
_borderWidth);
|
||||
|
||||
textureObject->bind(state);
|
||||
|
||||
extensions->glTexImage2DMultisample( getTextureTarget(),
|
||||
// no image present, but dimensions at set so lets create the texture
|
||||
if(extensions->isTextureStorageEnabled)
|
||||
extensions->glTexStorage2DMultisample( GL_TEXTURE_2D_MULTISAMPLE, _numSamples, _internalFormat,
|
||||
_textureWidth, _textureHeight, _fixedsamplelocations);
|
||||
else
|
||||
extensions->glTexImage2DMultisample( GL_TEXTURE_2D_MULTISAMPLE,
|
||||
_numSamples,
|
||||
_internalFormat,
|
||||
_textureWidth,
|
||||
@ -124,7 +128,7 @@ void Texture2DMultisample::apply(State& state) const
|
||||
}
|
||||
else
|
||||
{
|
||||
glBindTexture( getTextureTarget(), 0 );
|
||||
glBindTexture( GL_TEXTURE_2D_MULTISAMPLE, 0 );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -323,7 +323,13 @@ void Texture3D::apply(State& state) const
|
||||
applyTexParameters(GL_TEXTURE_3D,state);
|
||||
|
||||
// no image present, but dimensions at set so lets create the texture
|
||||
extensions->glTexImage3D( GL_TEXTURE_3D, 0, _internalFormat,
|
||||
bool useTexStorrage = extensions->isTextureStorageEnabled;
|
||||
// no image present, but dimensions at set so lets create the texture
|
||||
if(useTexStorrage)
|
||||
extensions->glTexStorage3D( GL_TEXTURE_3D, (_numMipmapLevels >0)?_numMipmapLevels:1, _internalFormat,
|
||||
_textureWidth, _textureHeight, _textureDepth);
|
||||
else
|
||||
extensions->glTexImage3D( GL_TEXTURE_3D, 0, _internalFormat,
|
||||
_textureWidth, _textureHeight, _textureDepth,
|
||||
_borderWidth,
|
||||
_sourceFormat ? _sourceFormat : _internalFormat,
|
||||
|
Loading…
Reference in New Issue
Block a user