From bd15d0352aef8e6801d5bd50b40fff61447c0b77 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Sun, 27 Nov 2016 18:14:29 +1000 Subject: [PATCH] GLExtensions: Seperate GL_ARB_texture_storage from GL 4.2 This allows us to use glTexStorage on GL3.3 implementations that support the extension. --- Source/Core/Common/Common.vcxproj | 1 + Source/Core/Common/Common.vcxproj.filters | 5 +++ .../GL/GLExtensions/ARB_texture_storage.h | 41 +++++++++++++++++++ .../Common/GL/GLExtensions/GLExtensions.cpp | 13 ++++-- .../Common/GL/GLExtensions/GLExtensions.h | 1 + Source/Core/Common/GL/GLExtensions/gl_4_2.h | 13 ------ 6 files changed, 58 insertions(+), 16 deletions(-) create mode 100644 Source/Core/Common/GL/GLExtensions/ARB_texture_storage.h diff --git a/Source/Core/Common/Common.vcxproj b/Source/Core/Common/Common.vcxproj index 13256bdce7..b93e3c65d0 100644 --- a/Source/Core/Common/Common.vcxproj +++ b/Source/Core/Common/Common.vcxproj @@ -86,6 +86,7 @@ + diff --git a/Source/Core/Common/Common.vcxproj.filters b/Source/Core/Common/Common.vcxproj.filters index cb6fba5ad5..0d87a075f5 100644 --- a/Source/Core/Common/Common.vcxproj.filters +++ b/Source/Core/Common/Common.vcxproj.filters @@ -238,6 +238,10 @@ + + + GL\GLExtensions + @@ -303,6 +307,7 @@ + diff --git a/Source/Core/Common/GL/GLExtensions/ARB_texture_storage.h b/Source/Core/Common/GL/GLExtensions/ARB_texture_storage.h new file mode 100644 index 0000000000..1686a11248 --- /dev/null +++ b/Source/Core/Common/GL/GLExtensions/ARB_texture_storage.h @@ -0,0 +1,41 @@ +/* +** Copyright (c) 2013-2015 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +#include "Common/GL/GLExtensions/gl_common.h" + +#define GL_TEXTURE_IMMUTABLE_FORMAT 0x912F + +typedef void(APIENTRYP PFNDOLTEXSTORAGE1DPROC)(GLenum target, GLsizei levels, GLenum internalformat, + GLsizei width); +typedef void(APIENTRYP PFNDOLTEXSTORAGE2DPROC)(GLenum target, GLsizei levels, GLenum internalformat, + GLsizei width, GLsizei height); +typedef void(APIENTRYP PFNDOLTEXSTORAGE3DPROC)(GLenum target, GLsizei levels, GLenum internalformat, + GLsizei width, GLsizei height, GLsizei depth); + +extern PFNDOLTEXSTORAGE1DPROC dolTexStorage1D; +extern PFNDOLTEXSTORAGE2DPROC dolTexStorage2D; +extern PFNDOLTEXSTORAGE3DPROC dolTexStorage3D; + +#define glTexStorage1D dolTexStorage1D +#define glTexStorage2D dolTexStorage2D +#define glTexStorage3D dolTexStorage3D diff --git a/Source/Core/Common/GL/GLExtensions/GLExtensions.cpp b/Source/Core/Common/GL/GLExtensions/GLExtensions.cpp index 546bfa1b69..db8fb84624 100644 --- a/Source/Core/Common/GL/GLExtensions/GLExtensions.cpp +++ b/Source/Core/Common/GL/GLExtensions/GLExtensions.cpp @@ -655,9 +655,6 @@ PFNDOLGETINTERNALFORMATIVPROC dolGetInternalformativ; PFNDOLGETACTIVEATOMICCOUNTERBUFFERIVPROC dolGetActiveAtomicCounterBufferiv; PFNDOLBINDIMAGETEXTUREPROC dolBindImageTexture; PFNDOLMEMORYBARRIERPROC dolMemoryBarrier; -PFNDOLTEXSTORAGE1DPROC dolTexStorage1D; -PFNDOLTEXSTORAGE2DPROC dolTexStorage2D; -PFNDOLTEXSTORAGE3DPROC dolTexStorage3D; PFNDOLDRAWTRANSFORMFEEDBACKINSTANCEDPROC dolDrawTransformFeedbackInstanced; PFNDOLDRAWTRANSFORMFEEDBACKSTREAMINSTANCEDPROC dolDrawTransformFeedbackStreamInstanced; @@ -905,6 +902,11 @@ PFNDOLTEXIMAGE3DMULTISAMPLEPROC dolTexImage3DMultisample; PFNDOLGETMULTISAMPLEFVPROC dolGetMultisamplefv; PFNDOLSAMPLEMASKIPROC dolSampleMaski; +// ARB_texture_storage +PFNDOLTEXSTORAGE1DPROC dolTexStorage1D; +PFNDOLTEXSTORAGE2DPROC dolTexStorage2D; +PFNDOLTEXSTORAGE3DPROC dolTexStorage3D; + // ARB_texture_storage_multisample PFNDOLTEXSTORAGE2DMULTISAMPLEPROC dolTexStorage2DMultisample; PFNDOLTEXSTORAGE3DMULTISAMPLEPROC dolTexStorage3DMultisample; @@ -1681,6 +1683,11 @@ const GLFunc gl_function_array[] = { GLFUNC_REQUIRES(glGetMultisamplefv, "GL_ARB_texture_multisample"), GLFUNC_REQUIRES(glSampleMaski, "GL_ARB_texture_multisample"), + // ARB_texture_storage + GLFUNC_REQUIRES(glTexStorage1D, "GL_ARB_texture_storage !VERSION_4_2"), + GLFUNC_REQUIRES(glTexStorage2D, "GL_ARB_texture_storage !VERSION_4_2 |VERSION_GLES_3"), + GLFUNC_REQUIRES(glTexStorage3D, "GL_ARB_texture_storage !VERSION_4_2 |VERSION_GLES_3"), + // ARB_texture_storage_multisample GLFUNC_REQUIRES(glTexStorage2DMultisample, "GL_ARB_texture_storage_multisample !VERSION_4_3 |VERSION_GLES_3_1"), diff --git a/Source/Core/Common/GL/GLExtensions/GLExtensions.h b/Source/Core/Common/GL/GLExtensions/GLExtensions.h index 4c58167700..127b2adfd6 100644 --- a/Source/Core/Common/GL/GLExtensions/GLExtensions.h +++ b/Source/Core/Common/GL/GLExtensions/GLExtensions.h @@ -24,6 +24,7 @@ #include "Common/GL/GLExtensions/ARB_shader_storage_buffer_object.h" #include "Common/GL/GLExtensions/ARB_sync.h" #include "Common/GL/GLExtensions/ARB_texture_multisample.h" +#include "Common/GL/GLExtensions/ARB_texture_storage.h" #include "Common/GL/GLExtensions/ARB_texture_storage_multisample.h" #include "Common/GL/GLExtensions/ARB_uniform_buffer_object.h" #include "Common/GL/GLExtensions/ARB_vertex_array_object.h" diff --git a/Source/Core/Common/GL/GLExtensions/gl_4_2.h b/Source/Core/Common/GL/GLExtensions/gl_4_2.h index bb9286bf32..bff8edfaff 100644 --- a/Source/Core/Common/GL/GLExtensions/gl_4_2.h +++ b/Source/Core/Common/GL/GLExtensions/gl_4_2.h @@ -134,7 +134,6 @@ #define GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM 0x8E8D #define GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT 0x8E8E #define GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT 0x8E8F -#define GL_TEXTURE_IMMUTABLE_FORMAT 0x912F typedef void(APIENTRYP PFNDOLDRAWARRAYSINSTANCEDBASEINSTANCEPROC)(GLenum mode, GLint first, GLsizei count, @@ -156,12 +155,6 @@ typedef void(APIENTRYP PFNDOLBINDIMAGETEXTUREPROC)(GLuint unit, GLuint texture, GLboolean layered, GLint layer, GLenum access, GLenum format); typedef void(APIENTRYP PFNDOLMEMORYBARRIERPROC)(GLbitfield barriers); -typedef void(APIENTRYP PFNDOLTEXSTORAGE1DPROC)(GLenum target, GLsizei levels, GLenum internalformat, - GLsizei width); -typedef void(APIENTRYP PFNDOLTEXSTORAGE2DPROC)(GLenum target, GLsizei levels, GLenum internalformat, - GLsizei width, GLsizei height); -typedef void(APIENTRYP PFNDOLTEXSTORAGE3DPROC)(GLenum target, GLsizei levels, GLenum internalformat, - GLsizei width, GLsizei height, GLsizei depth); typedef void(APIENTRYP PFNDOLDRAWTRANSFORMFEEDBACKINSTANCEDPROC)(GLenum mode, GLuint id, GLsizei instancecount); typedef void(APIENTRYP PFNDOLDRAWTRANSFORMFEEDBACKSTREAMINSTANCEDPROC)(GLenum mode, GLuint id, @@ -176,9 +169,6 @@ extern PFNDOLGETINTERNALFORMATIVPROC dolGetInternalformativ; extern PFNDOLGETACTIVEATOMICCOUNTERBUFFERIVPROC dolGetActiveAtomicCounterBufferiv; extern PFNDOLBINDIMAGETEXTUREPROC dolBindImageTexture; extern PFNDOLMEMORYBARRIERPROC dolMemoryBarrier; -extern PFNDOLTEXSTORAGE1DPROC dolTexStorage1D; -extern PFNDOLTEXSTORAGE2DPROC dolTexStorage2D; -extern PFNDOLTEXSTORAGE3DPROC dolTexStorage3D; extern PFNDOLDRAWTRANSFORMFEEDBACKINSTANCEDPROC dolDrawTransformFeedbackInstanced; extern PFNDOLDRAWTRANSFORMFEEDBACKSTREAMINSTANCEDPROC dolDrawTransformFeedbackStreamInstanced; @@ -189,8 +179,5 @@ extern PFNDOLDRAWTRANSFORMFEEDBACKSTREAMINSTANCEDPROC dolDrawTransformFeedbackSt #define glGetActiveAtomicCounterBufferiv dolGetActiveAtomicCounterBufferiv #define glBindImageTexture dolBindImageTexture #define glMemoryBarrier dolMemoryBarrier -#define glTexStorage1D dolTexStorage1D -#define glTexStorage2D dolTexStorage2D -#define glTexStorage3D dolTexStorage3D #define glDrawTransformFeedbackInstanced dolDrawTransformFeedbackInstanced #define glDrawTransformFeedbackStreamInstanced dolDrawTransformFeedbackStreamInstanced