From 59082686112144343073de75986dbb8076b35689 Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Thu, 1 Feb 2018 09:46:49 -0800 Subject: Enabled IOS build --- Graphics/GraphicsEngineOpenGL/CMakeLists.txt | 19 +- Graphics/GraphicsEngineOpenGL/include/GLContext.h | 2 + .../GraphicsEngineOpenGL/include/GLContextIOS.h | 49 + Graphics/GraphicsEngineOpenGL/include/GLStubs.h | 1015 ------------------- .../GraphicsEngineOpenGL/include/GLStubsAndroid.h | 1052 ++++++++++++++++++++ Graphics/GraphicsEngineOpenGL/include/GLStubsIOS.h | 534 ++++++++++ Graphics/GraphicsEngineOpenGL/include/pch.h | 8 +- .../interface/BaseInterfacesGL.h | 8 +- .../interface/RenderDeviceFactoryOpenGL.h | 2 +- Graphics/GraphicsEngineOpenGL/src/BufferGLImpl.cpp | 32 +- .../GraphicsEngineOpenGL/src/BufferViewGLImpl.cpp | 2 + .../src/DeviceContextGLImpl.cpp | 18 + Graphics/GraphicsEngineOpenGL/src/GLContextIOS.mm | 119 +++ .../GraphicsEngineOpenGL/src/GLContextMacOS.cpp | 106 -- .../GraphicsEngineOpenGL/src/GLContextMacOS.mm | 106 ++ .../GraphicsEngineOpenGL/src/GLContextState.cpp | 10 + .../src/GLProgramResources.cpp | 8 +- Graphics/GraphicsEngineOpenGL/src/GLStubs.cpp | 283 ------ .../GraphicsEngineOpenGL/src/GLStubsAndroid.cpp | 283 ++++++ .../src/RenderDeviceFactoryOpenGL.cpp | 2 + .../src/RenderDeviceGLImpl.cpp | 4 + Graphics/GraphicsEngineOpenGL/src/ShaderGLImpl.cpp | 21 + .../GraphicsEngineOpenGL/src/Texture2D_OGL.cpp | 4 + .../GraphicsEngineOpenGL/src/TextureBaseGL.cpp | 62 +- 24 files changed, 2304 insertions(+), 1445 deletions(-) create mode 100644 Graphics/GraphicsEngineOpenGL/include/GLContextIOS.h delete mode 100644 Graphics/GraphicsEngineOpenGL/include/GLStubs.h create mode 100644 Graphics/GraphicsEngineOpenGL/include/GLStubsAndroid.h create mode 100644 Graphics/GraphicsEngineOpenGL/include/GLStubsIOS.h create mode 100644 Graphics/GraphicsEngineOpenGL/src/GLContextIOS.mm delete mode 100644 Graphics/GraphicsEngineOpenGL/src/GLContextMacOS.cpp create mode 100644 Graphics/GraphicsEngineOpenGL/src/GLContextMacOS.mm delete mode 100644 Graphics/GraphicsEngineOpenGL/src/GLStubs.cpp create mode 100644 Graphics/GraphicsEngineOpenGL/src/GLStubsAndroid.cpp (limited to 'Graphics/GraphicsEngineOpenGL') diff --git a/Graphics/GraphicsEngineOpenGL/CMakeLists.txt b/Graphics/GraphicsEngineOpenGL/CMakeLists.txt index 3ff8988d..fbd1b404 100644 --- a/Graphics/GraphicsEngineOpenGL/CMakeLists.txt +++ b/Graphics/GraphicsEngineOpenGL/CMakeLists.txt @@ -86,10 +86,10 @@ if(PLATFORM_WIN32) elseif(PLATFORM_ANDROID) list(APPEND SOURCE src/GLContextAndroid.cpp) list(APPEND SOURCE src/RenderDeviceGLESImpl.cpp) - list(APPEND SOURCE src/GLStubs.cpp) + list(APPEND SOURCE src/GLStubsAndroid.cpp) list(APPEND INCLUDE include/GLContextAndroid.h) - list(APPEND INCLUDE include/GLStubs.h) + list(APPEND INCLUDE include/GLStubsAndroid.h) list(APPEND INCLUDE include/RenderDeviceGLESImpl.h) list(APPEND INTERFACE interface/RenderDeviceGLES.h) @@ -97,11 +97,12 @@ elseif(PLATFORM_LINUX) list(APPEND SOURCE src/GLContextLinux.cpp) list(APPEND INCLUDE include/GLContextLinux.h) elseif(PLATFORM_MACOS) - list(APPEND SOURCE src/GLContextMacOS.cpp) + list(APPEND SOURCE src/GLContextMacOS.mm) list(APPEND INCLUDE include/GLContextMacOS.h) - set_source_files_properties(src/GLContextMacOS.cpp - PROPERTIES COMPILE_FLAGS "-x objective-c++" - ) +elseif(PLATFORM_IOS) + list(APPEND SOURCE src/GLContextIOS.mm) + list(APPEND INCLUDE include/GLContextIOS.h) + list(APPEND INCLUDE include/GLStubsIOS.h) else() message(FATAL_ERROR "Unknown platform") endif() @@ -170,6 +171,12 @@ elseif(PLATFORM_LINUX) elseif(PLATFORM_MACOS) find_package(OpenGL REQUIRED) set(PRIVATE_DEPENDENCIES ${PRIVATE_DEPENDENCIES} glew-static ${OPENGL_LIBRARY} ${APP_KIT}) +elseif(PLATFORM_IOS) + # How is OPENGLES defined? + if(NOT OPENGLES) + message(FATAL_ERROR "Cannot find OPENGLES framework") + endif() + set(PRIVATE_DEPENDENCIES ${PRIVATE_DEPENDENCIES} ${APP_KIT} ${OPENGLES}) else() message(FATAL_ERROR "Unknown platform") endif() diff --git a/Graphics/GraphicsEngineOpenGL/include/GLContext.h b/Graphics/GraphicsEngineOpenGL/include/GLContext.h index 935d0dbc..e51df8da 100644 --- a/Graphics/GraphicsEngineOpenGL/include/GLContext.h +++ b/Graphics/GraphicsEngineOpenGL/include/GLContext.h @@ -31,6 +31,8 @@ # include "GLContextLinux.h" #elif defined(PLATFORM_MACOS) # include "GLContextMacOS.h" +#elif defined(PLATFORM_IOS) +# include "GLContextIOS.h" #else # error Unsupported platform #endif diff --git a/Graphics/GraphicsEngineOpenGL/include/GLContextIOS.h b/Graphics/GraphicsEngineOpenGL/include/GLContextIOS.h new file mode 100644 index 00000000..3e5b77bb --- /dev/null +++ b/Graphics/GraphicsEngineOpenGL/include/GLContextIOS.h @@ -0,0 +1,49 @@ +/* Copyright 2015-2018 Egor Yusov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * THE SOFTWARE IS 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent acts) or agreed to in writing, shall any Contributor be + * liable for any damages, including any direct, indirect, special, incidental, + * or consequential damages of any character arising as a result of this License or + * out of the use or inability to use the software (including but not limited to damages + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#pragma once + +namespace Diligent +{ + struct ContextInitInfo + { + SwapChainDesc SwapChainAttribs; + void *pNativeWndHandle = nullptr; + }; + + class GLContext + { + public: + typedef void* NativeGLContextType; // NSOpenGLContext* + + GLContext(const ContextInitInfo &Info, struct DeviceCaps &DeviceCaps); + void SwapBuffers(); + + const SwapChainDesc& GetSwapChainDesc()const{ return m_SwapChainAttribs; } + + NativeGLContextType GetCurrentNativeGLContext(); + + private: + SwapChainDesc m_SwapChainAttribs; + }; +} diff --git a/Graphics/GraphicsEngineOpenGL/include/GLStubs.h b/Graphics/GraphicsEngineOpenGL/include/GLStubs.h deleted file mode 100644 index d3d237ab..00000000 --- a/Graphics/GraphicsEngineOpenGL/include/GLStubs.h +++ /dev/null @@ -1,1015 +0,0 @@ -/* Copyright 2015-2018 Egor Yusov - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * THE SOFTWARE IS 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent acts) or agreed to in writing, shall any Contributor be - * liable for any damages, including any direct, indirect, special, incidental, - * or consequential damages of any character arising as a result of this License or - * out of the use or inability to use the software (including but not limited to damages - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#pragma once - -// Define unsupported formats for OpenGL ES -#ifndef GL_RGBA16 -# define GL_RGBA16 0x805B -#endif - -#ifndef GL_RGBA16_SNORM -# define GL_RGBA16_SNORM 0x8F9B -#endif - -#ifndef GL_RG16 -# define GL_RG16 0x822C -#endif - -#ifndef GL_RG16_SNORM -# define GL_RG16_SNORM 0x8F99 -#endif - -#ifndef GL_R16 -# define GL_R16 0x822A -#endif - -#ifndef GL_R16_SNORM -# define GL_R16_SNORM 0x8F98 -#endif - -#ifndef GL_COMPRESSED_RGB_S3TC_DXT1_EXT -# define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0 -#endif - -#ifndef GL_COMPRESSED_SRGB_S3TC_DXT1_EXT -# define GL_COMPRESSED_SRGB_S3TC_DXT1_EXT 0x8C4C -#endif - -#ifndef GL_COMPRESSED_RGBA_S3TC_DXT3_EXT -# define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2 -#endif - -#ifndef GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT -# define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT 0x8C4E -#endif - -#ifndef GL_COMPRESSED_RGBA_S3TC_DXT5_EXT -# define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3 -#endif - -#ifndef GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT -# define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT 0x8C4F -#endif - -#ifndef GL_COMPRESSED_RED_RGTC1 -# define GL_COMPRESSED_RED_RGTC1 0x8DBB -#endif - -#ifndef GL_COMPRESSED_SIGNED_RED_RGTC1 -# define GL_COMPRESSED_SIGNED_RED_RGTC1 0x8DBC -#endif - -#ifndef GL_COMPRESSED_RG_RGTC2 -# define GL_COMPRESSED_RG_RGTC2 0x8DBD -#endif - -#ifndef GL_COMPRESSED_SIGNED_RG_RGTC2 -# define GL_COMPRESSED_SIGNED_RG_RGTC2 0x8DBE -#endif - -#ifndef GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT -# define GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT 0x8E8F -#endif - -#ifndef GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT -# define GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT 0x8E8E -#endif - -#ifndef GL_COMPRESSED_RGBA_BPTC_UNORM -# define GL_COMPRESSED_RGBA_BPTC_UNORM 0x8E8C -#endif - -#ifndef GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM -# define GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM 0x8E8D -#endif - -#ifndef GL_UNSIGNED_SHORT_5_6_5_REV -# define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364 -#endif - -#ifndef GL_UNSIGNED_INT_10_10_10_2 -# define GL_UNSIGNED_INT_10_10_10_2 0x8036 -#endif - -#ifndef GL_UNSIGNED_SHORT_5_6_5_REV -# define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364 -#endif - -#ifndef GL_UNSIGNED_SHORT_1_5_5_5_REV -# define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366 -#endif - -// Define unsupported shaders -#ifndef GL_GEOMETRY_SHADER -# define GL_GEOMETRY_SHADER 0x8DD9 -#endif - -#ifndef GL_TESS_CONTROL_SHADER -# define GL_TESS_CONTROL_SHADER 0x8E88 -#endif - -#ifndef GL_TESS_EVALUATION_SHADER -# define GL_TESS_EVALUATION_SHADER 0x8E87 -#endif - -// Define unsupported texture filtering modes -#ifndef GL_CLAMP_TO_BORDER -# define GL_CLAMP_TO_BORDER 0 -#endif - -#ifndef GL_MIRROR_CLAMP_TO_EDGE -# define GL_MIRROR_CLAMP_TO_EDGE 0 -#endif - -// Define unsupported bind points -#ifndef GL_DRAW_INDIRECT_BUFFER -# define GL_DRAW_INDIRECT_BUFFER 0x8F3F -#endif - -#ifndef GL_DISPATCH_INDIRECT_BUFFER -# define GL_DISPATCH_INDIRECT_BUFFER 0x90EE -#endif - -#ifndef GL_TEXTURE_1D_ARRAY -# define GL_TEXTURE_1D_ARRAY 0x8C18 -#endif - -#ifndef GL_TEXTURE_BINDING_1D_ARRAY -# define GL_TEXTURE_BINDING_1D_ARRAY 0x8C1C -#endif - -#ifndef GL_TEXTURE_1D -# define GL_TEXTURE_1D 0x0DE0 -#endif - -#ifndef GL_TEXTURE_BINDING_1D -# define GL_TEXTURE_BINDING_1D 0x8068 -#endif - -#ifndef GL_TEXTURE_2D_MULTISAMPLE -# define GL_TEXTURE_2D_MULTISAMPLE 0x9100 -#endif - -#ifndef GL_TEXTURE_BINDING_2D_MULTISAMPLE -# define GL_TEXTURE_BINDING_2D_MULTISAMPLE 0x9104 -#endif - -#ifndef GL_TEXTURE_2D_MULTISAMPLE_ARRAY -# define GL_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9102 -#endif - -#ifndef GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY -# define GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY 0x9105 -#endif - -#ifndef GL_TEXTURE_CUBE_MAP_ARRAY -# define GL_TEXTURE_CUBE_MAP_ARRAY 0x9009 -#endif - -#ifndef GL_TEXTURE_BINDING_CUBE_MAP_ARRAY -# define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY 0x900A -#endif - -#ifndef GL_TEXTURE_BUFFER -# define GL_TEXTURE_BUFFER 0x8C2A -#endif - -// Define unsupported pipeline bind flags -#ifndef GL_VERTEX_SHADER_BIT -# define GL_VERTEX_SHADER_BIT 0x00000001 -#endif - -#ifndef GL_FRAGMENT_SHADER_BIT -# define GL_FRAGMENT_SHADER_BIT 0x00000002 -#endif - -#ifndef GL_GEOMETRY_SHADER_BIT -# define GL_GEOMETRY_SHADER_BIT 0x00000004 -#endif - -#ifndef GL_TESS_CONTROL_SHADER_BIT -# define GL_TESS_CONTROL_SHADER_BIT 0x00000008 -#endif - -#ifndef GL_TESS_EVALUATION_SHADER_BIT -# define GL_TESS_EVALUATION_SHADER_BIT 0x00000010 -#endif - -#ifndef GL_COMPUTE_SHADER_BIT -# define GL_COMPUTE_SHADER_BIT 0x00000020 -#endif - -// Define unsupported sampler attributes -#ifndef GL_TEXTURE_LOD_BIAS -# define GL_TEXTURE_LOD_BIAS 0 -#endif - -#ifndef GL_TEXTURE_MAX_ANISOTROPY_EXT -# define GL_TEXTURE_MAX_ANISOTROPY_EXT 0 -#endif - -#ifndef GL_TEXTURE_BORDER_COLOR -# define GL_TEXTURE_BORDER_COLOR 0 -#endif - -// Other unsupported attributes -#ifndef GL_PROGRAM_SEPARABLE -# define GL_PROGRAM_SEPARABLE 0x8258 -#endif - -// Define unsupported uniform data types -#ifndef GL_SAMPLER_1D - #define GL_SAMPLER_1D 0x8B5D -#endif - -#ifndef GL_SAMPLER_1D_SHADOW - #define GL_SAMPLER_1D_SHADOW 0x8B61 -#endif - -#ifndef GL_SAMPLER_1D_ARRAY - #define GL_SAMPLER_1D_ARRAY 0x8DC0 -#endif - -#ifndef GL_SAMPLER_1D_ARRAY_SHADOW - #define GL_SAMPLER_1D_ARRAY_SHADOW 0x8DC3 -#endif - -#ifndef GL_INT_SAMPLER_1D - #define GL_INT_SAMPLER_1D 0x8DC9 -#endif - -#ifndef GL_INT_SAMPLER_1D_ARRAY - #define GL_INT_SAMPLER_1D_ARRAY 0x8DCE -#endif - -#ifndef GL_UNSIGNED_INT_SAMPLER_1D - #define GL_UNSIGNED_INT_SAMPLER_1D 0x8DD1 -#endif - -#ifndef GL_UNSIGNED_INT_SAMPLER_1D_ARRAY - #define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY 0x8DD6 -#endif - -#ifndef GL_SAMPLER_CUBE_MAP_ARRAY - #define GL_SAMPLER_CUBE_MAP_ARRAY 0x900C -#endif - -#ifndef GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW - #define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW 0x900D -#endif - -#ifndef GL_INT_SAMPLER_CUBE_MAP_ARRAY - #define GL_INT_SAMPLER_CUBE_MAP_ARRAY 0x900E -#endif - -#ifndef GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY - #define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY 0x900F -#endif - -#ifndef GL_SAMPLER_BUFFER - #define GL_SAMPLER_BUFFER 0x8DC2 -#endif - -#ifndef GL_INT_SAMPLER_BUFFER - #define GL_INT_SAMPLER_BUFFER 0x8DD0 -#endif - -#ifndef GL_UNSIGNED_INT_SAMPLER_BUFFER - #define GL_UNSIGNED_INT_SAMPLER_BUFFER 0x8DD8 -#endif - -#ifndef GL_SAMPLER_2D_MULTISAMPLE - #define GL_SAMPLER_2D_MULTISAMPLE 0x9108 -#endif - -#ifndef GL_INT_SAMPLER_2D_MULTISAMPLE - #define GL_INT_SAMPLER_2D_MULTISAMPLE 0x9109 -#endif - -#ifndef GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE - #define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE 0x910A -#endif - -#ifndef GL_SAMPLER_2D_MULTISAMPLE_ARRAY - #define GL_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910B -#endif - -#ifndef GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY - #define GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910C -#endif - -#ifndef GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY - #define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910D -#endif - - -#ifndef GL_IMAGE_1D - #define GL_IMAGE_1D 0x904C -#endif - -#ifndef GL_IMAGE_2D - #define GL_IMAGE_2D 0x904D -#endif - -#ifndef GL_IMAGE_3D - #define GL_IMAGE_3D 0x904E -#endif - -#ifndef GL_IMAGE_2D_RECT - #define GL_IMAGE_2D_RECT 0x904F -#endif - -#ifndef GL_IMAGE_CUBE - #define GL_IMAGE_CUBE 0x9050 -#endif - -#ifndef GL_IMAGE_BUFFER - #define GL_IMAGE_BUFFER 0x9051 -#endif - -#ifndef GL_IMAGE_1D_ARRAY - #define GL_IMAGE_1D_ARRAY 0x9052 -#endif - -#ifndef GL_IMAGE_2D_ARRAY - #define GL_IMAGE_2D_ARRAY 0x9053 -#endif - -#ifndef GL_IMAGE_CUBE_MAP_ARRAY - #define GL_IMAGE_CUBE_MAP_ARRAY 0x9054 -#endif - -#ifndef GL_IMAGE_2D_MULTISAMPLE - #define GL_IMAGE_2D_MULTISAMPLE 0x9055 -#endif - -#ifndef GL_IMAGE_2D_MULTISAMPLE_ARRAY - #define GL_IMAGE_2D_MULTISAMPLE_ARRAY 0x9056 -#endif - -#ifndef GL_INT_IMAGE_1D - #define GL_INT_IMAGE_1D 0x9057 -#endif - -#ifndef GL_INT_IMAGE_2D - #define GL_INT_IMAGE_2D 0x9058 -#endif - -#ifndef GL_INT_IMAGE_3D - #define GL_INT_IMAGE_3D 0x9059 -#endif - -#ifndef GL_INT_IMAGE_2D_RECT - #define GL_INT_IMAGE_2D_RECT 0x905A -#endif - -#ifndef GL_INT_IMAGE_CUBE - #define GL_INT_IMAGE_CUBE 0x905B -#endif - -#ifndef GL_INT_IMAGE_BUFFER - #define GL_INT_IMAGE_BUFFER 0x905C -#endif - -#ifndef GL_INT_IMAGE_1D_ARRAY - #define GL_INT_IMAGE_1D_ARRAY 0x905D -#endif - -#ifndef GL_INT_IMAGE_2D_ARRAY - #define GL_INT_IMAGE_2D_ARRAY 0x905E -#endif - -#ifndef GL_INT_IMAGE_CUBE_MAP_ARRAY - #define GL_INT_IMAGE_CUBE_MAP_ARRAY 0x905F -#endif - -#ifndef GL_INT_IMAGE_2D_MULTISAMPLE - #define GL_INT_IMAGE_2D_MULTISAMPLE 0x9060 -#endif - -#ifndef GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY - #define GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY 0x9061 -#endif - -#ifndef GL_UNSIGNED_INT_IMAGE_1D - #define GL_UNSIGNED_INT_IMAGE_1D 0x9062 -#endif - -#ifndef GL_UNSIGNED_INT_IMAGE_2D - #define GL_UNSIGNED_INT_IMAGE_2D 0x9063 -#endif - -#ifndef GL_UNSIGNED_INT_IMAGE_3D - #define GL_UNSIGNED_INT_IMAGE_3D 0x9064 -#endif - -#ifndef GL_UNSIGNED_INT_IMAGE_2D_RECT - #define GL_UNSIGNED_INT_IMAGE_2D_RECT 0x9065 -#endif - -#ifndef GL_UNSIGNED_INT_IMAGE_CUBE - #define GL_UNSIGNED_INT_IMAGE_CUBE 0x9066 -#endif - -#ifndef GL_UNSIGNED_INT_IMAGE_BUFFER - #define GL_UNSIGNED_INT_IMAGE_BUFFER 0x9067 -#endif - -#ifndef GL_UNSIGNED_INT_IMAGE_1D_ARRAY - #define GL_UNSIGNED_INT_IMAGE_1D_ARRAY 0x9068 -#endif - -#ifndef GL_UNSIGNED_INT_IMAGE_2D_ARRAY - #define GL_UNSIGNED_INT_IMAGE_2D_ARRAY 0x9069 -#endif - -#ifndef GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY - #define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY 0x906A -#endif - -#ifndef GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE - #define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE 0x906B -#endif - -#ifndef GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY - #define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY 0x906C -#endif - - -// Compute shader stubs -#ifndef GL_READ_ONLY -# define GL_READ_ONLY 0x88B8 -#endif - -#ifndef GL_WRITE_ONLY -# define GL_WRITE_ONLY 0x88B9 -#endif - -#ifndef GL_READ_WRITE -# define GL_READ_WRITE 0x88BA -#endif - -#ifndef GL_COMPUTE_SHADER -# define GL_COMPUTE_SHADER 0x91B9 -#endif - -#ifndef GL_ES_VERSION_3_1 -#define LOAD_GL_BIND_IMAGE_TEXTURE -typedef void (GL_APIENTRY* PFNGLBINDIMAGETEXTUREPROC) (GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format); -extern PFNGLBINDIMAGETEXTUREPROC glBindImageTexture; - -#define LOAD_GL_DISPATCH_COMPUTE -typedef void (GL_APIENTRY* PFNGLDISPATCHCOMPUTEPROC) (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z); -extern PFNGLDISPATCHCOMPUTEPROC glDispatchCompute; - -#define LOAD_GL_MEMORY_BARRIER -typedef void (GL_APIENTRY* PFNGLMEMORYBARRIERPROC) (GLbitfield barriers); -extern PFNGLMEMORYBARRIERPROC glMemoryBarrier; -#endif // GL_ES_VERSION_3_1 - -#ifndef GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT -# define GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT 0x00000001 -#endif -#ifndef GL_ELEMENT_ARRAY_BARRIER_BIT -# define GL_ELEMENT_ARRAY_BARRIER_BIT 0x00000002 -#endif -#ifndef GL_UNIFORM_BARRIER_BIT -# define GL_UNIFORM_BARRIER_BIT 0x00000004 -#endif -#ifndef GL_TEXTURE_FETCH_BARRIER_BIT -# define GL_TEXTURE_FETCH_BARRIER_BIT 0x00000008 -#endif -#ifndef GL_SHADER_IMAGE_ACCESS_BARRIER_BIT -# define GL_SHADER_IMAGE_ACCESS_BARRIER_BIT 0x00000020 -#endif -#ifndef GL_COMMAND_BARRIER_BIT -# define GL_COMMAND_BARRIER_BIT 0x00000040 -#endif -#ifndef GL_PIXEL_BUFFER_BARRIER_BIT -# define GL_PIXEL_BUFFER_BARRIER_BIT 0x00000080 -#endif -#ifndef GL_TEXTURE_UPDATE_BARRIER_BIT -# define GL_TEXTURE_UPDATE_BARRIER_BIT 0x00000100 -#endif -#ifndef GL_BUFFER_UPDATE_BARRIER_BIT -# define GL_BUFFER_UPDATE_BARRIER_BIT 0x00000200 -#endif -#ifndef GL_FRAMEBUFFER_BARRIER_BIT -# define GL_FRAMEBUFFER_BARRIER_BIT 0x00000400 -#endif -#ifndef GL_TRANSFORM_FEEDBACK_BARRIER_BIT -# define GL_TRANSFORM_FEEDBACK_BARRIER_BIT 0x00000800 -#endif -#ifndef GL_ATOMIC_COUNTER_BARRIER_BIT -# define GL_ATOMIC_COUNTER_BARRIER_BIT 0x00001000 -#endif -#ifndef GL_SHADER_STORAGE_BARRIER_BIT -# define GL_SHADER_STORAGE_BARRIER_BIT 0x00002000 -#endif -#ifndef GL_CLIENT_MAPPED_BUFFER_BARRIER_BIT -# define GL_CLIENT_MAPPED_BUFFER_BARRIER_BIT 0x00004000 -#endif -#ifndef GL_QUERY_BUFFER_BARRIER_BIT -# define GL_QUERY_BUFFER_BARRIER_BIT 0x00008000 -#endif -#ifndef GL_ALL_BARRIER_BITS -# define GL_ALL_BARRIER_BITS 0xFFFFFFFF -#endif - - -//--------------------------- Texture queries ----------------------------- -#ifndef GL_TEXTURE_WIDTH -# define GL_TEXTURE_WIDTH 0x1000 -#endif - -#ifndef GL_TEXTURE_HEIGHT -# define GL_TEXTURE_HEIGHT 0x1001 -#endif - -#ifndef GL_TEXTURE_DEPTH -# define GL_TEXTURE_DEPTH 0x8071 -#endif - -#ifndef GL_TEXTURE_INTERNAL_FORMAT -# define GL_TEXTURE_INTERNAL_FORMAT 0x1003 -#endif - - -//------------------------ Program interface query ------------------------ -#ifndef GL_UNIFORM -# define GL_UNIFORM 0x92E1 -#endif - -#ifndef GL_UNIFORM_BLOCK -# define GL_UNIFORM_BLOCK 0x92E2 -#endif - -#ifndef GL_PROGRAM_INPUT -# define GL_PROGRAM_INPUT 0x92E3 -#endif - -#ifndef GL_PROGRAM_OUTPUT -# define GL_PROGRAM_OUTPUT 0x92E4 -#endif - -#ifndef GL_BUFFER_VARIABLE -# define GL_BUFFER_VARIABLE 0x92E5 -#endif - -#ifndef GL_SHADER_STORAGE_BLOCK -# define GL_SHADER_STORAGE_BLOCK 0x92E6 -#endif - -#ifndef GL_IS_PER_PATCH -# define GL_IS_PER_PATCH 0x92E7 -#endif - -#ifndef GL_VERTEX_SUBROUTINE -# define GL_VERTEX_SUBROUTINE 0x92E8 -#endif - -#ifndef GL_TESS_CONTROL_SUBROUTINE -# define GL_TESS_CONTROL_SUBROUTINE 0x92E9 -#endif - -#ifndef GL_TESS_EVALUATION_SUBROUTINE -# define GL_TESS_EVALUATION_SUBROUTINE 0x92EA -#endif - -#ifndef GL_GEOMETRY_SUBROUTINE -# define GL_GEOMETRY_SUBROUTINE 0x92EB -#endif - -#ifndef GL_FRAGMENT_SUBROUTINE -# define GL_FRAGMENT_SUBROUTINE 0x92EC -#endif - -#ifndef GL_COMPUTE_SUBROUTINE -# define GL_COMPUTE_SUBROUTINE 0x92ED -#endif - -#ifndef GL_VERTEX_SUBROUTINE_UNIFORM -# define GL_VERTEX_SUBROUTINE_UNIFORM 0x92EE -#endif - -#ifndef GL_TESS_CONTROL_SUBROUTINE_UNIFORM -# define GL_TESS_CONTROL_SUBROUTINE_UNIFORM 0x92EF -#endif - -#ifndef GL_TESS_EVALUATION_SUBROUTINE_UNIFORM -# define GL_TESS_EVALUATION_SUBROUTINE_UNIFORM 0x92F0 -#endif - -#ifndef GL_GEOMETRY_SUBROUTINE_UNIFORM -# define GL_GEOMETRY_SUBROUTINE_UNIFORM 0x92F1 -#endif - -#ifndef GL_FRAGMENT_SUBROUTINE_UNIFORM -# define GL_FRAGMENT_SUBROUTINE_UNIFORM 0x92F2 -#endif - -#ifndef GL_COMPUTE_SUBROUTINE_UNIFORM -# define GL_COMPUTE_SUBROUTINE_UNIFORM 0x92F3 -#endif - -#ifndef GL_TRANSFORM_FEEDBACK_VARYING -# define GL_TRANSFORM_FEEDBACK_VARYING 0x92F4 -#endif - -#ifndef GL_ACTIVE_RESOURCES -# define GL_ACTIVE_RESOURCES 0x92F5 -#endif - -#ifndef GL_MAX_NAME_LENGTH -# define GL_MAX_NAME_LENGTH 0x92F6 -#endif - -#ifndef GL_MAX_NUM_ACTIVE_VARIABLES -# define GL_MAX_NUM_ACTIVE_VARIABLES 0x92F7 -#endif - -#ifndef GL_MAX_NUM_COMPATIBLE_SUBROUTINES -# define GL_MAX_NUM_COMPATIBLE_SUBROUTINES 0x92F8 -#endif - -#ifndef GL_NAME_LENGTH -# define GL_NAME_LENGTH 0x92F9 -#endif - -#ifndef GL_TYPE -# define GL_TYPE 0x92FA -#endif - -#ifndef GL_ARRAY_SIZE -# define GL_ARRAY_SIZE 0x92FB -#endif - -#ifndef GL_OFFSET -# define GL_OFFSET 0x92FC -#endif - -#ifndef GL_BLOCK_INDEX -# define GL_BLOCK_INDEX 0x92FD -#endif - -#ifndef GL_ARRAY_STRIDE -# define GL_ARRAY_STRIDE 0x92FE -#endif - -#ifndef GL_MATRIX_STRIDE -# define GL_MATRIX_STRIDE 0x92FF -#endif - -#ifndef GL_IS_ROW_MAJOR -# define GL_IS_ROW_MAJOR 0x9300 -#endif - -#ifndef GL_ATOMIC_COUNTER_BUFFER_INDEX -# define GL_ATOMIC_COUNTER_BUFFER_INDEX 0x9301 -#endif - -#ifndef GL_BUFFER_BINDING -# define GL_BUFFER_BINDING 0x9302 -#endif - -#ifndef GL_BUFFER_DATA_SIZE -# define GL_BUFFER_DATA_SIZE 0x9303 -#endif - -#ifndef GL_NUM_ACTIVE_VARIABLES -# define GL_NUM_ACTIVE_VARIABLES 0x9304 -#endif - -#ifndef GL_ACTIVE_VARIABLES -# define GL_ACTIVE_VARIABLES 0x9305 -#endif - -#ifndef GL_REFERENCED_BY_VERTEX_SHADER -# define GL_REFERENCED_BY_VERTEX_SHADER 0x9306 -#endif - -#ifndef GL_REFERENCED_BY_TESS_CONTROL_SHADER -# define GL_REFERENCED_BY_TESS_CONTROL_SHADER 0x9307 -#endif - -#ifndef GL_REFERENCED_BY_TESS_EVALUATION_SHADER -# define GL_REFERENCED_BY_TESS_EVALUATION_SHADER 0x9308 -#endif - -#ifndef GL_REFERENCED_BY_GEOMETRY_SHADER -# define GL_REFERENCED_BY_GEOMETRY_SHADER 0x9309 -#endif - -#ifndef GL_REFERENCED_BY_FRAGMENT_SHADER -# define GL_REFERENCED_BY_FRAGMENT_SHADER 0x930A -#endif - -#ifndef GL_REFERENCED_BY_COMPUTE_SHADER -# define GL_REFERENCED_BY_COMPUTE_SHADER 0x930B -#endif - -#ifndef GL_TOP_LEVEL_ARRAY_SIZE -# define GL_TOP_LEVEL_ARRAY_SIZE 0x930C -#endif - -#ifndef GL_TOP_LEVEL_ARRAY_STRIDE -# define GL_TOP_LEVEL_ARRAY_STRIDE 0x930D -#endif - -#ifndef GL_LOCATION -# define GL_LOCATION 0x930E -#endif - -#ifndef GL_LOCATION_INDEX -# define GL_LOCATION_INDEX 0x930F -#endif - - - -// --------------------- Shader storage buffer ----------------------- - -#ifndef GL_MAX_COMBINED_SHADER_OUTPUT_RESOURCES -# define GL_MAX_COMBINED_SHADER_OUTPUT_RESOURCES 0x8F39 -#endif - -#ifndef GL_SHADER_STORAGE_BUFFER -# define GL_SHADER_STORAGE_BUFFER 0x90D2 -#endif - -#ifndef GL_SHADER_STORAGE_BUFFER_BINDING -# define GL_SHADER_STORAGE_BUFFER_BINDING 0x90D3 -#endif - -#ifndef GL_SHADER_STORAGE_BUFFER_START -# define GL_SHADER_STORAGE_BUFFER_START 0x90D4 -#endif - -#ifndef GL_SHADER_STORAGE_BUFFER_SIZE -# define GL_SHADER_STORAGE_BUFFER_SIZE 0x90D5 -#endif - -#ifndef GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS -# define GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS 0x90D6 -#endif - -#ifndef GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS -# define GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS 0x90D7 -#endif - -#ifndef GL_MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS -# define GL_MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS 0x90D8 -#endif - -#ifndef GL_MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS -# define GL_MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS 0x90D9 -#endif - -#ifndef GL_MAX_FRAGMENT_SHADER_STORAGE_BLOCKS -# define GL_MAX_FRAGMENT_SHADER_STORAGE_BLOCKS 0x90DA -#endif - -#ifndef GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS -# define GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS 0x90DB -#endif - -#ifndef GL_MAX_COMBINED_SHADER_STORAGE_BLOCKS -# define GL_MAX_COMBINED_SHADER_STORAGE_BLOCKS 0x90DC -#endif - -#ifndef GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS -# define GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS 0x90DD -#endif - -#ifndef GL_MAX_SHADER_STORAGE_BLOCK_SIZE -# define GL_MAX_SHADER_STORAGE_BLOCK_SIZE 0x90DE -#endif - -#ifndef GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT -# define GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT 0x90DF -#endif - - -// Polygon mode -#ifndef GL_POINT -# define GL_POINT 0x1B00 -#endif - -#ifndef GL_LINE -# define GL_LINE 0x1B01 -#endif - -#ifndef GL_FILL -# define GL_FILL 0x1B02 -#endif - - -#ifndef GL_DEPTH_CLAMP -# define GL_DEPTH_CLAMP 0 -#endif - -// Blend functions -#ifndef GL_SRC1_COLOR -# define GL_SRC1_COLOR 0x88F9 -#endif - -#ifndef GL_ONE_MINUS_SRC1_COLOR -# define GL_ONE_MINUS_SRC1_COLOR 0x88FA -#endif - -#ifndef GL_SOURCE1_ALPHA -# define GL_SOURCE1_ALPHA 0x8589 -#endif - -#ifndef GL_SRC1_ALPHA -# define GL_SRC1_ALPHA GL_SOURCE1_ALPHA -#endif - -#ifndef GL_ONE_MINUS_SRC1_ALPHA -# define GL_ONE_MINUS_SRC1_ALPHA 0x88FB -#endif - -/* ---------------------- GL_ARB_internalformat_query2 --------------------- */ - -#ifndef GL_INTERNALFORMAT_SUPPORTED -# define GL_INTERNALFORMAT_SUPPORTED 0x826F -#endif - -// --------------------- Framebuffer SRGB ----------------------- -#ifndef GL_FRAMEBUFFER_SRGB -# define GL_FRAMEBUFFER_SRGB 0x8DB9 -#endif - -// -------------------- Incomplete FBO error codes --------------- -#ifndef GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS -# define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS 0x8DA8 -#endif - -#ifndef GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER -# define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER 0x8CDB -#endif - -#ifndef GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER -# define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER 0x8CDC -#endif - -/* ---------------------- ARB_tessellation_shader --------------------- */ -#ifndef GL_PATCHES -# define GL_PATCHES 0xE -#endif - -#ifndef GL_PATCH_VERTICES -# define GL_PATCH_VERTICES 0x8E72 -#endif - - -// Define unsupported GL function stubs -template -void UnsupportedGLFunctionStub( const T &Name ) -{ - LOG_ERROR_MESSAGE( Name, "() is not supported in this API!\n" ); -} - -#define glDrawElementsInstancedBaseVertexBaseInstance(...) UnsupportedGLFunctionStub("glDrawElementsInstancedBaseVertexBaseInstance") -#define glDrawElementsInstancedBaseVertex(...) UnsupportedGLFunctionStub("glDrawElementsInstancedBaseVertex") -#define glDrawElementsInstancedBaseInstance(...) UnsupportedGLFunctionStub("glDrawElementsInstancedBaseInstance") -#define glDrawArraysInstancedBaseInstance(...) UnsupportedGLFunctionStub("glDrawArraysInstancedBaseInstance") -#define glDrawElementsBaseVertex(...) UnsupportedGLFunctionStub("glDrawElementsBaseVertex") -#define glTextureView(...) UnsupportedGLFunctionStub("glTextureView") -#define glTexStorage1D(...) UnsupportedGLFunctionStub("glTexStorage1D") -#define glTexSubImage1D(...) UnsupportedGLFunctionStub("glTexSubImage1D") -#define glTexStorage3DMultisample(...) UnsupportedGLFunctionStub("glTexStorage3DMultisample") - -#ifndef GL_ES_VERSION_3_1 - - #define LOAD_GEN_PROGRAM_PIPELINES - typedef void (GL_APIENTRY* PFNGLGENPROGRAMPIPELINESPROC) (GLsizei n, GLuint* pipelines); - extern PFNGLGENPROGRAMPIPELINESPROC glGenProgramPipelines; - - #define LOAD_GL_DELETE_PROGRAM_PIPELINES - typedef void (GL_APIENTRY* PFNGLDELETEPROGRAMPIPELINESPROC) (GLsizei n, const GLuint* pipelines); - extern PFNGLDELETEPROGRAMPIPELINESPROC glDeleteProgramPipelines; - - #define LOAD_GL_BIND_PROGRAM_PIPELINE - typedef void (GL_APIENTRY* PFNGLBINDPROGRAMPIPELINEPROC) (GLuint pipeline); - extern PFNGLBINDPROGRAMPIPELINEPROC glBindProgramPipeline; - - #define LOAD_DRAW_ELEMENTS_INDIRECT - typedef void (GL_APIENTRY* PFNGLDRAWELEMENTSINDIRECTPROC) (GLenum mode, GLenum type, const GLvoid *indirect); - extern PFNGLDRAWELEMENTSINDIRECTPROC glDrawElementsIndirect; - - #define LOAD_DRAW_ARRAYS_INDIRECT - typedef void (GL_APIENTRY* PFNGLDRAWARRAYSINDIRECTPROC)( GLenum mode, const GLvoid *indirect ); - extern PFNGLDRAWARRAYSINDIRECTPROC glDrawArraysIndirect; - - #define LOAD_DISPATCH_COMPUTE_INDIRECT - typedef void (GL_APIENTRY* PFNGLDISPATCHCOMPUTEINDIRECTPROC) (GLintptr indirect); - extern PFNGLDISPATCHCOMPUTEINDIRECTPROC glDispatchComputeIndirect; - - #define LOAD_GL_USE_PROGRAM_STAGES - typedef void (GL_APIENTRY* PFNGLUSEPROGRAMSTAGESPROC) (GLuint pipeline, GLbitfield stages, GLuint program); - extern PFNGLUSEPROGRAMSTAGESPROC glUseProgramStages; - - #define LOAD_GL_TEX_STORAGE_2D_MULTISAMPLE - typedef void (GL_APIENTRY* PFNGLTEXSTORAGE2DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); - extern PFNGLTEXSTORAGE2DMULTISAMPLEPROC glTexStorage2DMultisample; - - #define LOAD_GL_PROGRAM_UNIFORM_1I - typedef void (GL_APIENTRY* PFNGLPROGRAMUNIFORM1IPROC) (GLuint program, GLint location, GLint x); - extern PFNGLPROGRAMUNIFORM1IPROC glProgramUniform1i; - - #define LOAD_GL_GET_PROGRAM_INTERFACEIV - typedef void (GL_APIENTRY* PFNGLGETPROGRAMINTERFACEIVPROC) (GLuint program, GLenum programInterface, GLenum pname, GLint* params); - extern PFNGLGETPROGRAMINTERFACEIVPROC glGetProgramInterfaceiv; - - #define LOAD_GL_GET_PROGRAM_RESOURCE_NAME - typedef void (GL_APIENTRY* PFNGLGETPROGRAMRESOURCENAMEPROC) (GLuint program, GLenum programInterface, GLuint index, GLsizei bufSize, GLsizei* length, GLchar *name); - extern PFNGLGETPROGRAMRESOURCENAMEPROC glGetProgramResourceName; - - #define LOAD_GL_GET_PROGRAM_RESOURCEIV - typedef void (GL_APIENTRY* PFNGLGETPROGRAMRESOURCEIVPROC) (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum* props, GLsizei bufSize, GLsizei *length, GLint *params); - extern PFNGLGETPROGRAMRESOURCEIVPROC glGetProgramResourceiv; - - #define LOAD_GET_TEX_LEVEL_PARAMETER_IV - typedef void (GL_APIENTRY* PFNGLGETTEXLEVELPARAMETERIVPROC) (GLenum target, GLint level, GLenum pname, GLint *params); - extern PFNGLGETTEXLEVELPARAMETERIVPROC glGetTexLevelParameteriv; - -#endif //GL_ES_VERSION_3_1 - -#define LOAD_GL_TEX_BUFFER -typedef void (GL_APIENTRY* PFNGLTEXBUFFERPROC) (GLenum, GLenum, GLuint); -extern PFNGLTEXBUFFERPROC glTexBuffer; - -#define LOAD_GL_VIEWPORT_INDEXEDF -typedef void (GL_APIENTRY* PFNGLVIEWPORTINDEXEDFPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h); -extern PFNGLVIEWPORTINDEXEDFPROC glViewportIndexedf; - -#define LOAD_GL_SCISSOR_INDEXED -typedef void (GL_APIENTRY* PFNGLSCISSORINDEXEDPROC) (GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height); -extern PFNGLSCISSORINDEXEDPROC glScissorIndexed; - -#define LOAD_GL_POLYGON_MODE -typedef void (GL_APIENTRY* PFNGLPOLYGONMODE) (GLenum face, GLenum mode); -extern PFNGLPOLYGONMODE glPolygonMode; - -#define LOAD_GL_ENABLEI -typedef void (GL_APIENTRY* PFNGLENABLEIPROC) (GLenum, GLuint); -extern PFNGLENABLEIPROC glEnablei; - -#define LOAD_GL_BLEND_FUNC_SEPARATEI -typedef void (GL_APIENTRY* PFNGLBLENDFUNCSEPARATEIPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); -extern PFNGLBLENDFUNCSEPARATEIPROC glBlendFuncSeparatei; - -#define LOAD_GL_BLEND_EQUATION_SEPARATEI -typedef void (GL_APIENTRY* PFNGLBLENDEQUATIONSEPARATEIPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); -extern PFNGLBLENDEQUATIONSEPARATEIPROC glBlendEquationSeparatei; - -#define LOAD_GL_DISABLEI -typedef void (GL_APIENTRY* PFNGLDISABLEIPROC) (GLenum, GLuint); -extern PFNGLDISABLEIPROC glDisablei; - -#define LOAD_GL_COLOR_MASKI -typedef void (GL_APIENTRY* PFNGLCOLORMASKIPROC) (GLuint, GLboolean, GLboolean, GLboolean, GLboolean); -extern PFNGLCOLORMASKIPROC glColorMaski; - -#define LOAD_GL_PATCH_PARAMTER_I -typedef void (GL_APIENTRY* PFNGLPATCHPARAMETERIPROC) (GLenum pname, GLint value); -extern PFNGLPATCHPARAMETERIPROC glPatchParameteri; - -#define LOAD_GL_FRAMEBUFFER_TEXTURE -typedef void (GL_APIENTRY* PFNGLFRAMEBUFFERTEXTUREPROC) (GLenum, GLenum, GLuint, GLint); -extern PFNGLFRAMEBUFFERTEXTUREPROC glFramebufferTexture; - -#define LOAD_GL_FRAMEBUFFER_TEXTURE_1D -typedef void (GL_APIENTRY* PFNGLFRAMEBUFFERTEXTURE1DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -extern PFNGLFRAMEBUFFERTEXTURE1DPROC glFramebufferTexture1D; - -#define LOAD_GL_FRAMEBUFFER_TEXTURE_3D -typedef void (GL_APIENTRY* PFNGLFRAMEBUFFERTEXTURE3DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint layer); -extern PFNGLFRAMEBUFFERTEXTURE3DPROC glFramebufferTexture3D; - -#define LOAD_GL_COPY_IMAGE_SUB_DATA -typedef void (GL_APIENTRY* PFNGLCOPYIMAGESUBDATAPROC) (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth); -extern PFNGLCOPYIMAGESUBDATAPROC glCopyImageSubData; - -void LoadGLFunctions(); \ No newline at end of file diff --git a/Graphics/GraphicsEngineOpenGL/include/GLStubsAndroid.h b/Graphics/GraphicsEngineOpenGL/include/GLStubsAndroid.h new file mode 100644 index 00000000..d51434fb --- /dev/null +++ b/Graphics/GraphicsEngineOpenGL/include/GLStubsAndroid.h @@ -0,0 +1,1052 @@ +/* Copyright 2015-2018 Egor Yusov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * THE SOFTWARE IS 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent acts) or agreed to in writing, shall any Contributor be + * liable for any damages, including any direct, indirect, special, incidental, + * or consequential damages of any character arising as a result of this License or + * out of the use or inability to use the software (including but not limited to damages + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#pragma once + +#include "Errors.h" + +// Define unsupported formats for OpenGL ES +#ifndef GL_RGBA16 +# define GL_RGBA16 0x805B +#endif + +#ifndef GL_RGBA16_SNORM +# define GL_RGBA16_SNORM 0x8F9B +#endif + +#ifndef GL_RG16 +# define GL_RG16 0x822C +#endif + +#ifndef GL_RG16_SNORM +# define GL_RG16_SNORM 0x8F99 +#endif + +#ifndef GL_R16 +# define GL_R16 0x822A +#endif + +#ifndef GL_R16_SNORM +# define GL_R16_SNORM 0x8F98 +#endif + +#ifndef GL_COMPRESSED_RGB_S3TC_DXT1_EXT +# define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0 +#endif + +#ifndef GL_COMPRESSED_SRGB_S3TC_DXT1_EXT +# define GL_COMPRESSED_SRGB_S3TC_DXT1_EXT 0x8C4C +#endif + +#ifndef GL_COMPRESSED_RGBA_S3TC_DXT3_EXT +# define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2 +#endif + +#ifndef GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT +# define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT 0x8C4E +#endif + +#ifndef GL_COMPRESSED_RGBA_S3TC_DXT5_EXT +# define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3 +#endif + +#ifndef GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT +# define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT 0x8C4F +#endif + +#ifndef GL_COMPRESSED_RED_RGTC1 +# define GL_COMPRESSED_RED_RGTC1 0x8DBB +#endif + +#ifndef GL_COMPRESSED_SIGNED_RED_RGTC1 +# define GL_COMPRESSED_SIGNED_RED_RGTC1 0x8DBC +#endif + +#ifndef GL_COMPRESSED_RG_RGTC2 +# define GL_COMPRESSED_RG_RGTC2 0x8DBD +#endif + +#ifndef GL_COMPRESSED_SIGNED_RG_RGTC2 +# define GL_COMPRESSED_SIGNED_RG_RGTC2 0x8DBE +#endif + +#ifndef GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT +# define GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT 0x8E8F +#endif + +#ifndef GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT +# define GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT 0x8E8E +#endif + +#ifndef GL_COMPRESSED_RGBA_BPTC_UNORM +# define GL_COMPRESSED_RGBA_BPTC_UNORM 0x8E8C +#endif + +#ifndef GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM +# define GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM 0x8E8D +#endif + +#ifndef GL_UNSIGNED_SHORT_5_6_5_REV +# define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364 +#endif + +#ifndef GL_UNSIGNED_INT_10_10_10_2 +# define GL_UNSIGNED_INT_10_10_10_2 0x8036 +#endif + +#ifndef GL_UNSIGNED_SHORT_5_6_5_REV +# define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364 +#endif + +#ifndef GL_UNSIGNED_SHORT_1_5_5_5_REV +# define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366 +#endif + +// Define unsupported shaders +#ifndef GL_GEOMETRY_SHADER +# define GL_GEOMETRY_SHADER 0x8DD9 +#endif + +#ifndef GL_TESS_CONTROL_SHADER +# define GL_TESS_CONTROL_SHADER 0x8E88 +#endif + +#ifndef GL_TESS_EVALUATION_SHADER +# define GL_TESS_EVALUATION_SHADER 0x8E87 +#endif + +// Define unsupported texture filtering modes +#ifndef GL_CLAMP_TO_BORDER +# define GL_CLAMP_TO_BORDER 0 +#endif + +#ifndef GL_MIRROR_CLAMP_TO_EDGE +# define GL_MIRROR_CLAMP_TO_EDGE 0 +#endif + +// Define unsupported bind points +#ifndef GL_ARB_draw_indirect +# define GL_ARB_draw_indirect 1 +#endif + +#ifndef GL_DRAW_INDIRECT_BUFFER +# define GL_DRAW_INDIRECT_BUFFER 0x8F3F +#endif + +#ifndef GL_DISPATCH_INDIRECT_BUFFER +# define GL_DISPATCH_INDIRECT_BUFFER 0x90EE +#endif + +#ifndef GL_TEXTURE_1D_ARRAY +# define GL_TEXTURE_1D_ARRAY 0x8C18 +#endif + +#ifndef GL_TEXTURE_BINDING_1D_ARRAY +# define GL_TEXTURE_BINDING_1D_ARRAY 0x8C1C +#endif + +#ifndef GL_TEXTURE_1D +# define GL_TEXTURE_1D 0x0DE0 +#endif + +#ifndef GL_TEXTURE_BINDING_1D +# define GL_TEXTURE_BINDING_1D 0x8068 +#endif + +#ifndef GL_ARB_texture_storage_multisample +# define GL_ARB_texture_storage_multisample 1 +#endif + +#ifndef GL_TEXTURE_2D_MULTISAMPLE +# define GL_TEXTURE_2D_MULTISAMPLE 0x9100 +#endif + +#ifndef GL_TEXTURE_BINDING_2D_MULTISAMPLE +# define GL_TEXTURE_BINDING_2D_MULTISAMPLE 0x9104 +#endif + +#ifndef GL_TEXTURE_2D_MULTISAMPLE_ARRAY +# define GL_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9102 +#endif + +#ifndef GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY +# define GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY 0x9105 +#endif + +#ifndef GL_TEXTURE_CUBE_MAP_ARRAY +# define GL_TEXTURE_CUBE_MAP_ARRAY 0x9009 +#endif + +#ifndef GL_TEXTURE_BINDING_CUBE_MAP_ARRAY +# define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY 0x900A +#endif + +#ifndef GL_TEXTURE_BUFFER +# define GL_TEXTURE_BUFFER 0x8C2A +#endif + +// Define unsupported pipeline bind flags +#ifndef GL_VERTEX_SHADER_BIT +# define GL_VERTEX_SHADER_BIT 0x00000001 +#endif + +#ifndef GL_FRAGMENT_SHADER_BIT +# define GL_FRAGMENT_SHADER_BIT 0x00000002 +#endif + +#ifndef GL_GEOMETRY_SHADER_BIT +# define GL_GEOMETRY_SHADER_BIT 0x00000004 +#endif + +#ifndef GL_TESS_CONTROL_SHADER_BIT +# define GL_TESS_CONTROL_SHADER_BIT 0x00000008 +#endif + +#ifndef GL_TESS_EVALUATION_SHADER_BIT +# define GL_TESS_EVALUATION_SHADER_BIT 0x00000010 +#endif + +#ifndef GL_COMPUTE_SHADER_BIT +# define GL_COMPUTE_SHADER_BIT 0x00000020 +#endif + +// Define unsupported sampler attributes +#ifndef GL_TEXTURE_LOD_BIAS +# define GL_TEXTURE_LOD_BIAS 0 +#endif + +#ifndef GL_TEXTURE_MAX_ANISOTROPY_EXT +# define GL_TEXTURE_MAX_ANISOTROPY_EXT 0 +#endif + +#ifndef GL_TEXTURE_BORDER_COLOR +# define GL_TEXTURE_BORDER_COLOR 0 +#endif + +// Other unsupported attributes +#ifndef GL_PROGRAM_SEPARABLE +# define GL_PROGRAM_SEPARABLE 0x8258 +#endif + +// Define unsupported uniform data types +#ifndef GL_SAMPLER_1D + #define GL_SAMPLER_1D 0x8B5D +#endif + +#ifndef GL_SAMPLER_1D_SHADOW + #define GL_SAMPLER_1D_SHADOW 0x8B61 +#endif + +#ifndef GL_SAMPLER_1D_ARRAY + #define GL_SAMPLER_1D_ARRAY 0x8DC0 +#endif + +#ifndef GL_SAMPLER_1D_ARRAY_SHADOW + #define GL_SAMPLER_1D_ARRAY_SHADOW 0x8DC3 +#endif + +#ifndef GL_INT_SAMPLER_1D + #define GL_INT_SAMPLER_1D 0x8DC9 +#endif + +#ifndef GL_INT_SAMPLER_1D_ARRAY + #define GL_INT_SAMPLER_1D_ARRAY 0x8DCE +#endif + +#ifndef GL_UNSIGNED_INT_SAMPLER_1D + #define GL_UNSIGNED_INT_SAMPLER_1D 0x8DD1 +#endif + +#ifndef GL_UNSIGNED_INT_SAMPLER_1D_ARRAY + #define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY 0x8DD6 +#endif + +#ifndef GL_SAMPLER_CUBE_MAP_ARRAY + #define GL_SAMPLER_CUBE_MAP_ARRAY 0x900C +#endif + +#ifndef GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW + #define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW 0x900D +#endif + +#ifndef GL_INT_SAMPLER_CUBE_MAP_ARRAY + #define GL_INT_SAMPLER_CUBE_MAP_ARRAY 0x900E +#endif + +#ifndef GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY + #define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY 0x900F +#endif + +#ifndef GL_SAMPLER_BUFFER + #define GL_SAMPLER_BUFFER 0x8DC2 +#endif + +#ifndef GL_INT_SAMPLER_BUFFER + #define GL_INT_SAMPLER_BUFFER 0x8DD0 +#endif + +#ifndef GL_UNSIGNED_INT_SAMPLER_BUFFER + #define GL_UNSIGNED_INT_SAMPLER_BUFFER 0x8DD8 +#endif + +#ifndef GL_SAMPLER_2D_MULTISAMPLE + #define GL_SAMPLER_2D_MULTISAMPLE 0x9108 +#endif + +#ifndef GL_INT_SAMPLER_2D_MULTISAMPLE + #define GL_INT_SAMPLER_2D_MULTISAMPLE 0x9109 +#endif + +#ifndef GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE + #define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE 0x910A +#endif + +#ifndef GL_SAMPLER_2D_MULTISAMPLE_ARRAY + #define GL_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910B +#endif + +#ifndef GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY + #define GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910C +#endif + +#ifndef GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY + #define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910D +#endif + + +#ifndef GL_IMAGE_1D + #define GL_IMAGE_1D 0x904C +#endif + +#ifndef GL_IMAGE_2D + #define GL_IMAGE_2D 0x904D +#endif + +#ifndef GL_IMAGE_3D + #define GL_IMAGE_3D 0x904E +#endif + +#ifndef GL_IMAGE_2D_RECT + #define GL_IMAGE_2D_RECT 0x904F +#endif + +#ifndef GL_IMAGE_CUBE + #define GL_IMAGE_CUBE 0x9050 +#endif + +#ifndef GL_IMAGE_BUFFER + #define GL_IMAGE_BUFFER 0x9051 +#endif + +#ifndef GL_IMAGE_1D_ARRAY + #define GL_IMAGE_1D_ARRAY 0x9052 +#endif + +#ifndef GL_IMAGE_2D_ARRAY + #define GL_IMAGE_2D_ARRAY 0x9053 +#endif + +#ifndef GL_IMAGE_CUBE_MAP_ARRAY + #define GL_IMAGE_CUBE_MAP_ARRAY 0x9054 +#endif + +#ifndef GL_IMAGE_2D_MULTISAMPLE + #define GL_IMAGE_2D_MULTISAMPLE 0x9055 +#endif + +#ifndef GL_IMAGE_2D_MULTISAMPLE_ARRAY + #define GL_IMAGE_2D_MULTISAMPLE_ARRAY 0x9056 +#endif + +#ifndef GL_INT_IMAGE_1D + #define GL_INT_IMAGE_1D 0x9057 +#endif + +#ifndef GL_INT_IMAGE_2D + #define GL_INT_IMAGE_2D 0x9058 +#endif + +#ifndef GL_INT_IMAGE_3D + #define GL_INT_IMAGE_3D 0x9059 +#endif + +#ifndef GL_INT_IMAGE_2D_RECT + #define GL_INT_IMAGE_2D_RECT 0x905A +#endif + +#ifndef GL_INT_IMAGE_CUBE + #define GL_INT_IMAGE_CUBE 0x905B +#endif + +#ifndef GL_INT_IMAGE_BUFFER + #define GL_INT_IMAGE_BUFFER 0x905C +#endif + +#ifndef GL_INT_IMAGE_1D_ARRAY + #define GL_INT_IMAGE_1D_ARRAY 0x905D +#endif + +#ifndef GL_INT_IMAGE_2D_ARRAY + #define GL_INT_IMAGE_2D_ARRAY 0x905E +#endif + +#ifndef GL_INT_IMAGE_CUBE_MAP_ARRAY + #define GL_INT_IMAGE_CUBE_MAP_ARRAY 0x905F +#endif + +#ifndef GL_INT_IMAGE_2D_MULTISAMPLE + #define GL_INT_IMAGE_2D_MULTISAMPLE 0x9060 +#endif + +#ifndef GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY + #define GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY 0x9061 +#endif + +#ifndef GL_UNSIGNED_INT_IMAGE_1D + #define GL_UNSIGNED_INT_IMAGE_1D 0x9062 +#endif + +#ifndef GL_UNSIGNED_INT_IMAGE_2D + #define GL_UNSIGNED_INT_IMAGE_2D 0x9063 +#endif + +#ifndef GL_UNSIGNED_INT_IMAGE_3D + #define GL_UNSIGNED_INT_IMAGE_3D 0x9064 +#endif + +#ifndef GL_UNSIGNED_INT_IMAGE_2D_RECT + #define GL_UNSIGNED_INT_IMAGE_2D_RECT 0x9065 +#endif + +#ifndef GL_UNSIGNED_INT_IMAGE_CUBE + #define GL_UNSIGNED_INT_IMAGE_CUBE 0x9066 +#endif + +#ifndef GL_UNSIGNED_INT_IMAGE_BUFFER + #define GL_UNSIGNED_INT_IMAGE_BUFFER 0x9067 +#endif + +#ifndef GL_UNSIGNED_INT_IMAGE_1D_ARRAY + #define GL_UNSIGNED_INT_IMAGE_1D_ARRAY 0x9068 +#endif + +#ifndef GL_UNSIGNED_INT_IMAGE_2D_ARRAY + #define GL_UNSIGNED_INT_IMAGE_2D_ARRAY 0x9069 +#endif + +#ifndef GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY + #define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY 0x906A +#endif + +#ifndef GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE + #define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE 0x906B +#endif + +#ifndef GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY + #define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY 0x906C +#endif + + +// Compute shader stubs +#ifndef GL_ARB_compute_shader +# define GL_ARB_compute_shader 1 +#endif + +#ifndef GL_READ_ONLY +# define GL_READ_ONLY 0x88B8 +#endif + +#ifndef GL_WRITE_ONLY +# define GL_WRITE_ONLY 0x88B9 +#endif + +#ifndef GL_READ_WRITE +# define GL_READ_WRITE 0x88BA +#endif + +#ifndef GL_COMPUTE_SHADER +# define GL_COMPUTE_SHADER 0x91B9 +#endif + +#ifndef GL_ES_VERSION_3_1 +#define LOAD_GL_BIND_IMAGE_TEXTURE +typedef void (GL_APIENTRY* PFNGLBINDIMAGETEXTUREPROC) (GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format); +extern PFNGLBINDIMAGETEXTUREPROC glBindImageTexture; + +#define LOAD_GL_DISPATCH_COMPUTE +typedef void (GL_APIENTRY* PFNGLDISPATCHCOMPUTEPROC) (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z); +extern PFNGLDISPATCHCOMPUTEPROC glDispatchCompute; + +#define LOAD_GL_MEMORY_BARRIER +typedef void (GL_APIENTRY* PFNGLMEMORYBARRIERPROC) (GLbitfield barriers); +extern PFNGLMEMORYBARRIERPROC glMemoryBarrier; +#endif // GL_ES_VERSION_3_1 + +#ifndef GL_ARB_shader_image_load_store +# define GL_ARB_shader_image_load_store 1 +#endif + +#ifndef GL_ARB_shader_storage_buffer_object +# define GL_ARB_shader_storage_buffer_object 1 +#endif + +#ifndef GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT +# define GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT 0x00000001 +#endif +#ifndef GL_ELEMENT_ARRAY_BARRIER_BIT +# define GL_ELEMENT_ARRAY_BARRIER_BIT 0x00000002 +#endif +#ifndef GL_UNIFORM_BARRIER_BIT +# define GL_UNIFORM_BARRIER_BIT 0x00000004 +#endif +#ifndef GL_TEXTURE_FETCH_BARRIER_BIT +# define GL_TEXTURE_FETCH_BARRIER_BIT 0x00000008 +#endif +#ifndef GL_SHADER_IMAGE_ACCESS_BARRIER_BIT +# define GL_SHADER_IMAGE_ACCESS_BARRIER_BIT 0x00000020 +#endif +#ifndef GL_COMMAND_BARRIER_BIT +# define GL_COMMAND_BARRIER_BIT 0x00000040 +#endif +#ifndef GL_PIXEL_BUFFER_BARRIER_BIT +# define GL_PIXEL_BUFFER_BARRIER_BIT 0x00000080 +#endif +#ifndef GL_TEXTURE_UPDATE_BARRIER_BIT +# define GL_TEXTURE_UPDATE_BARRIER_BIT 0x00000100 +#endif +#ifndef GL_BUFFER_UPDATE_BARRIER_BIT +# define GL_BUFFER_UPDATE_BARRIER_BIT 0x00000200 +#endif +#ifndef GL_FRAMEBUFFER_BARRIER_BIT +# define GL_FRAMEBUFFER_BARRIER_BIT 0x00000400 +#endif +#ifndef GL_TRANSFORM_FEEDBACK_BARRIER_BIT +# define GL_TRANSFORM_FEEDBACK_BARRIER_BIT 0x00000800 +#endif +#ifndef GL_ATOMIC_COUNTER_BARRIER_BIT +# define GL_ATOMIC_COUNTER_BARRIER_BIT 0x00001000 +#endif +#ifndef GL_SHADER_STORAGE_BARRIER_BIT +# define GL_SHADER_STORAGE_BARRIER_BIT 0x00002000 +#endif +#ifndef GL_CLIENT_MAPPED_BUFFER_BARRIER_BIT +# define GL_CLIENT_MAPPED_BUFFER_BARRIER_BIT 0x00004000 +#endif +#ifndef GL_QUERY_BUFFER_BARRIER_BIT +# define GL_QUERY_BUFFER_BARRIER_BIT 0x00008000 +#endif +#ifndef GL_ALL_BARRIER_BITS +# define GL_ALL_BARRIER_BITS 0xFFFFFFFF +#endif + + +//--------------------------- Texture queries ----------------------------- +#ifndef GL_TEXTURE_WIDTH +# define GL_TEXTURE_WIDTH 0x1000 +#endif + +#ifndef GL_TEXTURE_HEIGHT +# define GL_TEXTURE_HEIGHT 0x1001 +#endif + +#ifndef GL_TEXTURE_DEPTH +# define GL_TEXTURE_DEPTH 0x8071 +#endif + +#ifndef GL_TEXTURE_INTERNAL_FORMAT +# define GL_TEXTURE_INTERNAL_FORMAT 0x1003 +#endif + + +//------------------------ Program interface query ------------------------ +#ifndef GL_UNIFORM +# define GL_UNIFORM 0x92E1 +#endif + +#ifndef GL_UNIFORM_BLOCK +# define GL_UNIFORM_BLOCK 0x92E2 +#endif + +#ifndef GL_PROGRAM_INPUT +# define GL_PROGRAM_INPUT 0x92E3 +#endif + +#ifndef GL_PROGRAM_OUTPUT +# define GL_PROGRAM_OUTPUT 0x92E4 +#endif + +#ifndef GL_BUFFER_VARIABLE +# define GL_BUFFER_VARIABLE 0x92E5 +#endif + +#ifndef GL_ARB_program_interface_query +# define GL_ARB_program_interface_query 1 +#endif + +#ifndef GL_SHADER_STORAGE_BLOCK +# define GL_SHADER_STORAGE_BLOCK 0x92E6 +#endif + +#ifndef GL_IS_PER_PATCH +# define GL_IS_PER_PATCH 0x92E7 +#endif + +#ifndef GL_VERTEX_SUBROUTINE +# define GL_VERTEX_SUBROUTINE 0x92E8 +#endif + +#ifndef GL_TESS_CONTROL_SUBROUTINE +# define GL_TESS_CONTROL_SUBROUTINE 0x92E9 +#endif + +#ifndef GL_TESS_EVALUATION_SUBROUTINE +# define GL_TESS_EVALUATION_SUBROUTINE 0x92EA +#endif + +#ifndef GL_GEOMETRY_SUBROUTINE +# define GL_GEOMETRY_SUBROUTINE 0x92EB +#endif + +#ifndef GL_FRAGMENT_SUBROUTINE +# define GL_FRAGMENT_SUBROUTINE 0x92EC +#endif + +#ifndef GL_COMPUTE_SUBROUTINE +# define GL_COMPUTE_SUBROUTINE 0x92ED +#endif + +#ifndef GL_VERTEX_SUBROUTINE_UNIFORM +# define GL_VERTEX_SUBROUTINE_UNIFORM 0x92EE +#endif + +#ifndef GL_TESS_CONTROL_SUBROUTINE_UNIFORM +# define GL_TESS_CONTROL_SUBROUTINE_UNIFORM 0x92EF +#endif + +#ifndef GL_TESS_EVALUATION_SUBROUTINE_UNIFORM +# define GL_TESS_EVALUATION_SUBROUTINE_UNIFORM 0x92F0 +#endif + +#ifndef GL_GEOMETRY_SUBROUTINE_UNIFORM +# define GL_GEOMETRY_SUBROUTINE_UNIFORM 0x92F1 +#endif + +#ifndef GL_FRAGMENT_SUBROUTINE_UNIFORM +# define GL_FRAGMENT_SUBROUTINE_UNIFORM 0x92F2 +#endif + +#ifndef GL_COMPUTE_SUBROUTINE_UNIFORM +# define GL_COMPUTE_SUBROUTINE_UNIFORM 0x92F3 +#endif + +#ifndef GL_TRANSFORM_FEEDBACK_VARYING +# define GL_TRANSFORM_FEEDBACK_VARYING 0x92F4 +#endif + +#ifndef GL_ACTIVE_RESOURCES +# define GL_ACTIVE_RESOURCES 0x92F5 +#endif + +#ifndef GL_MAX_NAME_LENGTH +# define GL_MAX_NAME_LENGTH 0x92F6 +#endif + +#ifndef GL_MAX_NUM_ACTIVE_VARIABLES +# define GL_MAX_NUM_ACTIVE_VARIABLES 0x92F7 +#endif + +#ifndef GL_MAX_NUM_COMPATIBLE_SUBROUTINES +# define GL_MAX_NUM_COMPATIBLE_SUBROUTINES 0x92F8 +#endif + +#ifndef GL_NAME_LENGTH +# define GL_NAME_LENGTH 0x92F9 +#endif + +#ifndef GL_TYPE +# define GL_TYPE 0x92FA +#endif + +#ifndef GL_ARRAY_SIZE +# define GL_ARRAY_SIZE 0x92FB +#endif + +#ifndef GL_OFFSET +# define GL_OFFSET 0x92FC +#endif + +#ifndef GL_BLOCK_INDEX +# define GL_BLOCK_INDEX 0x92FD +#endif + +#ifndef GL_ARRAY_STRIDE +# define GL_ARRAY_STRIDE 0x92FE +#endif + +#ifndef GL_MATRIX_STRIDE +# define GL_MATRIX_STRIDE 0x92FF +#endif + +#ifndef GL_IS_ROW_MAJOR +# define GL_IS_ROW_MAJOR 0x9300 +#endif + +#ifndef GL_ATOMIC_COUNTER_BUFFER_INDEX +# define GL_ATOMIC_COUNTER_BUFFER_INDEX 0x9301 +#endif + +#ifndef GL_BUFFER_BINDING +# define GL_BUFFER_BINDING 0x9302 +#endif + +#ifndef GL_BUFFER_DATA_SIZE +# define GL_BUFFER_DATA_SIZE 0x9303 +#endif + +#ifndef GL_NUM_ACTIVE_VARIABLES +# define GL_NUM_ACTIVE_VARIABLES 0x9304 +#endif + +#ifndef GL_ACTIVE_VARIABLES +# define GL_ACTIVE_VARIABLES 0x9305 +#endif + +#ifndef GL_REFERENCED_BY_VERTEX_SHADER +# define GL_REFERENCED_BY_VERTEX_SHADER 0x9306 +#endif + +#ifndef GL_REFERENCED_BY_TESS_CONTROL_SHADER +# define GL_REFERENCED_BY_TESS_CONTROL_SHADER 0x9307 +#endif + +#ifndef GL_REFERENCED_BY_TESS_EVALUATION_SHADER +# define GL_REFERENCED_BY_TESS_EVALUATION_SHADER 0x9308 +#endif + +#ifndef GL_REFERENCED_BY_GEOMETRY_SHADER +# define GL_REFERENCED_BY_GEOMETRY_SHADER 0x9309 +#endif + +#ifndef GL_REFERENCED_BY_FRAGMENT_SHADER +# define GL_REFERENCED_BY_FRAGMENT_SHADER 0x930A +#endif + +#ifndef GL_REFERENCED_BY_COMPUTE_SHADER +# define GL_REFERENCED_BY_COMPUTE_SHADER 0x930B +#endif + +#ifndef GL_TOP_LEVEL_ARRAY_SIZE +# define GL_TOP_LEVEL_ARRAY_SIZE 0x930C +#endif + +#ifndef GL_TOP_LEVEL_ARRAY_STRIDE +# define GL_TOP_LEVEL_ARRAY_STRIDE 0x930D +#endif + +#ifndef GL_LOCATION +# define GL_LOCATION 0x930E +#endif + +#ifndef GL_LOCATION_INDEX +# define GL_LOCATION_INDEX 0x930F +#endif + + + +// --------------------- Shader storage buffer ----------------------- + +#ifndef GL_MAX_COMBINED_SHADER_OUTPUT_RESOURCES +# define GL_MAX_COMBINED_SHADER_OUTPUT_RESOURCES 0x8F39 +#endif + +#ifndef GL_SHADER_STORAGE_BUFFER +# define GL_SHADER_STORAGE_BUFFER 0x90D2 +#endif + +#ifndef GL_SHADER_STORAGE_BUFFER_BINDING +# define GL_SHADER_STORAGE_BUFFER_BINDING 0x90D3 +#endif + +#ifndef GL_SHADER_STORAGE_BUFFER_START +# define GL_SHADER_STORAGE_BUFFER_START 0x90D4 +#endif + +#ifndef GL_SHADER_STORAGE_BUFFER_SIZE +# define GL_SHADER_STORAGE_BUFFER_SIZE 0x90D5 +#endif + +#ifndef GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS +# define GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS 0x90D6 +#endif + +#ifndef GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS +# define GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS 0x90D7 +#endif + +#ifndef GL_MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS +# define GL_MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS 0x90D8 +#endif + +#ifndef GL_MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS +# define GL_MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS 0x90D9 +#endif + +#ifndef GL_MAX_FRAGMENT_SHADER_STORAGE_BLOCKS +# define GL_MAX_FRAGMENT_SHADER_STORAGE_BLOCKS 0x90DA +#endif + +#ifndef GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS +# define GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS 0x90DB +#endif + +#ifndef GL_MAX_COMBINED_SHADER_STORAGE_BLOCKS +# define GL_MAX_COMBINED_SHADER_STORAGE_BLOCKS 0x90DC +#endif + +#ifndef GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS +# define GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS 0x90DD +#endif + +#ifndef GL_MAX_SHADER_STORAGE_BLOCK_SIZE +# define GL_MAX_SHADER_STORAGE_BLOCK_SIZE 0x90DE +#endif + +#ifndef GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT +# define GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT 0x90DF +#endif + + +// Polygon mode +#ifndef GL_POINT +# define GL_POINT 0x1B00 +#endif + +#ifndef GL_LINE +# define GL_LINE 0x1B01 +#endif + +#ifndef GL_FILL +# define GL_FILL 0x1B02 +#endif + + +#ifndef GL_DEPTH_CLAMP +# define GL_DEPTH_CLAMP 0 +#endif + +// Blend functions +#ifndef GL_SRC1_COLOR +# define GL_SRC1_COLOR 0x88F9 +#endif + +#ifndef GL_ONE_MINUS_SRC1_COLOR +# define GL_ONE_MINUS_SRC1_COLOR 0x88FA +#endif + +#ifndef GL_SOURCE1_ALPHA +# define GL_SOURCE1_ALPHA 0x8589 +#endif + +#ifndef GL_SRC1_ALPHA +# define GL_SRC1_ALPHA GL_SOURCE1_ALPHA +#endif + +#ifndef GL_ONE_MINUS_SRC1_ALPHA +# define GL_ONE_MINUS_SRC1_ALPHA 0x88FB +#endif + +/* ---------------------- GL_ARB_internalformat_query2 --------------------- */ +#ifndef GL_ARB_internalformat_query2 +# define GL_ARB_internalformat_query2 1 +#endif + +#ifndef GL_INTERNALFORMAT_SUPPORTED +# define GL_INTERNALFORMAT_SUPPORTED 0x826F +#endif + +// --------------------- Framebuffer SRGB ----------------------- +#ifndef GL_FRAMEBUFFER_SRGB +# define GL_FRAMEBUFFER_SRGB 0x8DB9 +#endif + +// -------------------- Incomplete FBO error codes --------------- +#ifndef GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS +# define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS 0x8DA8 +#endif + +#ifndef GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER +# define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER 0x8CDB +#endif + +#ifndef GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER +# define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER 0x8CDC +#endif + +/* ---------------------- ARB_tessellation_shader --------------------- */ +#ifndef GL_ARB_tessellation_shader +# define GL_ARB_tessellation_shader 1 +#endif + +#ifndef GL_PATCHES +# define GL_PATCHES 0xE +#endif + +#ifndef GL_PATCH_VERTICES +# define GL_PATCH_VERTICES 0x8E72 +#endif + + +// Define unsupported GL function stubs +template +void UnsupportedGLFunctionStub( const T &Name ) +{ + LOG_ERROR_MESSAGE( Name, "() is not supported in this API!\n" ); +} + +#define glDrawElementsInstancedBaseVertexBaseInstance(...) UnsupportedGLFunctionStub("glDrawElementsInstancedBaseVertexBaseInstance") +#define glDrawElementsInstancedBaseVertex(...) UnsupportedGLFunctionStub("glDrawElementsInstancedBaseVertex") +#define glDrawElementsInstancedBaseInstance(...) UnsupportedGLFunctionStub("glDrawElementsInstancedBaseInstance") +#define glDrawArraysInstancedBaseInstance(...) UnsupportedGLFunctionStub("glDrawArraysInstancedBaseInstance") +#define glDrawElementsBaseVertex(...) UnsupportedGLFunctionStub("glDrawElementsBaseVertex") +#define glTextureView(...) UnsupportedGLFunctionStub("glTextureView") +#define glTexStorage1D(...) UnsupportedGLFunctionStub("glTexStorage1D") +#define glTexSubImage1D(...) UnsupportedGLFunctionStub("glTexSubImage1D") +#define glTexStorage3DMultisample(...) UnsupportedGLFunctionStub("glTexStorage3DMultisample") + +#ifndef GL_ES_VERSION_3_1 + + #define LOAD_GEN_PROGRAM_PIPELINES + typedef void (GL_APIENTRY* PFNGLGENPROGRAMPIPELINESPROC) (GLsizei n, GLuint* pipelines); + extern PFNGLGENPROGRAMPIPELINESPROC glGenProgramPipelines; + + #define LOAD_GL_DELETE_PROGRAM_PIPELINES + typedef void (GL_APIENTRY* PFNGLDELETEPROGRAMPIPELINESPROC) (GLsizei n, const GLuint* pipelines); + extern PFNGLDELETEPROGRAMPIPELINESPROC glDeleteProgramPipelines; + + #define LOAD_GL_BIND_PROGRAM_PIPELINE + typedef void (GL_APIENTRY* PFNGLBINDPROGRAMPIPELINEPROC) (GLuint pipeline); + extern PFNGLBINDPROGRAMPIPELINEPROC glBindProgramPipeline; + + #define LOAD_DRAW_ELEMENTS_INDIRECT + typedef void (GL_APIENTRY* PFNGLDRAWELEMENTSINDIRECTPROC) (GLenum mode, GLenum type, const GLvoid *indirect); + extern PFNGLDRAWELEMENTSINDIRECTPROC glDrawElementsIndirect; + + #define LOAD_DRAW_ARRAYS_INDIRECT + typedef void (GL_APIENTRY* PFNGLDRAWARRAYSINDIRECTPROC)( GLenum mode, const GLvoid *indirect ); + extern PFNGLDRAWARRAYSINDIRECTPROC glDrawArraysIndirect; + + #define LOAD_DISPATCH_COMPUTE_INDIRECT + typedef void (GL_APIENTRY* PFNGLDISPATCHCOMPUTEINDIRECTPROC) (GLintptr indirect); + extern PFNGLDISPATCHCOMPUTEINDIRECTPROC glDispatchComputeIndirect; + + #define LOAD_GL_USE_PROGRAM_STAGES + typedef void (GL_APIENTRY* PFNGLUSEPROGRAMSTAGESPROC) (GLuint pipeline, GLbitfield stages, GLuint program); + extern PFNGLUSEPROGRAMSTAGESPROC glUseProgramStages; + + #define LOAD_GL_TEX_STORAGE_2D_MULTISAMPLE + typedef void (GL_APIENTRY* PFNGLTEXSTORAGE2DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); + extern PFNGLTEXSTORAGE2DMULTISAMPLEPROC glTexStorage2DMultisample; + + #define LOAD_GL_PROGRAM_UNIFORM_1I + typedef void (GL_APIENTRY* PFNGLPROGRAMUNIFORM1IPROC) (GLuint program, GLint location, GLint x); + extern PFNGLPROGRAMUNIFORM1IPROC glProgramUniform1i; + + #define LOAD_GL_GET_PROGRAM_INTERFACEIV + typedef void (GL_APIENTRY* PFNGLGETPROGRAMINTERFACEIVPROC) (GLuint program, GLenum programInterface, GLenum pname, GLint* params); + extern PFNGLGETPROGRAMINTERFACEIVPROC glGetProgramInterfaceiv; + + #define LOAD_GL_GET_PROGRAM_RESOURCE_NAME + typedef void (GL_APIENTRY* PFNGLGETPROGRAMRESOURCENAMEPROC) (GLuint program, GLenum programInterface, GLuint index, GLsizei bufSize, GLsizei* length, GLchar *name); + extern PFNGLGETPROGRAMRESOURCENAMEPROC glGetProgramResourceName; + + #define LOAD_GL_GET_PROGRAM_RESOURCEIV + typedef void (GL_APIENTRY* PFNGLGETPROGRAMRESOURCEIVPROC) (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum* props, GLsizei bufSize, GLsizei *length, GLint *params); + extern PFNGLGETPROGRAMRESOURCEIVPROC glGetProgramResourceiv; + + #define LOAD_GET_TEX_LEVEL_PARAMETER_IV + typedef void (GL_APIENTRY* PFNGLGETTEXLEVELPARAMETERIVPROC) (GLenum target, GLint level, GLenum pname, GLint *params); + extern PFNGLGETTEXLEVELPARAMETERIVPROC glGetTexLevelParameteriv; + +#endif //GL_ES_VERSION_3_1 + +#define LOAD_GL_TEX_BUFFER +typedef void (GL_APIENTRY* PFNGLTEXBUFFERPROC) (GLenum, GLenum, GLuint); +extern PFNGLTEXBUFFERPROC glTexBuffer; + +#define LOAD_GL_VIEWPORT_INDEXEDF +typedef void (GL_APIENTRY* PFNGLVIEWPORTINDEXEDFPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h); +extern PFNGLVIEWPORTINDEXEDFPROC glViewportIndexedf; + +#define LOAD_GL_SCISSOR_INDEXED +typedef void (GL_APIENTRY* PFNGLSCISSORINDEXEDPROC) (GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height); +extern PFNGLSCISSORINDEXEDPROC glScissorIndexed; + +#define LOAD_GL_POLYGON_MODE +typedef void (GL_APIENTRY* PFNGLPOLYGONMODE) (GLenum face, GLenum mode); +extern PFNGLPOLYGONMODE glPolygonMode; + +#define LOAD_GL_ENABLEI +typedef void (GL_APIENTRY* PFNGLENABLEIPROC) (GLenum, GLuint); +extern PFNGLENABLEIPROC glEnablei; + +#define LOAD_GL_BLEND_FUNC_SEPARATEI +typedef void (GL_APIENTRY* PFNGLBLENDFUNCSEPARATEIPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +extern PFNGLBLENDFUNCSEPARATEIPROC glBlendFuncSeparatei; + +#define LOAD_GL_BLEND_EQUATION_SEPARATEI +typedef void (GL_APIENTRY* PFNGLBLENDEQUATIONSEPARATEIPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +extern PFNGLBLENDEQUATIONSEPARATEIPROC glBlendEquationSeparatei; + +#define LOAD_GL_DISABLEI +typedef void (GL_APIENTRY* PFNGLDISABLEIPROC) (GLenum, GLuint); +extern PFNGLDISABLEIPROC glDisablei; + +#define LOAD_GL_COLOR_MASKI +typedef void (GL_APIENTRY* PFNGLCOLORMASKIPROC) (GLuint, GLboolean, GLboolean, GLboolean, GLboolean); +extern PFNGLCOLORMASKIPROC glColorMaski; + +#define LOAD_GL_PATCH_PARAMTER_I +typedef void (GL_APIENTRY* PFNGLPATCHPARAMETERIPROC) (GLenum pname, GLint value); +extern PFNGLPATCHPARAMETERIPROC glPatchParameteri; + +#define LOAD_GL_FRAMEBUFFER_TEXTURE +typedef void (GL_APIENTRY* PFNGLFRAMEBUFFERTEXTUREPROC) (GLenum, GLenum, GLuint, GLint); +extern PFNGLFRAMEBUFFERTEXTUREPROC glFramebufferTexture; + +#define LOAD_GL_FRAMEBUFFER_TEXTURE_1D +typedef void (GL_APIENTRY* PFNGLFRAMEBUFFERTEXTURE1DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +extern PFNGLFRAMEBUFFERTEXTURE1DPROC glFramebufferTexture1D; + +#define LOAD_GL_FRAMEBUFFER_TEXTURE_3D +typedef void (GL_APIENTRY* PFNGLFRAMEBUFFERTEXTURE3DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint layer); +extern PFNGLFRAMEBUFFERTEXTURE3DPROC glFramebufferTexture3D; + +#ifndef GL_ARB_copy_image +# define GL_ARB_copy_image 1 +#endif + +#define LOAD_GL_COPY_IMAGE_SUB_DATA +typedef void (GL_APIENTRY* PFNGLCOPYIMAGESUBDATAPROC) (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth); +extern PFNGLCOPYIMAGESUBDATAPROC glCopyImageSubData; + +void LoadGLFunctions(); diff --git a/Graphics/GraphicsEngineOpenGL/include/GLStubsIOS.h b/Graphics/GraphicsEngineOpenGL/include/GLStubsIOS.h new file mode 100644 index 00000000..7b5e0315 --- /dev/null +++ b/Graphics/GraphicsEngineOpenGL/include/GLStubsIOS.h @@ -0,0 +1,534 @@ +/* Copyright 2015-2018 Egor Yusov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * THE SOFTWARE IS 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent acts) or agreed to in writing, shall any Contributor be + * liable for any damages, including any direct, indirect, special, incidental, + * or consequential damages of any character arising as a result of this License or + * out of the use or inability to use the software (including but not limited to damages + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#pragma once + +#include "Errors.h" + +#define glUseProgramStages glUseProgramStagesEXT +#define glActiveShaderProgram glActiveShaderProgramEXT +#define glCreateShaderProgramv glCreateShaderProgramvEXT +#define glBindProgramPipeline glBindProgramPipelineEXT +#define glDeleteProgramPipelines glDeleteProgramPipelinesEXT +#define glGenProgramPipelines glGenProgramPipelinesEXT +#define glIsProgramPipeline glIsProgramPipelineEXT +#define glProgramParameteri glProgramParameteriEXT +#define glGetProgramPipelineiv glGetProgramPipelineivEXT +#define glValidateProgramPipeline glValidateProgramPipelineEXT +#define glGetProgramPipelineInfoLog glGetProgramPipelineInfoLogEXT +#define glProgramUniform1i glProgramUniform1iEXT + +#define GL_VERTEX_SHADER_BIT GL_VERTEX_SHADER_BIT_EXT +#define GL_FRAGMENT_SHADER_BIT GL_FRAGMENT_SHADER_BIT_EXT +#define GL_ALL_SHADER_BITS GL_ALL_SHADER_BITS_EXT +#define GL_PROGRAM_SEPARABLE GL_PROGRAM_SEPARABLE_EXT +#define GL_ACTIVE_PROGRAM GL_ACTIVE_PROGRAM_EXT +#define GL_PROGRAM_PIPELINE_BINDING GL_PROGRAM_PIPELINE_BINDING_EXT + +#define GL_ARB_shader_image_load_store 0 +#define GL_ARB_shader_storage_buffer_object 0 +#define GL_ARB_tessellation_shader 0 +#define GL_ARB_draw_indirect 0 +#define GL_ARB_compute_shader 0 +#define GL_ARB_program_interface_query 0 +#define GL_ARB_internalformat_query2 0 +#define GL_ARB_texture_storage_multisample 0 + +#ifndef GL_CLAMP_TO_BORDER +# define GL_CLAMP_TO_BORDER GL_CLAMP_TO_EDGE +#endif + +#ifndef GL_MIRROR_CLAMP_TO_EDGE +# define GL_MIRROR_CLAMP_TO_EDGE GL_CLAMP_TO_EDGE +#endif + +#ifndef GL_UNSIGNED_INT_10_10_10_2 +# define GL_UNSIGNED_INT_10_10_10_2 0x8036 +#endif + +#ifndef GL_UNSIGNED_SHORT_5_6_5_REV +# define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364 +#endif + +#ifndef GL_TEXTURE_BUFFER +# define GL_TEXTURE_BUFFER 0 +#endif + +#define glTexBuffer(...) 0 + +#ifndef GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER +# define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER 0x8CDB +#endif + +#ifndef GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER +# define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER 0x8CDC +#endif + +#ifndef GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS +# define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS 0x8DA8 +#endif + +#ifndef GL_DRAW_INDIRECT_BUFFER +# define GL_DRAW_INDIRECT_BUFFER 0 +#endif + +#ifndef GL_GEOMETRY_SHADER +# define GL_GEOMETRY_SHADER 0 +#endif + +#ifndef GL_TESS_CONTROL_SHADER +# define GL_TESS_CONTROL_SHADER 0 +#endif + +#ifndef GL_TESS_EVALUATION_SHADER +# define GL_TESS_EVALUATION_SHADER 0 +#endif + +#ifndef GL_COMPUTE_SHADER +# define GL_COMPUTE_SHADER 0 +#endif + +#ifndef GL_GEOMETRY_SHADER_BIT +# define GL_GEOMETRY_SHADER_BIT 0 +#endif + +#ifndef GL_TESS_CONTROL_SHADER_BIT +# define GL_TESS_CONTROL_SHADER_BIT 0 +#endif + +#ifndef GL_TESS_EVALUATION_SHADER_BIT +# define GL_TESS_EVALUATION_SHADER_BIT 0 +#endif + +#ifndef GL_COMPUTE_SHADER_BIT +# define GL_COMPUTE_SHADER_BIT 0 +#endif + +#ifndef GL_SAMPLER_BUFFER +# define GL_SAMPLER_BUFFER 0x8DC2 +#endif + +#ifndef GL_INT_SAMPLER_BUFFER +# define GL_INT_SAMPLER_BUFFER 0x8DD0 +#endif + +#ifndef GL_UNSIGNED_INT_SAMPLER_BUFFER +# define GL_UNSIGNED_INT_SAMPLER_BUFFER 0x8DD8 +#endif + +// Polygon mode +#ifndef GL_POINT +# define GL_POINT 0x1B00 +#endif + +#ifndef GL_LINE +# define GL_LINE 0x1B01 +#endif + +#ifndef GL_FILL +# define GL_FILL 0x1B02 +#endif + +#ifndef GL_DEPTH_CLAMP +# define GL_DEPTH_CLAMP 0 +#endif + + +// Define unsupported formats for OpenGL ES +#ifndef GL_RGBA16 +# define GL_RGBA16 0x805B +#endif + +#ifndef GL_RGBA16_SNORM +# define GL_RGBA16_SNORM 0x8F9B +#endif + +#ifndef GL_RG16 +# define GL_RG16 0x822C +#endif + +#ifndef GL_RG16_SNORM +# define GL_RG16_SNORM 0x8F99 +#endif + +#ifndef GL_R16 +# define GL_R16 0x822A +#endif + +#ifndef GL_R16_SNORM +# define GL_R16_SNORM 0x8F98 +#endif + +#ifndef GL_COMPRESSED_RGB_S3TC_DXT1_EXT +# define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0 +#endif + +#ifndef GL_COMPRESSED_SRGB_S3TC_DXT1_EXT +# define GL_COMPRESSED_SRGB_S3TC_DXT1_EXT 0x8C4C +#endif + +#ifndef GL_COMPRESSED_RGBA_S3TC_DXT3_EXT +# define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2 +#endif + +#ifndef GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT +# define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT 0x8C4E +#endif + +#ifndef GL_COMPRESSED_RGBA_S3TC_DXT5_EXT +# define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3 +#endif + +#ifndef GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT +# define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT 0x8C4F +#endif + +#ifndef GL_COMPRESSED_RED_RGTC1 +# define GL_COMPRESSED_RED_RGTC1 0x8DBB +#endif + +#ifndef GL_COMPRESSED_SIGNED_RED_RGTC1 +# define GL_COMPRESSED_SIGNED_RED_RGTC1 0x8DBC +#endif + +#ifndef GL_COMPRESSED_RG_RGTC2 +# define GL_COMPRESSED_RG_RGTC2 0x8DBD +#endif + +#ifndef GL_COMPRESSED_SIGNED_RG_RGTC2 +# define GL_COMPRESSED_SIGNED_RG_RGTC2 0x8DBE +#endif + +#ifndef GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT +# define GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT 0x8E8F +#endif + +#ifndef GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT +# define GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT 0x8E8E +#endif + +#ifndef GL_COMPRESSED_RGBA_BPTC_UNORM +# define GL_COMPRESSED_RGBA_BPTC_UNORM 0x8E8C +#endif + +#ifndef GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM +# define GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM 0x8E8D +#endif + +#ifndef GL_UNSIGNED_SHORT_5_6_5_REV +# define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364 +#endif + +#ifndef GL_UNSIGNED_INT_10_10_10_2 +# define GL_UNSIGNED_INT_10_10_10_2 0x8036 +#endif + +#ifndef GL_UNSIGNED_SHORT_5_6_5_REV +# define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364 +#endif + +#ifndef GL_UNSIGNED_SHORT_1_5_5_5_REV +# define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366 +#endif + + +// Define unsupported uniform data types +#ifndef GL_SAMPLER_1D +# define GL_SAMPLER_1D 0x8B5D +#endif + +#ifndef GL_SAMPLER_1D_SHADOW +# define GL_SAMPLER_1D_SHADOW 0x8B61 +#endif + +#ifndef GL_SAMPLER_1D_ARRAY +# define GL_SAMPLER_1D_ARRAY 0x8DC0 +#endif + +#ifndef GL_SAMPLER_1D_ARRAY_SHADOW +# define GL_SAMPLER_1D_ARRAY_SHADOW 0x8DC3 +#endif + +#ifndef GL_INT_SAMPLER_1D +# define GL_INT_SAMPLER_1D 0x8DC9 +#endif + +#ifndef GL_INT_SAMPLER_1D_ARRAY +# define GL_INT_SAMPLER_1D_ARRAY 0x8DCE +#endif + +#ifndef GL_UNSIGNED_INT_SAMPLER_1D +# define GL_UNSIGNED_INT_SAMPLER_1D 0x8DD1 +#endif + +#ifndef GL_UNSIGNED_INT_SAMPLER_1D_ARRAY +# define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY 0x8DD6 +#endif + +#ifndef GL_SAMPLER_CUBE_MAP_ARRAY +# define GL_SAMPLER_CUBE_MAP_ARRAY 0x900C +#endif + +#ifndef GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW +# define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW 0x900D +#endif + +#ifndef GL_INT_SAMPLER_CUBE_MAP_ARRAY +# define GL_INT_SAMPLER_CUBE_MAP_ARRAY 0x900E +#endif + +#ifndef GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY +# define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY 0x900F +#endif + +#ifndef GL_SAMPLER_BUFFER +# define GL_SAMPLER_BUFFER 0x8DC2 +#endif + +#ifndef GL_INT_SAMPLER_BUFFER +# define GL_INT_SAMPLER_BUFFER 0x8DD0 +#endif + +#ifndef GL_UNSIGNED_INT_SAMPLER_BUFFER +# define GL_UNSIGNED_INT_SAMPLER_BUFFER 0x8DD8 +#endif + +#ifndef GL_SAMPLER_2D_MULTISAMPLE +# define GL_SAMPLER_2D_MULTISAMPLE 0x9108 +#endif + +#ifndef GL_INT_SAMPLER_2D_MULTISAMPLE +# define GL_INT_SAMPLER_2D_MULTISAMPLE 0x9109 +#endif + +#ifndef GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE +# define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE 0x910A +#endif + +#ifndef GL_SAMPLER_2D_MULTISAMPLE_ARRAY +# define GL_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910B +#endif + +#ifndef GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY +# define GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910C +#endif + +#ifndef GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY +# define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910D +#endif + + +// Blend functions +#ifndef GL_SRC1_COLOR +# define GL_SRC1_COLOR 0x88F9 +#endif + +#ifndef GL_ONE_MINUS_SRC1_COLOR +# define GL_ONE_MINUS_SRC1_COLOR 0x88FA +#endif + +#ifndef GL_SOURCE1_ALPHA +# define GL_SOURCE1_ALPHA 0x8589 +#endif + +#ifndef GL_SRC1_ALPHA +# define GL_SRC1_ALPHA GL_SOURCE1_ALPHA +#endif + +#ifndef GL_ONE_MINUS_SRC1_ALPHA +# define GL_ONE_MINUS_SRC1_ALPHA 0x88FB +#endif + + +#ifndef GL_READ_ONLY +# define GL_READ_ONLY 0x88B8 +#endif + +#ifndef GL_WRITE_ONLY +# define GL_WRITE_ONLY 0x88B9 +#endif + +#ifndef GL_READ_WRITE +# define GL_READ_WRITE 0x88BA +#endif + + + +// Define unsupported sampler attributes +#ifndef GL_TEXTURE_LOD_BIAS +# define GL_TEXTURE_LOD_BIAS 0 +#endif + +#ifndef GL_TEXTURE_BORDER_COLOR +# define GL_TEXTURE_BORDER_COLOR 0 +#endif + + + + +#ifndef GL_TEXTURE_1D +# define GL_TEXTURE_1D 0x0DE0 +#endif + +#ifndef GL_TEXTURE_1D_ARRAY +# define GL_TEXTURE_1D_ARRAY 0x8C18 +#endif + +#ifndef GL_TEXTURE_BINDING_1D_ARRAY +# define GL_TEXTURE_BINDING_1D_ARRAY 0x8C1C +#endif + +#ifndef GL_TEXTURE_BINDING_1D +# define GL_TEXTURE_BINDING_1D 0x8068 +#endif + +#ifndef GL_TEXTURE_2D_MULTISAMPLE +# define GL_TEXTURE_2D_MULTISAMPLE 0x9100 +#endif + +#ifndef GL_TEXTURE_BINDING_2D_MULTISAMPLE +# define GL_TEXTURE_BINDING_2D_MULTISAMPLE 0x9104 +#endif + +#ifndef GL_TEXTURE_2D_MULTISAMPLE_ARRAY +# define GL_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9102 +#endif + +#ifndef GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY +# define GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY 0x9105 +#endif + +#ifndef GL_TEXTURE_CUBE_MAP_ARRAY +# define GL_TEXTURE_CUBE_MAP_ARRAY 0x9009 +#endif + +#ifndef GL_TEXTURE_BINDING_CUBE_MAP_ARRAY +# define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY 0x900A +#endif + +//#ifndef GL_TEXTURE_BUFFER +//# define GL_TEXTURE_BUFFER 0x8C2A +//#endif + + +#ifndef GL_TEXTURE_WIDTH +# define GL_TEXTURE_WIDTH 0 +#endif + +#ifndef GL_TEXTURE_HEIGHT +# define GL_TEXTURE_HEIGHT 0 +#endif + +#ifndef GL_TEXTURE_DEPTH +# define GL_TEXTURE_DEPTH 0 +#endif + +#ifndef GL_TEXTURE_INTERNAL_FORMAT +# define GL_TEXTURE_INTERNAL_FORMAT 0 +#endif + +#ifndef GL_TEXTURE_INTERNAL_FORMAT +# define GL_TEXTURE_INTERNAL_FORMAT 0 +#endif + + + + +#ifndef GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT +# define GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT 0x00000001 +#endif +#ifndef GL_ELEMENT_ARRAY_BARRIER_BIT +# define GL_ELEMENT_ARRAY_BARRIER_BIT 0x00000002 +#endif +#ifndef GL_UNIFORM_BARRIER_BIT +# define GL_UNIFORM_BARRIER_BIT 0x00000004 +#endif +#ifndef GL_TEXTURE_FETCH_BARRIER_BIT +# define GL_TEXTURE_FETCH_BARRIER_BIT 0x00000008 +#endif +#ifndef GL_SHADER_IMAGE_ACCESS_BARRIER_BIT +# define GL_SHADER_IMAGE_ACCESS_BARRIER_BIT 0x00000020 +#endif +#ifndef GL_COMMAND_BARRIER_BIT +# define GL_COMMAND_BARRIER_BIT 0x00000040 +#endif +#ifndef GL_PIXEL_BUFFER_BARRIER_BIT +# define GL_PIXEL_BUFFER_BARRIER_BIT 0x00000080 +#endif +#ifndef GL_TEXTURE_UPDATE_BARRIER_BIT +# define GL_TEXTURE_UPDATE_BARRIER_BIT 0x00000100 +#endif +#ifndef GL_BUFFER_UPDATE_BARRIER_BIT +# define GL_BUFFER_UPDATE_BARRIER_BIT 0x00000200 +#endif +#ifndef GL_FRAMEBUFFER_BARRIER_BIT +# define GL_FRAMEBUFFER_BARRIER_BIT 0x00000400 +#endif +#ifndef GL_TRANSFORM_FEEDBACK_BARRIER_BIT +# define GL_TRANSFORM_FEEDBACK_BARRIER_BIT 0x00000800 +#endif +#ifndef GL_ATOMIC_COUNTER_BARRIER_BIT +# define GL_ATOMIC_COUNTER_BARRIER_BIT 0x00001000 +#endif +#ifndef GL_SHADER_STORAGE_BARRIER_BIT +# define GL_SHADER_STORAGE_BARRIER_BIT 0x00002000 +#endif +#ifndef GL_CLIENT_MAPPED_BUFFER_BARRIER_BIT +# define GL_CLIENT_MAPPED_BUFFER_BARRIER_BIT 0x00004000 +#endif +#ifndef GL_QUERY_BUFFER_BARRIER_BIT +# define GL_QUERY_BUFFER_BARRIER_BIT 0x00008000 +#endif +#ifndef GL_ALL_BARRIER_BITS +# define GL_ALL_BARRIER_BITS 0xFFFFFFFF +#endif + +// Define unsupported GL function stubs +template +void UnsupportedGLFunctionStub( const T &Name ) +{ + LOG_ERROR_MESSAGE( Name, "() is not supported in this API!\n" ); +} + +#define glDrawElementsInstancedBaseVertexBaseInstance(...) UnsupportedGLFunctionStub("glDrawElementsInstancedBaseVertexBaseInstance") +#define glDrawElementsInstancedBaseVertex(...) UnsupportedGLFunctionStub("glDrawElementsInstancedBaseVertex") +#define glDrawElementsInstancedBaseInstance(...) UnsupportedGLFunctionStub("glDrawElementsInstancedBaseInstance") +#define glDrawArraysInstancedBaseInstance(...) UnsupportedGLFunctionStub("glDrawArraysInstancedBaseInstance") +#define glDrawElementsBaseVertex(...) UnsupportedGLFunctionStub("glDrawElementsBaseVertex") +#define glTextureView(...) UnsupportedGLFunctionStub("glTextureView") +#define glTexStorage1D(...) UnsupportedGLFunctionStub("glTexStorage1D") +#define glTexSubImage1D(...) UnsupportedGLFunctionStub("glTexSubImage1D") +#define glTexStorage3DMultisample(...) UnsupportedGLFunctionStub("glTexStorage3DMultisample") +#define glViewportIndexedf(...) UnsupportedGLFunctionStub("glViewportIndexedf") +#define glScissorIndexed(...) UnsupportedGLFunctionStub("glScissorIndexed") +#define glPolygonMode(...) UnsupportedGLFunctionStub("glPolygonMode") +#define glEnablei(...) UnsupportedGLFunctionStub("glEnablei") +#define glBlendFuncSeparatei(...) UnsupportedGLFunctionStub("glBlendFuncSeparatei") +#define glBlendEquationSeparatei(...) UnsupportedGLFunctionStub("glBlendEquationSeparatei") +#define glDisablei(...) UnsupportedGLFunctionStub("eglDisablei") +#define glColorMaski(...) UnsupportedGLFunctionStub("glColorMaski") +#define glFramebufferTexture(...) UnsupportedGLFunctionStub("glFramebufferTexture") +#define glFramebufferTexture1D(...) UnsupportedGLFunctionStub("glFramebufferTexture1D") + + + diff --git a/Graphics/GraphicsEngineOpenGL/include/pch.h b/Graphics/GraphicsEngineOpenGL/include/pch.h index 77815ec8..5755e391 100644 --- a/Graphics/GraphicsEngineOpenGL/include/pch.h +++ b/Graphics/GraphicsEngineOpenGL/include/pch.h @@ -92,13 +92,19 @@ # define USE_GL3_STUB 0 # endif # if USE_GL3_STUB -# include "gl3stub.h" +# include "GLStubsAndroid.h" # include # else # include # include # endif +#elif defined(PLATFORM_IOS) + +# include +# include +# include "GLStubsIOS.h" + #else # error Unsupported platform #endif diff --git a/Graphics/GraphicsEngineOpenGL/interface/BaseInterfacesGL.h b/Graphics/GraphicsEngineOpenGL/interface/BaseInterfacesGL.h index 36ccd33b..a7c01ba8 100644 --- a/Graphics/GraphicsEngineOpenGL/interface/BaseInterfacesGL.h +++ b/Graphics/GraphicsEngineOpenGL/interface/BaseInterfacesGL.h @@ -35,6 +35,12 @@ { using IGLDeviceBaseInterface = IRenderDeviceGL; } +#elif defined(PLATFORM_IOS) + #include "RenderDeviceGL.h" + namespace Diligent + { + using IGLDeviceBaseInterface = IRenderDeviceGL; + } #else # error Unsupported platform #endif @@ -43,4 +49,4 @@ namespace Diligent { using IGLDeviceContextBaseInterface = IDeviceContextGL; -} \ No newline at end of file +} diff --git a/Graphics/GraphicsEngineOpenGL/interface/RenderDeviceFactoryOpenGL.h b/Graphics/GraphicsEngineOpenGL/interface/RenderDeviceFactoryOpenGL.h index a9c4891f..13e884b7 100644 --- a/Graphics/GraphicsEngineOpenGL/interface/RenderDeviceFactoryOpenGL.h +++ b/Graphics/GraphicsEngineOpenGL/interface/RenderDeviceFactoryOpenGL.h @@ -35,7 +35,7 @@ # define API_QUALIFIER -#elif defined(PLATFORM_ANDROID) || defined(PLATFORM_LINUX) || defined(PLATFORM_MACOS) +#elif defined(PLATFORM_ANDROID) || defined(PLATFORM_LINUX) || defined(PLATFORM_MACOS) || defined(PLATFORM_IOS) # ifdef ENGINE_DLL # ifdef BUILDING_DLL diff --git a/Graphics/GraphicsEngineOpenGL/src/BufferGLImpl.cpp b/Graphics/GraphicsEngineOpenGL/src/BufferGLImpl.cpp index 7f88eaed..390b99cd 100644 --- a/Graphics/GraphicsEngineOpenGL/src/BufferGLImpl.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/BufferGLImpl.cpp @@ -51,7 +51,10 @@ static GLenum GetBufferBindTarget(const BufferDesc& Desc) else if (Desc.BindFlags & BIND_UNIFORM_BUFFER) Target = GL_UNIFORM_BUFFER; else if(Desc.BindFlags & BIND_INDIRECT_DRAW_ARGS) + { + VERIFY(GL_DRAW_INDIRECT_BUFFER != 0, "Inidrect draw is not supported"); Target = GL_DRAW_INDIRECT_BUFFER; + } else if (Desc.Usage == USAGE_CPU_ACCESSIBLE && Desc.CPUAccessFlags == CPU_ACCESS_WRITE) Target = GL_PIXEL_UNPACK_BUFFER; @@ -178,8 +181,7 @@ void BufferGLImpl :: UpdateData(IDeviceContext *pContext, Uint32 Offset, Uint32 { TBufferBase::UpdateData( pContext, Offset, Size, pData ); - CHECK_DYNAMIC_TYPE( DeviceContextGLImpl, pContext ); - auto *pDeviceContextGL = static_cast(pContext); + auto *pDeviceContextGL = ValidatedCast(pContext); BufferMemoryBarrier( GL_BUFFER_UPDATE_BARRIER_BIT,// Reads or writes to buffer objects via any OpenGL API functions that allow @@ -201,18 +203,17 @@ void BufferGLImpl :: CopyData(IDeviceContext *pContext, IBuffer *pSrcBuffer, Uin { TBufferBase::CopyData( pContext, pSrcBuffer, SrcOffset, DstOffset, Size ); - CHECK_DYNAMIC_TYPE( DeviceContextGLImpl, pContext ); - auto *pDeviceContextGL = static_cast(pContext); - + auto *pDeviceContextGL = ValidatedCast(pContext); auto *pSrcBufferGL = static_cast( pSrcBuffer ); - BufferMemoryBarrier( GL_BUFFER_UPDATE_BARRIER_BIT,// Reads or writes to buffer objects via any OpenGL API functions that allow // modifying their contents will reflect data written by shaders prior to the barrier. // Additionally, writes via these commands issued after the barrier will wait on // the completion of any shader writes to the same memory initiated prior to the barrier. pDeviceContextGL->GetContextState()); - pSrcBufferGL->BufferMemoryBarrier( GL_BUFFER_UPDATE_BARRIER_BIT, pDeviceContextGL->GetContextState() ); + pSrcBufferGL->BufferMemoryBarrier( + GL_BUFFER_UPDATE_BARRIER_BIT, + pDeviceContextGL->GetContextState() ); // Whilst glCopyBufferSubData() can be used to copy data between buffers bound to any two targets, // the targets GL_COPY_READ_BUFFER and GL_COPY_WRITE_BUFFER are provided specifically for this purpose. @@ -232,14 +233,13 @@ void BufferGLImpl :: Map(IDeviceContext *pContext, MAP_TYPE MapType, Uint32 MapF TBufferBase::Map( pContext, MapType, MapFlags, pMappedData ); VERIFY( m_uiMapTarget == 0, "Buffer is already mapped"); - CHECK_DYNAMIC_TYPE( DeviceContextGLImpl, pContext ); - auto *pDeviceContextGL = static_cast(pContext); - - BufferMemoryBarrier( + auto *pDeviceContextGL = ValidatedCast(pContext); + BufferMemoryBarrier( GL_CLIENT_MAPPED_BUFFER_BARRIER_BIT,// Access by the client to persistent mapped regions of buffer // objects will reflect data written by shaders prior to the barrier. // Note that this may cause additional synchronization operations. - pDeviceContextGL->GetContextState()); + pDeviceContextGL->GetContextState()); + m_uiMapTarget = ( MapType == MAP_READ ) ? GL_COPY_READ_BUFFER : GL_COPY_WRITE_BUFFER; glBindBuffer(m_uiMapTarget, m_GlBuffer); @@ -317,13 +317,13 @@ void BufferGLImpl::Unmap( IDeviceContext *pContext, MAP_TYPE MapType, Uint32 Map glBindBuffer(m_uiMapTarget, m_GlBuffer); auto Result = glUnmapBuffer(m_uiMapTarget); - // glUnmapBuffer() returns TRUE unless data values in the buffer’s data store have + // glUnmapBuffer() returns TRUE unless data values in the buffer�s data store have // become corrupted during the period that the buffer was mapped. Such corruption // can be the result of a screen resolution change or other window system - dependent // event that causes system heaps such as those for high - performance graphics memory // to be discarded. GL implementations must guarantee that such corruption can - // occur only during the periods that a buffer’s data store is mapped. If such corruption - // has occurred, glUnmapBuffer() returns FALSE, and the contents of the buffer’s + // occur only during the periods that a buffer�s data store is mapped. If such corruption + // has occurred, glUnmapBuffer() returns FALSE, and the contents of the buffer�s // data store become undefined. VERIFY( Result != GL_FALSE, "Failed to unmap buffer. The data may have been corrupted" ); glBindBuffer(m_uiMapTarget, 0); @@ -332,6 +332,7 @@ void BufferGLImpl::Unmap( IDeviceContext *pContext, MAP_TYPE MapType, Uint32 Map void BufferGLImpl::BufferMemoryBarrier( Uint32 RequiredBarriers, GLContextState &GLContextState ) { +#if GL_ARB_shader_image_load_store const Uint32 BufferBarriers = GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT | GL_ELEMENT_ARRAY_BARRIER_BIT | @@ -345,6 +346,7 @@ void BufferGLImpl::BufferMemoryBarrier( Uint32 RequiredBarriers, GLContextState VERIFY( (RequiredBarriers & ~BufferBarriers) == 0, "Inappropriate buffer memory barrier flag" ); GLContextState.EnsureMemoryBarrier( RequiredBarriers, this ); +#endif } void BufferGLImpl::CreateViewInternal( const BufferViewDesc &OrigViewDesc, class IBufferView **ppView, bool bIsDefaultView ) diff --git a/Graphics/GraphicsEngineOpenGL/src/BufferViewGLImpl.cpp b/Graphics/GraphicsEngineOpenGL/src/BufferViewGLImpl.cpp index 154b508d..46653e2a 100644 --- a/Graphics/GraphicsEngineOpenGL/src/BufferViewGLImpl.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/BufferViewGLImpl.cpp @@ -42,6 +42,8 @@ namespace Diligent { if( ViewDesc.ViewType == BUFFER_VIEW_SHADER_RESOURCE && pBuffer->GetDesc().Mode == BUFFER_MODE_FORMATTED ) { + VERIFY( GL_TEXTURE_BUFFER != 0, "GL texture buffers are not supported"); + auto *pContextGL = ValidatedCast(pContext); auto &ContextState = pContextGL->GetContextState(); diff --git a/Graphics/GraphicsEngineOpenGL/src/DeviceContextGLImpl.cpp b/Graphics/GraphicsEngineOpenGL/src/DeviceContextGLImpl.cpp index 5946f899..854eebaf 100644 --- a/Graphics/GraphicsEngineOpenGL/src/DeviceContextGLImpl.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/DeviceContextGLImpl.cpp @@ -487,6 +487,7 @@ namespace Diligent } } +#if GL_ARB_shader_image_load_store auto &Images = ProgResources.GetImages(); for( auto it = Images.begin(); it != Images.end(); ++it ) { @@ -551,7 +552,9 @@ namespace Diligent } } } +#endif +#if GL_ARB_shader_storage_buffer_object auto &StorageBlocks = ProgResources.GetStorageBlocks(); for( auto it = StorageBlocks.begin(); it != StorageBlocks.end(); ++it ) { @@ -585,9 +588,11 @@ namespace Diligent } } } +#endif } } +#if GL_ARB_shader_image_load_store // Go through the list of textures bound as AUVs and set the required memory barriers for( auto pWritableTex = m_BoundWritableTextures.begin(); pWritableTex != m_BoundWritableTextures.end(); ++pWritableTex ) { @@ -634,6 +639,7 @@ namespace Diligent // Set new required barriers for the time when buffer is used next time (*pWritableBuff)->SetPendingMemoryBarriers( BufferMemoryBarriers ); } +#endif } void DeviceContextGLImpl::Draw( DrawAttribs &DrawAttribs ) @@ -675,9 +681,13 @@ namespace Diligent GLenum GlTopology; if (DrawAttribs.Topology >= PRIMITIVE_TOPOLOGY_1_CONTROL_POINT_PATCHLIST) { +#if GL_ARB_tessellation_shader GlTopology = GL_PATCHES; auto NumVertices = static_cast(DrawAttribs.Topology - PRIMITIVE_TOPOLOGY_1_CONTROL_POINT_PATCHLIST + 1); m_ContextState.SetNumPatchVertices(NumVertices); +#else + UNSUPPORTED("Tessellation is not supported"); +#endif } else { @@ -702,6 +712,7 @@ namespace Diligent // http://www.opengl.org/wiki/Vertex_Rendering if( DrawAttribs.IsIndirect ) { +#if GL_ARB_draw_indirect // The indirect rendering functions take their data from the buffer currently bound to the // GL_DRAW_INDIRECT_BUFFER binding. Thus, any of indirect draw functions will fail if no buffer is // bound to that binding. @@ -748,6 +759,9 @@ namespace Diligent } glBindBuffer( GL_DRAW_INDIRECT_BUFFER, 0 ); +#else + UNSUPPORTED("Indirect rendering is not supported"); +#endif } else { @@ -803,6 +817,7 @@ namespace Diligent void DeviceContextGLImpl::DispatchCompute( const DispatchComputeAttribs &DispatchAttrs ) { +#if GL_ARB_compute_shader if( DispatchAttrs.pIndirectDispatchAttribs ) { CHECK_DYNAMIC_TYPE( BufferGLImpl, DispatchAttrs.pIndirectDispatchAttribs ); @@ -835,6 +850,9 @@ namespace Diligent // AFTER the actual draw/dispatch command is executed. m_ContextState.SetPendingMemoryBarriers( m_CommitedResourcesTentativeBarriers ); m_CommitedResourcesTentativeBarriers = 0; +#else + UNSUPPORTED("Compute shaders are not supported"); +#endif } void DeviceContextGLImpl::ClearDepthStencil( ITextureView *pView, Uint32 ClearFlags, float fDepth, Uint8 Stencil ) diff --git a/Graphics/GraphicsEngineOpenGL/src/GLContextIOS.mm b/Graphics/GraphicsEngineOpenGL/src/GLContextIOS.mm new file mode 100644 index 00000000..b93451e8 --- /dev/null +++ b/Graphics/GraphicsEngineOpenGL/src/GLContextIOS.mm @@ -0,0 +1,119 @@ +/* Copyright 2015-2018 Egor Yusov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * THE SOFTWARE IS 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent acts) or agreed to in writing, shall any Contributor be + * liable for any damages, including any direct, indirect, special, incidental, + * or consequential damages of any character arising as a result of this License or + * out of the use or inability to use the software (including but not limited to damages + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "pch.h" + +//#import + +#include "GLContextIOS.h" +#include "DeviceCaps.h" +#include "GLTypeConversions.h" + +namespace Diligent +{ + + GLContext::GLContext( const ContextInitInfo &Info, DeviceCaps &DeviceCaps ) : + m_SwapChainAttribs(Info.SwapChainAttribs) + { + /*if (GetCurrentNativeGLContext() == nullptr) + { + LOG_ERROR_AND_THROW("No current GL context found!"); + } + + // Initialize GLEW + glewExperimental = true; // This is required on MacOS + GLenum err = glewInit(); + if( GLEW_OK != err ) + LOG_ERROR_AND_THROW( "Failed to initialize GLEW" ); + + //Set dummy width and height until resize is called by the app + if(m_SwapChainAttribs.Width == 0) + m_SwapChainAttribs.Width = 1024; + if(m_SwapChainAttribs.Height) + m_SwapChainAttribs.Height = 768; + + //Checking GL version + const GLubyte *GLVersionString = glGetString( GL_VERSION ); + const GLubyte *GLRenderer = glGetString(GL_RENDERER); + + Int32 MajorVersion = 0, MinorVersion = 0; + //Or better yet, use the GL3 way to get the version number + glGetIntegerv( GL_MAJOR_VERSION, &MajorVersion ); + glGetIntegerv( GL_MINOR_VERSION, &MinorVersion ); + LOG_INFO_MESSAGE(Info.pNativeWndHandle != nullptr ? "Initialized OpenGL " : "Attached to OpenGL ", MajorVersion, '.', MinorVersion, " context (", GLVersionString, ", ", GLRenderer, ')'); + + // Under the standard filtering rules for cubemaps, filtering does not work across faces of the cubemap. + // This results in a seam across the faces of a cubemap. This was a hardware limitation in the past, but + // modern hardware is capable of interpolating across a cube face boundary. + // GL_TEXTURE_CUBE_MAP_SEAMLESS is not defined in OpenGLES + glEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS); + if( glGetError() != GL_NO_ERROR ) + LOG_ERROR_MESSAGE("Failed to enable seamless cubemap filtering"); + + // When GL_FRAMEBUFFER_SRGB is enabled, and if the destination image is in the sRGB colorspace + // then OpenGL will assume the shader's output is in the linear RGB colorspace. It will therefore + // convert the output from linear RGB to sRGB. + // Any writes to images that are not in the sRGB format should not be affected. + // Thus this setting should be just set once and left that way + glEnable(GL_FRAMEBUFFER_SRGB); + if( glGetError() != GL_NO_ERROR ) + LOG_ERROR_MESSAGE("Failed to enable SRGB framebuffers"); + + DeviceCaps.DevType = DeviceType::OpenGL; + DeviceCaps.MajorVersion = MajorVersion; + DeviceCaps.MinorVersion = MinorVersion; + bool IsGL43OrAbove = MajorVersion >= 5 || (MajorVersion == 4 && MinorVersion >= 3); + bool IsGL42OrAbove = MajorVersion >= 5 || (MajorVersion == 4 && MinorVersion >= 2); + DeviceCaps.bComputeShadersSupported = IsGL42OrAbove; + auto &TexCaps = DeviceCaps.TexCaps; + TexCaps.bTexture2DMSSupported = IsGL43OrAbove; + TexCaps.bTexture2DMSArraySupported = IsGL43OrAbove; + TexCaps.bTextureViewSupported = IsGL43OrAbove; + TexCaps.bCubemapArraysSupported = IsGL43OrAbove; + DeviceCaps.bMultithreadedResourceCreationSupported = False;*/ + DeviceCaps.bIndirectRenderingSupported = False; + DeviceCaps.bGeometryShadersSupported = False; + DeviceCaps.bTessellationSupported = False; + DeviceCaps.bWireframeFillSupported = False; + DeviceCaps.SamCaps.bLODBiasSupported = False; + DeviceCaps.SamCaps.bBorderSamplingModeSupported = False; + DeviceCaps.TexCaps.bTexture1DSupported = False; + DeviceCaps.TexCaps.bCubemapArraysSupported = False; + DeviceCaps.TexCaps.bTexture1DSupported = False; + DeviceCaps.TexCaps.bTexture1DArraySupported = False; + DeviceCaps.TexCaps.bTextureViewSupported = False; + DeviceCaps.TexCaps.bTexture2DMSSupported = False; + DeviceCaps.TexCaps.bTexture2DMSArraySupported = False; + } + + void GLContext::SwapBuffers() + { + LOG_ERROR("Swap buffers operation must be performed by the app on MacOS"); + } + + GLContext::NativeGLContextType GLContext::GetCurrentNativeGLContext() + { + //NSOpenGLContext* CurrentCtx = [NSOpenGLContext currentContext]; + return nullptr;//CurrentCtx; + } +} diff --git a/Graphics/GraphicsEngineOpenGL/src/GLContextMacOS.cpp b/Graphics/GraphicsEngineOpenGL/src/GLContextMacOS.cpp deleted file mode 100644 index 81e0efdd..00000000 --- a/Graphics/GraphicsEngineOpenGL/src/GLContextMacOS.cpp +++ /dev/null @@ -1,106 +0,0 @@ -/* Copyright 2015-2018 Egor Yusov - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * THE SOFTWARE IS 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent acts) or agreed to in writing, shall any Contributor be - * liable for any damages, including any direct, indirect, special, incidental, - * or consequential damages of any character arising as a result of this License or - * out of the use or inability to use the software (including but not limited to damages - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "pch.h" - -#import - -#include "GLContextMacOS.h" -#include "DeviceCaps.h" -#include "GLTypeConversions.h" - -namespace Diligent -{ - - GLContext::GLContext( const ContextInitInfo &Info, DeviceCaps &DeviceCaps ) : - m_SwapChainAttribs(Info.SwapChainAttribs) - { - if (GetCurrentNativeGLContext() == nullptr) - { - LOG_ERROR_AND_THROW("No current GL context found!"); - } - - // Initialize GLEW - glewExperimental = true; // This is required on MacOS - GLenum err = glewInit(); - if( GLEW_OK != err ) - LOG_ERROR_AND_THROW( "Failed to initialize GLEW" ); - - //Set dummy width and height until resize is called by the app - if(m_SwapChainAttribs.Width == 0) - m_SwapChainAttribs.Width = 1024; - if(m_SwapChainAttribs.Height) - m_SwapChainAttribs.Height = 768; - - //Checking GL version - const GLubyte *GLVersionString = glGetString( GL_VERSION ); - const GLubyte *GLRenderer = glGetString(GL_RENDERER); - - Int32 MajorVersion = 0, MinorVersion = 0; - //Or better yet, use the GL3 way to get the version number - glGetIntegerv( GL_MAJOR_VERSION, &MajorVersion ); - glGetIntegerv( GL_MINOR_VERSION, &MinorVersion ); - LOG_INFO_MESSAGE(Info.pNativeWndHandle != nullptr ? "Initialized OpenGL " : "Attached to OpenGL ", MajorVersion, '.', MinorVersion, " context (", GLVersionString, ", ", GLRenderer, ')'); - - // Under the standard filtering rules for cubemaps, filtering does not work across faces of the cubemap. - // This results in a seam across the faces of a cubemap. This was a hardware limitation in the past, but - // modern hardware is capable of interpolating across a cube face boundary. - // GL_TEXTURE_CUBE_MAP_SEAMLESS is not defined in OpenGLES - glEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS); - if( glGetError() != GL_NO_ERROR ) - LOG_ERROR_MESSAGE("Failed to enable seamless cubemap filtering"); - - // When GL_FRAMEBUFFER_SRGB is enabled, and if the destination image is in the sRGB colorspace - // then OpenGL will assume the shader's output is in the linear RGB colorspace. It will therefore - // convert the output from linear RGB to sRGB. - // Any writes to images that are not in the sRGB format should not be affected. - // Thus this setting should be just set once and left that way - glEnable(GL_FRAMEBUFFER_SRGB); - if( glGetError() != GL_NO_ERROR ) - LOG_ERROR_MESSAGE("Failed to enable SRGB framebuffers"); - - DeviceCaps.DevType = DeviceType::OpenGL; - DeviceCaps.MajorVersion = MajorVersion; - DeviceCaps.MinorVersion = MinorVersion; - bool IsGL43OrAbove = MajorVersion >= 5 || (MajorVersion == 4 && MinorVersion >= 3); - bool IsGL42OrAbove = MajorVersion >= 5 || (MajorVersion == 4 && MinorVersion >= 2); - DeviceCaps.bComputeShadersSupported = IsGL42OrAbove; - auto &TexCaps = DeviceCaps.TexCaps; - TexCaps.bTexture2DMSSupported = IsGL43OrAbove; - TexCaps.bTexture2DMSArraySupported = IsGL43OrAbove; - TexCaps.bTextureViewSupported = IsGL43OrAbove; - TexCaps.bCubemapArraysSupported = IsGL43OrAbove; - DeviceCaps.bMultithreadedResourceCreationSupported = False; - } - - void GLContext::SwapBuffers() - { - LOG_ERROR("Swap buffers operation must be performed by the app on MacOS"); - } - - GLContext::NativeGLContextType GLContext::GetCurrentNativeGLContext() - { - NSOpenGLContext* CurrentCtx = [NSOpenGLContext currentContext]; - return CurrentCtx; - } -} diff --git a/Graphics/GraphicsEngineOpenGL/src/GLContextMacOS.mm b/Graphics/GraphicsEngineOpenGL/src/GLContextMacOS.mm new file mode 100644 index 00000000..81e0efdd --- /dev/null +++ b/Graphics/GraphicsEngineOpenGL/src/GLContextMacOS.mm @@ -0,0 +1,106 @@ +/* Copyright 2015-2018 Egor Yusov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * THE SOFTWARE IS 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent acts) or agreed to in writing, shall any Contributor be + * liable for any damages, including any direct, indirect, special, incidental, + * or consequential damages of any character arising as a result of this License or + * out of the use or inability to use the software (including but not limited to damages + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "pch.h" + +#import + +#include "GLContextMacOS.h" +#include "DeviceCaps.h" +#include "GLTypeConversions.h" + +namespace Diligent +{ + + GLContext::GLContext( const ContextInitInfo &Info, DeviceCaps &DeviceCaps ) : + m_SwapChainAttribs(Info.SwapChainAttribs) + { + if (GetCurrentNativeGLContext() == nullptr) + { + LOG_ERROR_AND_THROW("No current GL context found!"); + } + + // Initialize GLEW + glewExperimental = true; // This is required on MacOS + GLenum err = glewInit(); + if( GLEW_OK != err ) + LOG_ERROR_AND_THROW( "Failed to initialize GLEW" ); + + //Set dummy width and height until resize is called by the app + if(m_SwapChainAttribs.Width == 0) + m_SwapChainAttribs.Width = 1024; + if(m_SwapChainAttribs.Height) + m_SwapChainAttribs.Height = 768; + + //Checking GL version + const GLubyte *GLVersionString = glGetString( GL_VERSION ); + const GLubyte *GLRenderer = glGetString(GL_RENDERER); + + Int32 MajorVersion = 0, MinorVersion = 0; + //Or better yet, use the GL3 way to get the version number + glGetIntegerv( GL_MAJOR_VERSION, &MajorVersion ); + glGetIntegerv( GL_MINOR_VERSION, &MinorVersion ); + LOG_INFO_MESSAGE(Info.pNativeWndHandle != nullptr ? "Initialized OpenGL " : "Attached to OpenGL ", MajorVersion, '.', MinorVersion, " context (", GLVersionString, ", ", GLRenderer, ')'); + + // Under the standard filtering rules for cubemaps, filtering does not work across faces of the cubemap. + // This results in a seam across the faces of a cubemap. This was a hardware limitation in the past, but + // modern hardware is capable of interpolating across a cube face boundary. + // GL_TEXTURE_CUBE_MAP_SEAMLESS is not defined in OpenGLES + glEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS); + if( glGetError() != GL_NO_ERROR ) + LOG_ERROR_MESSAGE("Failed to enable seamless cubemap filtering"); + + // When GL_FRAMEBUFFER_SRGB is enabled, and if the destination image is in the sRGB colorspace + // then OpenGL will assume the shader's output is in the linear RGB colorspace. It will therefore + // convert the output from linear RGB to sRGB. + // Any writes to images that are not in the sRGB format should not be affected. + // Thus this setting should be just set once and left that way + glEnable(GL_FRAMEBUFFER_SRGB); + if( glGetError() != GL_NO_ERROR ) + LOG_ERROR_MESSAGE("Failed to enable SRGB framebuffers"); + + DeviceCaps.DevType = DeviceType::OpenGL; + DeviceCaps.MajorVersion = MajorVersion; + DeviceCaps.MinorVersion = MinorVersion; + bool IsGL43OrAbove = MajorVersion >= 5 || (MajorVersion == 4 && MinorVersion >= 3); + bool IsGL42OrAbove = MajorVersion >= 5 || (MajorVersion == 4 && MinorVersion >= 2); + DeviceCaps.bComputeShadersSupported = IsGL42OrAbove; + auto &TexCaps = DeviceCaps.TexCaps; + TexCaps.bTexture2DMSSupported = IsGL43OrAbove; + TexCaps.bTexture2DMSArraySupported = IsGL43OrAbove; + TexCaps.bTextureViewSupported = IsGL43OrAbove; + TexCaps.bCubemapArraysSupported = IsGL43OrAbove; + DeviceCaps.bMultithreadedResourceCreationSupported = False; + } + + void GLContext::SwapBuffers() + { + LOG_ERROR("Swap buffers operation must be performed by the app on MacOS"); + } + + GLContext::NativeGLContextType GLContext::GetCurrentNativeGLContext() + { + NSOpenGLContext* CurrentCtx = [NSOpenGLContext currentContext]; + return CurrentCtx; + } +} diff --git a/Graphics/GraphicsEngineOpenGL/src/GLContextState.cpp b/Graphics/GraphicsEngineOpenGL/src/GLContextState.cpp index d841938d..babdd479 100644 --- a/Graphics/GraphicsEngineOpenGL/src/GLContextState.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/GLContextState.cpp @@ -233,6 +233,7 @@ namespace Diligent GLenum Access, GLenum Format ) { +#if GL_ARB_shader_image_load_store BoundImageInfo NewImageInfo( pTexView->GetUniqueID(), MipLevel, @@ -250,10 +251,14 @@ namespace Diligent glBindImageTexture( Index, GLTexHandle, MipLevel, IsLayered, Layer, Access, Format ); CHECK_GL_ERROR( "glBindImageTexture() failed" ); } +#else + UNSUPPORTED("GL_ARB_shader_image_load_store is not supported"); +#endif } void GLContextState::EnsureMemoryBarrier( Uint32 RequiredBarriers, AsyncWritableResource *pRes/* = nullptr */ ) { +#if GL_ARB_shader_image_load_store // Every resource tracks its own pending memory barriers. // Device context also tracks which barriers have not been executed // When a resource with pending memory barrier flag is bound to the context, @@ -295,6 +300,9 @@ namespace Diligent // Leave only these barriers that are still pending if( pRes ) pRes->ResetPendingMemoryBarriers( m_PendingMemoryBarriers & ResourcePendingBarriers ); +#else + UNSUPPORTED("GL_ARB_shader_image_load_store is not supported"); +#endif } void GLContextState::SetPendingMemoryBarriers( Uint32 PendingBarriers ) @@ -694,11 +702,13 @@ namespace Diligent void GLContextState::SetNumPatchVertices(Int32 NumVertices) { +#if GL_ARB_tessellation_shader if (NumVertices != m_NumPatchVertices) { m_NumPatchVertices = NumVertices; glPatchParameteri(GL_PATCH_VERTICES, static_cast(NumVertices)); CHECK_GL_ERROR( "Failed to set the number of patch vertices" ); } +#endif } } diff --git a/Graphics/GraphicsEngineOpenGL/src/GLProgramResources.cpp b/Graphics/GraphicsEngineOpenGL/src/GLProgramResources.cpp index 5ec56f8d..682c1cb4 100644 --- a/Graphics/GraphicsEngineOpenGL/src/GLProgramResources.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/GLProgramResources.cpp @@ -86,6 +86,7 @@ namespace Diligent auto MaxNameLength = std::max( activeUniformMaxLength, activeUniformBlockMaxLength ); +#if GL_ARB_program_interface_query GLint numActiveShaderStorageBlocks = 0; if(glGetProgramInterfaceiv) { @@ -98,6 +99,7 @@ namespace Diligent CHECK_GL_ERROR_AND_THROW( "Unable to get the maximum shader storage block name length\n" ); MaxNameLength = std::max( MaxNameLength, MaxShaderStorageBlockNameLen ); } +#endif MaxNameLength = std::max( MaxNameLength, 512 ); std::vector Name( MaxNameLength + 1 ); @@ -192,6 +194,7 @@ namespace Diligent break; } +#if GL_ARB_shader_image_load_store case GL_IMAGE_1D: case GL_IMAGE_2D: case GL_IMAGE_3D: @@ -239,7 +242,7 @@ namespace Diligent m_Images.emplace_back( Name.data(), size, VarType, BindingPoint, dataType ); break; } - +#endif default: // Some other uniform type like scalar, matrix etc. break; @@ -297,6 +300,7 @@ namespace Diligent m_UniformBlocks.emplace_back( Name.data(), ArraySize, VarType, UniformBlockIndex ); } +#if GL_ARB_shader_storage_buffer_object for( int i = 0; i < numActiveShaderStorageBlocks; ++i ) { GLsizei Length = 0; @@ -343,6 +347,8 @@ namespace Diligent auto VarType = GetShaderVariableType(Name.data(), DefaultVariableType, VariableDesc, NumVars); m_StorageBlocks.emplace_back( Name.data(), ArraySize, VarType, Binding ); } +#endif + } static bool CheckType(SHADER_VARIABLE_TYPE Type, SHADER_VARIABLE_TYPE* AllowedTypes, Uint32 NumAllowedTypes) diff --git a/Graphics/GraphicsEngineOpenGL/src/GLStubs.cpp b/Graphics/GraphicsEngineOpenGL/src/GLStubs.cpp deleted file mode 100644 index 1407c2e2..00000000 --- a/Graphics/GraphicsEngineOpenGL/src/GLStubs.cpp +++ /dev/null @@ -1,283 +0,0 @@ -/* Copyright 2015-2018 Egor Yusov - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * THE SOFTWARE IS 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent acts) or agreed to in writing, shall any Contributor be - * liable for any damages, including any direct, indirect, special, incidental, - * or consequential damages of any character arising as a result of this License or - * out of the use or inability to use the software (including but not limited to damages - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "pch.h" -#include "GLStubs.h" -#include - -#define DECLARE_GL_FUNCTION(Func, FuncType, ...)\ - FuncType Func = nullptr; \ - void Func##Stub(__VA_ARGS__) \ - { \ - UnsupportedGLFunctionStub(#Func); \ - } - -#ifdef LOAD_GL_BIND_IMAGE_TEXTURE - DECLARE_GL_FUNCTION( glBindImageTexture, PFNGLBINDIMAGETEXTUREPROC, GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format ) -#endif - -#ifdef LOAD_GL_DISPATCH_COMPUTE - DECLARE_GL_FUNCTION( glDispatchCompute, PFNGLDISPATCHCOMPUTEPROC, GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z ) -#endif - -#ifdef LOAD_GL_PROGRAM_UNIFORM_1I - DECLARE_GL_FUNCTION( glProgramUniform1i, PFNGLPROGRAMUNIFORM1IPROC, GLuint program, GLint location, GLint x ) -#endif - -#ifdef LOAD_GL_MEMORY_BARRIER - DECLARE_GL_FUNCTION( glMemoryBarrier, PFNGLMEMORYBARRIERPROC, GLbitfield barriers ) -#endif - -#ifdef LOAD_DRAW_ELEMENTS_INDIRECT - DECLARE_GL_FUNCTION( glDrawElementsIndirect, PFNGLDRAWELEMENTSINDIRECTPROC, GLenum mode, GLenum type, const GLvoid *indirect ) -#endif - -#ifdef LOAD_DRAW_ARRAYS_INDIRECT - DECLARE_GL_FUNCTION( glDrawArraysIndirect, PFNGLDRAWARRAYSINDIRECTPROC, GLenum mode, const GLvoid *indirect ) -#endif - -#ifdef LOAD_GEN_PROGRAM_PIPELINES - DECLARE_GL_FUNCTION( glGenProgramPipelines, PFNGLGENPROGRAMPIPELINESPROC, GLsizei n, GLuint* pipelines ) -#endif - -#ifdef LOAD_GL_DELETE_PROGRAM_PIPELINES - DECLARE_GL_FUNCTION( glDeleteProgramPipelines, PFNGLDELETEPROGRAMPIPELINESPROC, GLsizei n, const GLuint* pipelines ) -#endif - -#ifdef LOAD_GL_BIND_PROGRAM_PIPELINE - DECLARE_GL_FUNCTION( glBindProgramPipeline, PFNGLBINDPROGRAMPIPELINEPROC, GLuint pipeline ) -#endif - -#ifdef LOAD_GL_USE_PROGRAM_STAGES - DECLARE_GL_FUNCTION( glUseProgramStages, PFNGLUSEPROGRAMSTAGESPROC, GLuint pipeline, GLbitfield stages, GLuint program ) -#endif - -#ifdef LOAD_GL_TEX_STORAGE_2D_MULTISAMPLE - DECLARE_GL_FUNCTION( glTexStorage2DMultisample, PFNGLTEXSTORAGE2DMULTISAMPLEPROC, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations ) -#endif - -#ifdef LOAD_GL_GET_PROGRAM_INTERFACEIV - DECLARE_GL_FUNCTION( glGetProgramInterfaceiv, PFNGLGETPROGRAMINTERFACEIVPROC, GLuint program, GLenum programInterface, GLenum pname, GLint* params ) -#endif - -#ifdef LOAD_GL_GET_PROGRAM_RESOURCE_NAME - DECLARE_GL_FUNCTION( glGetProgramResourceName, PFNGLGETPROGRAMRESOURCENAMEPROC, GLuint program, GLenum programInterface, GLuint index, GLsizei bufSize, GLsizei* length, GLchar *name ) -#endif - -#ifdef LOAD_GL_GET_PROGRAM_RESOURCEIV - DECLARE_GL_FUNCTION( glGetProgramResourceiv, PFNGLGETPROGRAMRESOURCEIVPROC, GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum* props, GLsizei bufSize, GLsizei *length, GLint *params ) -#endif - -#ifdef LOAD_DISPATCH_COMPUTE_INDIRECT - DECLARE_GL_FUNCTION( glDispatchComputeIndirect, PFNGLDISPATCHCOMPUTEINDIRECTPROC, GLintptr indirect ) -#endif - -#ifdef LOAD_GL_TEX_BUFFER - DECLARE_GL_FUNCTION( glTexBuffer, PFNGLTEXBUFFERPROC, GLenum, GLenum, GLuint) -#endif - -#ifdef LOAD_GL_POLYGON_MODE - DECLARE_GL_FUNCTION( glPolygonMode, PFNGLPOLYGONMODE, GLenum, GLenum) -#endif - -#ifdef LOAD_GL_ENABLEI - DECLARE_GL_FUNCTION( glEnablei, PFNGLENABLEIPROC, GLenum, GLuint) -#endif - -#ifdef LOAD_GL_BLEND_FUNC_SEPARATEI - DECLARE_GL_FUNCTION( glBlendFuncSeparatei, PFNGLBLENDFUNCSEPARATEIPROC, GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha) -#endif - -#ifdef LOAD_GL_BLEND_EQUATION_SEPARATEI - DECLARE_GL_FUNCTION( glBlendEquationSeparatei, PFNGLBLENDEQUATIONSEPARATEIPROC, GLuint buf, GLenum modeRGB, GLenum modeAlpha) -#endif - -#ifdef LOAD_GL_DISABLEI - DECLARE_GL_FUNCTION( glDisablei, PFNGLDISABLEIPROC, GLenum, GLuint) -#endif - -#ifdef LOAD_GL_COLOR_MASKI - DECLARE_GL_FUNCTION( glColorMaski, PFNGLCOLORMASKIPROC, GLuint, GLboolean, GLboolean, GLboolean, GLboolean) -#endif - -#ifdef LOAD_GL_VIEWPORT_INDEXEDF - DECLARE_GL_FUNCTION( glViewportIndexedf, PFNGLVIEWPORTINDEXEDFPROC, GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h) -#endif - -#ifdef LOAD_GL_SCISSOR_INDEXED - DECLARE_GL_FUNCTION( glScissorIndexed, PFNGLSCISSORINDEXEDPROC, GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height) -#endif - -#ifdef LOAD_GL_FRAMEBUFFER_TEXTURE - DECLARE_GL_FUNCTION( glFramebufferTexture, PFNGLFRAMEBUFFERTEXTUREPROC, GLenum, GLenum, GLuint, GLint) -#endif - -#ifdef LOAD_GL_FRAMEBUFFER_TEXTURE_1D - DECLARE_GL_FUNCTION( glFramebufferTexture1D, PFNGLFRAMEBUFFERTEXTURE1DPROC, GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) -#endif - -#ifdef LOAD_GL_FRAMEBUFFER_TEXTURE_3D - DECLARE_GL_FUNCTION( glFramebufferTexture3D, PFNGLFRAMEBUFFERTEXTURE3DPROC, GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint layer ) -#endif - -#ifdef LOAD_GL_COPY_IMAGE_SUB_DATA - DECLARE_GL_FUNCTION( glCopyImageSubData, PFNGLCOPYIMAGESUBDATAPROC, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth ) -#endif - -#ifdef LOAD_GL_PATCH_PARAMTER_I - DECLARE_GL_FUNCTION( glPatchParameteri, PFNGLPATCHPARAMETERIPROC, GLenum pname, GLint value ) -#endif - -#ifdef LOAD_GET_TEX_LEVEL_PARAMETER_IV - DECLARE_GL_FUNCTION( glGetTexLevelParameteriv, PFNGLGETTEXLEVELPARAMETERIVPROC, GLenum target, GLint level, GLenum pname, GLint *params ) -#endif - - -void LoadGLFunctions() -{ - -#define LOAD_GL_FUNCTION(Func, FuncType)\ -Func = (FuncType)eglGetProcAddress( #Func );\ - if( !Func )Func = Func##Stub; - -#ifdef LOAD_GL_BIND_IMAGE_TEXTURE - LOAD_GL_FUNCTION( glBindImageTexture, PFNGLBINDIMAGETEXTUREPROC ) -#endif - -#ifdef LOAD_GL_DISPATCH_COMPUTE - LOAD_GL_FUNCTION( glDispatchCompute, PFNGLDISPATCHCOMPUTEPROC ) -#endif - -#ifdef LOAD_GEN_PROGRAM_PIPELINES - LOAD_GL_FUNCTION( glGenProgramPipelines, PFNGLGENPROGRAMPIPELINESPROC ) -#endif - -#ifdef LOAD_GL_DELETE_PROGRAM_PIPELINES - LOAD_GL_FUNCTION( glDeleteProgramPipelines, PFNGLDELETEPROGRAMPIPELINESPROC ) -#endif - -#ifdef LOAD_GL_BIND_PROGRAM_PIPELINE - LOAD_GL_FUNCTION( glBindProgramPipeline, PFNGLBINDPROGRAMPIPELINEPROC ) -#endif - -#ifdef LOAD_GL_USE_PROGRAM_STAGES - LOAD_GL_FUNCTION( glUseProgramStages, PFNGLUSEPROGRAMSTAGESPROC ) -#endif - -#ifdef LOAD_GL_PROGRAM_UNIFORM_1I - LOAD_GL_FUNCTION( glProgramUniform1i, PFNGLPROGRAMUNIFORM1IPROC ) -#endif - -#ifdef LOAD_GL_MEMORY_BARRIER - LOAD_GL_FUNCTION( glMemoryBarrier, PFNGLMEMORYBARRIERPROC ) -#endif - -#ifdef LOAD_DRAW_ELEMENTS_INDIRECT - LOAD_GL_FUNCTION( glDrawElementsIndirect, PFNGLDRAWELEMENTSINDIRECTPROC ) -#endif - -#ifdef LOAD_DRAW_ARRAYS_INDIRECT - LOAD_GL_FUNCTION( glDrawArraysIndirect, PFNGLDRAWARRAYSINDIRECTPROC ) -#endif - -#ifdef LOAD_GL_TEX_STORAGE_2D_MULTISAMPLE - LOAD_GL_FUNCTION( glTexStorage2DMultisample, PFNGLTEXSTORAGE2DMULTISAMPLEPROC ) -#endif - -#ifdef LOAD_GL_GET_PROGRAM_INTERFACEIV - LOAD_GL_FUNCTION( glGetProgramInterfaceiv, PFNGLGETPROGRAMINTERFACEIVPROC ) -#endif - -#ifdef LOAD_GL_GET_PROGRAM_RESOURCE_NAME - LOAD_GL_FUNCTION( glGetProgramResourceName, PFNGLGETPROGRAMRESOURCENAMEPROC ) -#endif - -#ifdef LOAD_GL_GET_PROGRAM_RESOURCEIV - LOAD_GL_FUNCTION( glGetProgramResourceiv, PFNGLGETPROGRAMRESOURCEIVPROC ) -#endif - -#ifdef LOAD_DISPATCH_COMPUTE_INDIRECT - LOAD_GL_FUNCTION( glDispatchComputeIndirect, PFNGLDISPATCHCOMPUTEINDIRECTPROC ) -#endif - -#ifdef LOAD_GL_TEX_BUFFER - LOAD_GL_FUNCTION( glTexBuffer, PFNGLTEXBUFFERPROC ) -#endif - -#ifdef LOAD_GL_POLYGON_MODE - LOAD_GL_FUNCTION( glPolygonMode, PFNGLPOLYGONMODE) -#endif - -#ifdef LOAD_GL_ENABLEI - LOAD_GL_FUNCTION( glEnablei, PFNGLENABLEIPROC) -#endif - -#ifdef LOAD_GL_BLEND_FUNC_SEPARATEI - LOAD_GL_FUNCTION( glBlendFuncSeparatei, PFNGLBLENDFUNCSEPARATEIPROC ) -#endif - -#ifdef LOAD_GL_BLEND_EQUATION_SEPARATEI - LOAD_GL_FUNCTION( glBlendEquationSeparatei, PFNGLBLENDEQUATIONSEPARATEIPROC ) -#endif - -#ifdef LOAD_GL_DISABLEI - LOAD_GL_FUNCTION( glDisablei, PFNGLDISABLEIPROC ) -#endif - -#ifdef LOAD_GL_COLOR_MASKI - LOAD_GL_FUNCTION( glColorMaski, PFNGLCOLORMASKIPROC ) -#endif - -#ifdef LOAD_GL_VIEWPORT_INDEXEDF - LOAD_GL_FUNCTION( glViewportIndexedf, PFNGLVIEWPORTINDEXEDFPROC ) -#endif - -#ifdef LOAD_GL_SCISSOR_INDEXED - LOAD_GL_FUNCTION( glScissorIndexed, PFNGLSCISSORINDEXEDPROC ) -#endif - -#ifdef LOAD_GL_FRAMEBUFFER_TEXTURE - LOAD_GL_FUNCTION( glFramebufferTexture, PFNGLFRAMEBUFFERTEXTUREPROC ) -#endif - -#ifdef LOAD_GL_FRAMEBUFFER_TEXTURE_1D - LOAD_GL_FUNCTION( glFramebufferTexture1D, PFNGLFRAMEBUFFERTEXTURE1DPROC ) -#endif - -#ifdef LOAD_GL_FRAMEBUFFER_TEXTURE_3D - LOAD_GL_FUNCTION( glFramebufferTexture3D, PFNGLFRAMEBUFFERTEXTURE3DPROC ) -#endif - -#ifdef LOAD_GL_COPY_IMAGE_SUB_DATA - // Do not use proxy if function is not available! - LOAD_GL_FUNCTION(glCopyImageSubData, PFNGLCOPYIMAGESUBDATAPROC) -#endif - -#ifdef LOAD_GL_PATCH_PARAMTER_I - LOAD_GL_FUNCTION(glPatchParameteri, PFNGLPATCHPARAMETERIPROC) -#endif - -#ifdef LOAD_GET_TEX_LEVEL_PARAMETER_IV - LOAD_GL_FUNCTION(glGetTexLevelParameteriv, PFNGLGETTEXLEVELPARAMETERIVPROC) -#endif -} diff --git a/Graphics/GraphicsEngineOpenGL/src/GLStubsAndroid.cpp b/Graphics/GraphicsEngineOpenGL/src/GLStubsAndroid.cpp new file mode 100644 index 00000000..643aad8a --- /dev/null +++ b/Graphics/GraphicsEngineOpenGL/src/GLStubsAndroid.cpp @@ -0,0 +1,283 @@ +/* Copyright 2015-2018 Egor Yusov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * THE SOFTWARE IS 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent acts) or agreed to in writing, shall any Contributor be + * liable for any damages, including any direct, indirect, special, incidental, + * or consequential damages of any character arising as a result of this License or + * out of the use or inability to use the software (including but not limited to damages + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "pch.h" +#include "GLStubsAndroid.h" +#include + +#define DECLARE_GL_FUNCTION(Func, FuncType, ...)\ + FuncType Func = nullptr; \ + void Func##Stub(__VA_ARGS__) \ + { \ + UnsupportedGLFunctionStub(#Func); \ + } + +#ifdef LOAD_GL_BIND_IMAGE_TEXTURE + DECLARE_GL_FUNCTION( glBindImageTexture, PFNGLBINDIMAGETEXTUREPROC, GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format ) +#endif + +#ifdef LOAD_GL_DISPATCH_COMPUTE + DECLARE_GL_FUNCTION( glDispatchCompute, PFNGLDISPATCHCOMPUTEPROC, GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z ) +#endif + +#ifdef LOAD_GL_PROGRAM_UNIFORM_1I + DECLARE_GL_FUNCTION( glProgramUniform1i, PFNGLPROGRAMUNIFORM1IPROC, GLuint program, GLint location, GLint x ) +#endif + +#ifdef LOAD_GL_MEMORY_BARRIER + DECLARE_GL_FUNCTION( glMemoryBarrier, PFNGLMEMORYBARRIERPROC, GLbitfield barriers ) +#endif + +#ifdef LOAD_DRAW_ELEMENTS_INDIRECT + DECLARE_GL_FUNCTION( glDrawElementsIndirect, PFNGLDRAWELEMENTSINDIRECTPROC, GLenum mode, GLenum type, const GLvoid *indirect ) +#endif + +#ifdef LOAD_DRAW_ARRAYS_INDIRECT + DECLARE_GL_FUNCTION( glDrawArraysIndirect, PFNGLDRAWARRAYSINDIRECTPROC, GLenum mode, const GLvoid *indirect ) +#endif + +#ifdef LOAD_GEN_PROGRAM_PIPELINES + DECLARE_GL_FUNCTION( glGenProgramPipelines, PFNGLGENPROGRAMPIPELINESPROC, GLsizei n, GLuint* pipelines ) +#endif + +#ifdef LOAD_GL_DELETE_PROGRAM_PIPELINES + DECLARE_GL_FUNCTION( glDeleteProgramPipelines, PFNGLDELETEPROGRAMPIPELINESPROC, GLsizei n, const GLuint* pipelines ) +#endif + +#ifdef LOAD_GL_BIND_PROGRAM_PIPELINE + DECLARE_GL_FUNCTION( glBindProgramPipeline, PFNGLBINDPROGRAMPIPELINEPROC, GLuint pipeline ) +#endif + +#ifdef LOAD_GL_USE_PROGRAM_STAGES + DECLARE_GL_FUNCTION( glUseProgramStages, PFNGLUSEPROGRAMSTAGESPROC, GLuint pipeline, GLbitfield stages, GLuint program ) +#endif + +#ifdef LOAD_GL_TEX_STORAGE_2D_MULTISAMPLE + DECLARE_GL_FUNCTION( glTexStorage2DMultisample, PFNGLTEXSTORAGE2DMULTISAMPLEPROC, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations ) +#endif + +#ifdef LOAD_GL_GET_PROGRAM_INTERFACEIV + DECLARE_GL_FUNCTION( glGetProgramInterfaceiv, PFNGLGETPROGRAMINTERFACEIVPROC, GLuint program, GLenum programInterface, GLenum pname, GLint* params ) +#endif + +#ifdef LOAD_GL_GET_PROGRAM_RESOURCE_NAME + DECLARE_GL_FUNCTION( glGetProgramResourceName, PFNGLGETPROGRAMRESOURCENAMEPROC, GLuint program, GLenum programInterface, GLuint index, GLsizei bufSize, GLsizei* length, GLchar *name ) +#endif + +#ifdef LOAD_GL_GET_PROGRAM_RESOURCEIV + DECLARE_GL_FUNCTION( glGetProgramResourceiv, PFNGLGETPROGRAMRESOURCEIVPROC, GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum* props, GLsizei bufSize, GLsizei *length, GLint *params ) +#endif + +#ifdef LOAD_DISPATCH_COMPUTE_INDIRECT + DECLARE_GL_FUNCTION( glDispatchComputeIndirect, PFNGLDISPATCHCOMPUTEINDIRECTPROC, GLintptr indirect ) +#endif + +#ifdef LOAD_GL_TEX_BUFFER + DECLARE_GL_FUNCTION( glTexBuffer, PFNGLTEXBUFFERPROC, GLenum, GLenum, GLuint) +#endif + +#ifdef LOAD_GL_POLYGON_MODE + DECLARE_GL_FUNCTION( glPolygonMode, PFNGLPOLYGONMODE, GLenum, GLenum) +#endif + +#ifdef LOAD_GL_ENABLEI + DECLARE_GL_FUNCTION( glEnablei, PFNGLENABLEIPROC, GLenum, GLuint) +#endif + +#ifdef LOAD_GL_BLEND_FUNC_SEPARATEI + DECLARE_GL_FUNCTION( glBlendFuncSeparatei, PFNGLBLENDFUNCSEPARATEIPROC, GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha) +#endif + +#ifdef LOAD_GL_BLEND_EQUATION_SEPARATEI + DECLARE_GL_FUNCTION( glBlendEquationSeparatei, PFNGLBLENDEQUATIONSEPARATEIPROC, GLuint buf, GLenum modeRGB, GLenum modeAlpha) +#endif + +#ifdef LOAD_GL_DISABLEI + DECLARE_GL_FUNCTION( glDisablei, PFNGLDISABLEIPROC, GLenum, GLuint) +#endif + +#ifdef LOAD_GL_COLOR_MASKI + DECLARE_GL_FUNCTION( glColorMaski, PFNGLCOLORMASKIPROC, GLuint, GLboolean, GLboolean, GLboolean, GLboolean) +#endif + +#ifdef LOAD_GL_VIEWPORT_INDEXEDF + DECLARE_GL_FUNCTION( glViewportIndexedf, PFNGLVIEWPORTINDEXEDFPROC, GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h) +#endif + +#ifdef LOAD_GL_SCISSOR_INDEXED + DECLARE_GL_FUNCTION( glScissorIndexed, PFNGLSCISSORINDEXEDPROC, GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height) +#endif + +#ifdef LOAD_GL_FRAMEBUFFER_TEXTURE + DECLARE_GL_FUNCTION( glFramebufferTexture, PFNGLFRAMEBUFFERTEXTUREPROC, GLenum, GLenum, GLuint, GLint) +#endif + +#ifdef LOAD_GL_FRAMEBUFFER_TEXTURE_1D + DECLARE_GL_FUNCTION( glFramebufferTexture1D, PFNGLFRAMEBUFFERTEXTURE1DPROC, GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) +#endif + +#ifdef LOAD_GL_FRAMEBUFFER_TEXTURE_3D + DECLARE_GL_FUNCTION( glFramebufferTexture3D, PFNGLFRAMEBUFFERTEXTURE3DPROC, GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint layer ) +#endif + +#ifdef LOAD_GL_COPY_IMAGE_SUB_DATA + DECLARE_GL_FUNCTION( glCopyImageSubData, PFNGLCOPYIMAGESUBDATAPROC, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth ) +#endif + +#ifdef LOAD_GL_PATCH_PARAMTER_I + DECLARE_GL_FUNCTION( glPatchParameteri, PFNGLPATCHPARAMETERIPROC, GLenum pname, GLint value ) +#endif + +#ifdef LOAD_GET_TEX_LEVEL_PARAMETER_IV + DECLARE_GL_FUNCTION( glGetTexLevelParameteriv, PFNGLGETTEXLEVELPARAMETERIVPROC, GLenum target, GLint level, GLenum pname, GLint *params ) +#endif + + +void LoadGLFunctions() +{ + +#define LOAD_GL_FUNCTION(Func, FuncType)\ +Func = (FuncType)eglGetProcAddress( #Func );\ + if( !Func )Func = Func##Stub; + +#ifdef LOAD_GL_BIND_IMAGE_TEXTURE + LOAD_GL_FUNCTION( glBindImageTexture, PFNGLBINDIMAGETEXTUREPROC ) +#endif + +#ifdef LOAD_GL_DISPATCH_COMPUTE + LOAD_GL_FUNCTION( glDispatchCompute, PFNGLDISPATCHCOMPUTEPROC ) +#endif + +#ifdef LOAD_GEN_PROGRAM_PIPELINES + LOAD_GL_FUNCTION( glGenProgramPipelines, PFNGLGENPROGRAMPIPELINESPROC ) +#endif + +#ifdef LOAD_GL_DELETE_PROGRAM_PIPELINES + LOAD_GL_FUNCTION( glDeleteProgramPipelines, PFNGLDELETEPROGRAMPIPELINESPROC ) +#endif + +#ifdef LOAD_GL_BIND_PROGRAM_PIPELINE + LOAD_GL_FUNCTION( glBindProgramPipeline, PFNGLBINDPROGRAMPIPELINEPROC ) +#endif + +#ifdef LOAD_GL_USE_PROGRAM_STAGES + LOAD_GL_FUNCTION( glUseProgramStages, PFNGLUSEPROGRAMSTAGESPROC ) +#endif + +#ifdef LOAD_GL_PROGRAM_UNIFORM_1I + LOAD_GL_FUNCTION( glProgramUniform1i, PFNGLPROGRAMUNIFORM1IPROC ) +#endif + +#ifdef LOAD_GL_MEMORY_BARRIER + LOAD_GL_FUNCTION( glMemoryBarrier, PFNGLMEMORYBARRIERPROC ) +#endif + +#ifdef LOAD_DRAW_ELEMENTS_INDIRECT + LOAD_GL_FUNCTION( glDrawElementsIndirect, PFNGLDRAWELEMENTSINDIRECTPROC ) +#endif + +#ifdef LOAD_DRAW_ARRAYS_INDIRECT + LOAD_GL_FUNCTION( glDrawArraysIndirect, PFNGLDRAWARRAYSINDIRECTPROC ) +#endif + +#ifdef LOAD_GL_TEX_STORAGE_2D_MULTISAMPLE + LOAD_GL_FUNCTION( glTexStorage2DMultisample, PFNGLTEXSTORAGE2DMULTISAMPLEPROC ) +#endif + +#ifdef LOAD_GL_GET_PROGRAM_INTERFACEIV + LOAD_GL_FUNCTION( glGetProgramInterfaceiv, PFNGLGETPROGRAMINTERFACEIVPROC ) +#endif + +#ifdef LOAD_GL_GET_PROGRAM_RESOURCE_NAME + LOAD_GL_FUNCTION( glGetProgramResourceName, PFNGLGETPROGRAMRESOURCENAMEPROC ) +#endif + +#ifdef LOAD_GL_GET_PROGRAM_RESOURCEIV + LOAD_GL_FUNCTION( glGetProgramResourceiv, PFNGLGETPROGRAMRESOURCEIVPROC ) +#endif + +#ifdef LOAD_DISPATCH_COMPUTE_INDIRECT + LOAD_GL_FUNCTION( glDispatchComputeIndirect, PFNGLDISPATCHCOMPUTEINDIRECTPROC ) +#endif + +#ifdef LOAD_GL_TEX_BUFFER + LOAD_GL_FUNCTION( glTexBuffer, PFNGLTEXBUFFERPROC ) +#endif + +#ifdef LOAD_GL_POLYGON_MODE + LOAD_GL_FUNCTION( glPolygonMode, PFNGLPOLYGONMODE) +#endif + +#ifdef LOAD_GL_ENABLEI + LOAD_GL_FUNCTION( glEnablei, PFNGLENABLEIPROC) +#endif + +#ifdef LOAD_GL_BLEND_FUNC_SEPARATEI + LOAD_GL_FUNCTION( glBlendFuncSeparatei, PFNGLBLENDFUNCSEPARATEIPROC ) +#endif + +#ifdef LOAD_GL_BLEND_EQUATION_SEPARATEI + LOAD_GL_FUNCTION( glBlendEquationSeparatei, PFNGLBLENDEQUATIONSEPARATEIPROC ) +#endif + +#ifdef LOAD_GL_DISABLEI + LOAD_GL_FUNCTION( glDisablei, PFNGLDISABLEIPROC ) +#endif + +#ifdef LOAD_GL_COLOR_MASKI + LOAD_GL_FUNCTION( glColorMaski, PFNGLCOLORMASKIPROC ) +#endif + +#ifdef LOAD_GL_VIEWPORT_INDEXEDF + LOAD_GL_FUNCTION( glViewportIndexedf, PFNGLVIEWPORTINDEXEDFPROC ) +#endif + +#ifdef LOAD_GL_SCISSOR_INDEXED + LOAD_GL_FUNCTION( glScissorIndexed, PFNGLSCISSORINDEXEDPROC ) +#endif + +#ifdef LOAD_GL_FRAMEBUFFER_TEXTURE + LOAD_GL_FUNCTION( glFramebufferTexture, PFNGLFRAMEBUFFERTEXTUREPROC ) +#endif + +#ifdef LOAD_GL_FRAMEBUFFER_TEXTURE_1D + LOAD_GL_FUNCTION( glFramebufferTexture1D, PFNGLFRAMEBUFFERTEXTURE1DPROC ) +#endif + +#ifdef LOAD_GL_FRAMEBUFFER_TEXTURE_3D + LOAD_GL_FUNCTION( glFramebufferTexture3D, PFNGLFRAMEBUFFERTEXTURE3DPROC ) +#endif + +#ifdef LOAD_GL_COPY_IMAGE_SUB_DATA + // Do not use proxy if function is not available! + LOAD_GL_FUNCTION(glCopyImageSubData, PFNGLCOPYIMAGESUBDATAPROC) +#endif + +#ifdef LOAD_GL_PATCH_PARAMTER_I + LOAD_GL_FUNCTION(glPatchParameteri, PFNGLPATCHPARAMETERIPROC) +#endif + +#ifdef LOAD_GET_TEX_LEVEL_PARAMETER_IV + LOAD_GL_FUNCTION(glGetTexLevelParameteriv, PFNGLGETTEXLEVELPARAMETERIVPROC) +#endif +} diff --git a/Graphics/GraphicsEngineOpenGL/src/RenderDeviceFactoryOpenGL.cpp b/Graphics/GraphicsEngineOpenGL/src/RenderDeviceFactoryOpenGL.cpp index bf172073..2ef70c15 100644 --- a/Graphics/GraphicsEngineOpenGL/src/RenderDeviceFactoryOpenGL.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/RenderDeviceFactoryOpenGL.cpp @@ -43,6 +43,8 @@ namespace Diligent typedef RenderDeviceGLImpl TRenderDeviceGLImpl; #elif defined(PLATFORM_ANDROID) typedef RenderDeviceGLESImpl TRenderDeviceGLImpl; +#elif defined(PLATFORM_IOS) + typedef RenderDeviceGLImpl TRenderDeviceGLImpl; #else # error Unsupported platform #endif diff --git a/Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLImpl.cpp b/Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLImpl.cpp index 1eda4043..ec40f3a1 100644 --- a/Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLImpl.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLImpl.cpp @@ -449,6 +449,7 @@ void RenderDeviceGLImpl::FlagSupportedTexFormats() continue; } +#if GL_ARB_internalformat_query2 // Only works on GL4.3+ if( bGL43OrAbove ) { @@ -457,6 +458,7 @@ void RenderDeviceGLImpl::FlagSupportedTexFormats() CHECK_GL_ERROR( "glGetInternalformativ() failed" ); VERIFY( FmtInfo->Supported == (params == GL_TRUE), "This internal format should be supported" ); } +#endif // Check that the format is indeed supported if( FmtInfo->Supported ) @@ -616,11 +618,13 @@ void RenderDeviceGLImpl::TestTextureFormat( TEXTURE_FORMAT TexFormat ) if( TexFormatInfo.ComponentType != COMPONENT_TYPE_COMPRESSED && m_DeviceCaps.TexCaps.bTexture2DMSSupported ) { +#if GL_ARB_texture_storage_multisample GLObjectWrappers::GLTextureObj TestGLTex( true ); TexFormatInfo.SupportsMS = CreateTestGLTexture( ContextState, GL_TEXTURE_2D_MULTISAMPLE, TestGLTex, [&]() { glTexStorage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, 4, GLFmt, TestTextureDim, TestTextureDim, GL_TRUE); } ); +#endif } // Create test texture 3D diff --git a/Graphics/GraphicsEngineOpenGL/src/ShaderGLImpl.cpp b/Graphics/GraphicsEngineOpenGL/src/ShaderGLImpl.cpp index b0b69563..28ef9327 100644 --- a/Graphics/GraphicsEngineOpenGL/src/ShaderGLImpl.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/ShaderGLImpl.cpp @@ -57,6 +57,27 @@ ShaderGLImpl::ShaderGLImpl(IReferenceCounters *pRefCounters, RenderDeviceGLImpl "#version 410 core\n" "#define DESKTOP_GL 1\n" ); +#elif defined(PLATFORM_IOS) + Settings.append( + "#version 300 es\n" + "#ifndef GL_ES\n" + "# define GL_ES 1\n" + "#endif\n" + + "precision highp float;\n" + "precision highp int;\n" + //"precision highp uint;\n" + + "precision highp sampler2D;\n" + "precision highp sampler3D;\n" + "precision highp samplerCube;\n" + "precision highp samplerCubeArray;\n" + "precision highp samplerCubeShadow;\n" + "precision highp samplerCubeArrayShadow;\n" + "precision highp sampler2DShadow;\n" + "precision highp sampler2DArray;\n" + "precision highp sampler2DArrayShadow;\n" + ); #elif defined(ANDROID) Settings.append( "#version 310 es\n" diff --git a/Graphics/GraphicsEngineOpenGL/src/Texture2D_OGL.cpp b/Graphics/GraphicsEngineOpenGL/src/Texture2D_OGL.cpp index 372c20cf..0d448ca5 100644 --- a/Graphics/GraphicsEngineOpenGL/src/Texture2D_OGL.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/Texture2D_OGL.cpp @@ -47,6 +47,7 @@ Texture2D_OGL::Texture2D_OGL( IReferenceCounters *pRefCounters, if( m_Desc.SampleCount > 1 ) { +#if GL_ARB_texture_storage_multisample // format width height depth glTexStorage2DMultisample(m_BindTarget, m_Desc.SampleCount, m_GLTexFormat, m_Desc.Width, m_Desc.Height, GL_TRUE); // The last parameter specifies whether the image will use identical sample locations and the same number of @@ -62,6 +63,9 @@ Texture2D_OGL::Texture2D_OGL( IReferenceCounters *pRefCounters, SetDefaultGLParameters(); VERIFY( InitData.pSubResources == nullptr, "Multisampled textures cannot be modified directly" ); +#else + LOG_ERROR_AND_THROW("Multisampled textures are not supported"); +#endif } else { diff --git a/Graphics/GraphicsEngineOpenGL/src/TextureBaseGL.cpp b/Graphics/GraphicsEngineOpenGL/src/TextureBaseGL.cpp index 4d5fd1aa..94e9a261 100644 --- a/Graphics/GraphicsEngineOpenGL/src/TextureBaseGL.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/TextureBaseGL.cpp @@ -62,10 +62,13 @@ static GLenum GetTextureInternalFormat(DeviceContextGLImpl *pDeviceContextGL, GL QueryBindTarget = GL_TEXTURE_CUBE_MAP_POSITIVE_X; GLint GlFormat = 0; +#if GL_TEXTURE_INTERNAL_FORMAT glGetTexLevelParameteriv(QueryBindTarget, 0, GL_TEXTURE_INTERNAL_FORMAT, &GlFormat); CHECK_GL_ERROR( "Failed to get texture format through glGetTexLevelParameteriv()" ); VERIFY(GlFormat != 0, "Unable to get texture format"); - +#else + UNSUPPORTED("Texture format query is not supported"); +#endif ContextState.BindTexture(-1, BindTarget, GLObjectWrappers::GLTextureObj(false) ); return GlFormat; @@ -84,18 +87,49 @@ static TextureDesc GetTextureDescFromGLHandle(DeviceContextGLImpl *pDeviceContex if (BindTarget == GL_TEXTURE_CUBE_MAP) QueryBindTarget = GL_TEXTURE_CUBE_MAP_POSITIVE_X; - GLint TexWidth = 0, TexHeight = 0, TexDepth = 0; + +#if GL_TEXTURE_WIDTH + GLint TexWidth = 0; glGetTexLevelParameteriv(QueryBindTarget, 0, GL_TEXTURE_WIDTH, &TexWidth); + VERIFY_EXPR(TexWidth > 0); + VERIFY(TexDesc.Width == 0 || TexDesc.Width == static_cast(TexWidth), "Specified texture width (", TexDesc.Width, ") does not match the actual width (", TexWidth, ")"); + TexDesc.Width = static_cast(TexWidth); +#else + VERIFY(TexDesc.Width != 0, "Texture width query is not supported; it must be specified by the texture description."); +#endif + if (TexDesc.Type >= RESOURCE_DIM_TEX_2D) + { +#if GL_TEXTURE_HEIGHT + GLint TexHeight = 0; glGetTexLevelParameteriv(QueryBindTarget, 0, GL_TEXTURE_HEIGHT, &TexHeight); + VERIFY_EXPR(TexHeight > 0); + + VERIFY(TexDesc.Height == 0 || TexDesc.Height == static_cast(TexHeight), "Specified texture height (", TexDesc.Height,") does not match the actual height (", TexHeight, ")"); + TexDesc.Height = static_cast(TexHeight); +#else + VERIFY(TexDesc.Height != 0, "Texture height query is not supported; it must be specified by the texture description."); +#endif + } else - TexHeight = 1; + TexDesc.Height = 1; if (TexDesc.Type == RESOURCE_DIM_TEX_3D) + { +#if GL_TEXTURE_DEPTH + GLint TexDepth = 0; glGetTexLevelParameteriv(QueryBindTarget, 0, GL_TEXTURE_DEPTH, &TexDepth); + VERIFY_EXPR(TexDepth > 0); + VERIFY(TexDesc.Depth == 0 || TexDesc.Depth == static_cast(TexDepth), "Specified texture depth (", TexDesc.Depth, ") does not match the actual depth (", TexDepth, ")"); + TexDesc.Depth = static_cast(TexDepth); +#else + VERIFY(TexDesc.Depth != 0, "Texture depth query is not supported; it must be specified by the texture description."); +#endif + } else - TexDepth = 1; + TexDesc.Depth = 1; +#if GL_TEXTURE_INTERNAL_FORMAT GLint GlFormat = 0; glGetTexLevelParameteriv(QueryBindTarget, 0, GL_TEXTURE_INTERNAL_FORMAT, &GlFormat); CHECK_GL_ERROR( "Failed to get texture level 0 parameters through glGetTexLevelParameteriv()" ); @@ -105,17 +139,9 @@ static TextureDesc GetTextureDescFromGLHandle(DeviceContextGLImpl *pDeviceContex VERIFY(static_cast(GlFormat) == TexFormatToGLInternalTexFormat(TexDesc.Format), "Specified texture format (", GetTextureFormatAttribs(TexDesc.Format).Name,") does not match GL texture internal format (", GlFormat, ")"); else TexDesc.Format = GLInternalTexFormatToTexFormat(GlFormat); - - VERIFY_EXPR(TexWidth > 0 && TexHeight > 0 && TexDepth > 0); - VERIFY(TexDesc.Width == 0 || TexDesc.Width == static_cast(TexWidth), "Specified texture width (", TexDesc.Width, ") does not match the actual width (", TexWidth, ")"); - VERIFY(TexDesc.Height == 0 || TexDesc.Height == static_cast(TexHeight), "Specified texture height (", TexDesc.Height,") does not match the actual height (", TexHeight, ")"); - TexDesc.Width = static_cast(TexWidth); - TexDesc.Height = static_cast(TexHeight); - if (TexDesc.Type == RESOURCE_DIM_TEX_3D) - { - VERIFY(TexDesc.Depth == 0 || TexDesc.Depth == static_cast(TexDepth), "Specified texture depth (", TexDesc.Depth, ") does not match the actual depth (", TexDepth, ")"); - TexDesc.Depth = static_cast(TexDepth); - } +#else + VERIFY(TexDesc.Format != TEX_FORMAT_UNKNOWN, "Texture format query is not supported; it must be specified by the texture description."); +#endif // GL_TEXTURE_IMMUTABLE_LEVELS is only supported in GL4.3+ and GLES3.1+ GLint MipLevels = 0; @@ -297,7 +323,7 @@ void TextureBaseGL::UpdateData( GLContextState &CtxState, IDeviceContext *pCont { TTextureBase::UpdateData(pContext, MipLevel, Slice, DstBox, SubresData); - // GL_TEXTURE_UPDATE_BARRIER_BIT: + // GL_TEXTURE_UPDATE_BARRIER_BIT: // Writes to a texture via glTex( Sub )Image*, glCopyTex( Sub )Image*, glClearTex*Image, // glCompressedTex( Sub )Image*, and reads via glTexImage() after the barrier will reflect // data written by shaders prior to the barrier. Additionally, texture writes from these @@ -351,6 +377,7 @@ void TextureBaseGL :: CopyData(IDeviceContext *pContext, TTextureBase::CopyData( pContext, pSrcTexture, SrcMipLevel, SrcSlice, pSrcBox, DstMipLevel, DstSlice, DstX, DstY, DstZ ); +#if GL_ARB_copy_image if( glCopyImageSubData ) { GLint SrcSliceY = (SrcTexDesc.Type == RESOURCE_DIM_TEX_1D_ARRAY) ? SrcSlice : 0; @@ -376,6 +403,7 @@ void TextureBaseGL :: CopyData(IDeviceContext *pContext, CHECK_GL_ERROR( "glCopyImageSubData() failed" ); } else +#endif { const auto &FmtAttribs = GetDevice()->GetTextureFormatInfoExt( m_Desc.Format ); if( !FmtAttribs.ColorRenderable ) @@ -458,6 +486,7 @@ void TextureBaseGL::Unmap( IDeviceContext *pContext, Uint32 Subresource, MAP_TYP void TextureBaseGL::TextureMemoryBarrier( Uint32 RequiredBarriers, GLContextState &GLContextState ) { +#if GL_ARB_shader_image_load_store const Uint32 TextureBarriers = GL_TEXTURE_FETCH_BARRIER_BIT | GL_SHADER_IMAGE_ACCESS_BARRIER_BIT | @@ -468,6 +497,7 @@ void TextureBaseGL::TextureMemoryBarrier( Uint32 RequiredBarriers, GLContextStat VERIFY( (RequiredBarriers & ~TextureBarriers) == 0, "Inappropriate texture memory barrier flag" ); GLContextState.EnsureMemoryBarrier( RequiredBarriers, this ); +#endif } void TextureBaseGL::SetDefaultGLParameters() -- cgit v1.2.3