diff --git a/include/osg/GLExtensions b/include/osg/GLExtensions index a6bbbdcb4..7388fa4f0 100644 --- a/include/osg/GLExtensions +++ b/include/osg/GLExtensions @@ -365,11 +365,21 @@ class OSG_EXPORT GLExtensions : public osg::Referenced void (GL_APIENTRY * glUniformMatrix4x3dv)( GLint location, GLsizei count, GLboolean transpose, const GLdouble* value ); void (GL_APIENTRY * glGetActiveAtomicCounterBufferiv)( GLuint program, GLuint bufferIndex, GLenum pname, GLint* params ); void (GL_APIENTRY * glDispatchCompute)( GLuint numGroupsX, GLuint numGroupsY, GLuint numGroupsZ ); - GLuint64 (GL_APIENTRY* glGetTextureHandle)(GLint texture); - void (GL_APIENTRY* glMakeTextureHandleResident)(GLuint64 handle); - void (GL_APIENTRY* glMakeTextureHandleNonResident)(GLuint64 handle); - void (GL_APIENTRY* glUniformHandleui64)(GLint location, GLuint64 handle); - GLboolean (GL_APIENTRY* glIsTextureHandleResident)(GLuint64 handle); + + // ARB_bindless_texture + GLuint64 (GL_APIENTRY* glGetTextureHandle)(GLuint texture); + GLuint64 (GL_APIENTRY* glGetTextureSamplerHandle)(GLuint texture, GLuint sampler); + void (GL_APIENTRY* glMakeTextureHandleResident)(GLuint64 handle); + void (GL_APIENTRY* glMakeTextureHandleNonResident)(GLuint64 handle); + GLboolean (GL_APIENTRY* glIsTextureHandleResident)(GLuint64 handle); + GLuint64 (GL_APIENTRY* glGetImageHandle)(GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum format); + void (GL_APIENTRY* glMakeImageHandleResident)(GLuint64 handle); + void (GL_APIENTRY* glMakeImageHandleNonResident)(GLuint64 handle); + GLboolean (GL_APIENTRY* glIsImageHandleResident)(GLuint64 handle); + void (GL_APIENTRY* glUniformHandleui64)(GLint location, GLuint64 handle); + void (GL_APIENTRY* glUniformHandleuiv64)(GLint location, GLsizei count, GLuint64 *handles); + void (GL_APIENTRY* glProgramUniformHandleui64)(GLuint program, GLint location, GLuint64 handle); + void (GL_APIENTRY* glProgramUniformHandleuiv64)(GLuint program, GLint location, GLsizei count, GLuint64 *handles); // Buffer Object extensions bool isBufferObjectSupported; @@ -538,7 +548,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); @@ -557,8 +577,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); diff --git a/src/osg/GLExtensions.cpp b/src/osg/GLExtensions.cpp index 517b92534..76118d0d6 100644 --- a/src/osg/GLExtensions.cpp +++ b/src/osg/GLExtensions.cpp @@ -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); @@ -971,12 +978,21 @@ GLExtensions::GLExtensions(unsigned int in_contextID): maxLayerCount = 0; if (validContext) glGetIntegerv(GL_MAX_ARRAY_TEXTURE_LAYERS, &maxLayerCount); - // Bindless textures + // ARB_bindless_texture setGLExtensionFuncPtr(glGetTextureHandle, "glGetTextureHandle", "glGetTextureHandleARB","glGetTextureHandleNV", validContext); + setGLExtensionFuncPtr(glGetTextureSamplerHandle, "glGetTextureSamplerHandle","glGetTextureSamplerHandleARB", "glGetTextureSamplerHandleNV", validContext); setGLExtensionFuncPtr(glMakeTextureHandleResident, "glMakeTextureHandleResident", "glMakeTextureHandleResidentARB","glMakeTextureHandleResidentNV", validContext); setGLExtensionFuncPtr(glMakeTextureHandleNonResident, "glMakeTextureHandleNonResident", "glMakeTextureHandleNonResidentARB", "glMakeTextureHandleNonResidentNV",validContext); - setGLExtensionFuncPtr(glUniformHandleui64, "glUniformHandleui64", "glUniformHandleui64ARB","glUniformHandleui64NV", validContext); setGLExtensionFuncPtr(glIsTextureHandleResident, "glIsTextureHandleResident","glIsTextureHandleResidentARB", "glIsTextureHandleResidentNV", validContext); + setGLExtensionFuncPtr(glGetImageHandle, "glGetImageHandle","glGetImageHandleARB", "glGetImageHandleNV", validContext); + setGLExtensionFuncPtr(glMakeImageHandleResident, "glMakeImageHandleResident","glMakeImageHandleResidentARB", "glMakeImageHandleResidentNV", validContext); + setGLExtensionFuncPtr(glMakeImageHandleNonResident, "glMakeImageHandleNonResident","glMakeImageHandleNonResidentARB", "glMakeImageHandleNonResidentNV", validContext); + setGLExtensionFuncPtr(glIsImageHandleResident, "glIsImageHandleResident","glIsImageHandleResidentARB", "glIsImageHandleResidentNV", validContext); + setGLExtensionFuncPtr(glUniformHandleui64, "glUniformHandleui64", "glUniformHandleui64ARB","glUniformHandleui64NV", validContext); + setGLExtensionFuncPtr(glUniformHandleuiv64, "glUniformHandleuiv64","glUniformHandleuiv64ARB", "glUniformHandleuiv64NV", validContext); + setGLExtensionFuncPtr(glProgramUniformHandleui64, "glProgramUniformHandleui64","glProgramUniformHandleui64ARB", "glProgramUniformHandleui64NV", validContext); + setGLExtensionFuncPtr(glProgramUniformHandleuiv64, "glProgramUniformHandleuiv64","glProgramUniformHandleuiv64ARB", "glProgramUniformHandleuiv64NV", validContext); + // Blending isBlendColorSupported = validContext && @@ -1054,9 +1070,7 @@ GLExtensions::GLExtensions(unsigned int in_contextID): isPointSpriteSupported = validContext && (OSG_GLES2_FEATURES || OSG_GLES3_FEATURES || OSG_GL3_FEATURES || isGLExtensionSupported(contextID, "GL_ARB_point_sprite") || isGLExtensionSupported(contextID, "GL_OES_point_sprite") || isGLExtensionSupported(contextID, "GL_NV_point_sprite")); - isPointSpriteModeSupported = isPointSpriteSupported && !OSG_GL3_FEATURES; - isPointSpriteCoordOriginSupported = validContext && (OSG_GL3_FEATURES || (glVersion >= 2.0f)); diff --git a/src/osg/Texture.cpp b/src/osg/Texture.cpp index ec3948f1f..f50e5f045 100644 --- a/src/osg/Texture.cpp +++ b/src/osg/Texture.cpp @@ -2310,22 +2310,21 @@ void Texture::applyTexImage2D_load(State& state, GLenum target, const Image* ima int width = inwidth; int height = inheight; - bool useTexStorage = extensions->isTextureStorageEnabled && extensions->isTexStorage2DSupported() && (_borderWidth==0); - GLenum sizedInternalFormat = useTexStorage ? selectSizedInternalFormat(image) : 0; - OSG_NOTICE<<"New path useTexStorage="<