summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngineOpenGL
diff options
context:
space:
mode:
authorEgor Yusov <egor.yusov@gmail.com>2018-02-01 17:46:49 +0000
committerEgor Yusov <egor.yusov@gmail.com>2018-02-01 17:47:12 +0000
commit59082686112144343073de75986dbb8076b35689 (patch)
tree8b8932258ab952eb13b3fdc3ba13d77156d42e59 /Graphics/GraphicsEngineOpenGL
parentAdded info about MacOS to readme (diff)
downloadDiligentCore-59082686112144343073de75986dbb8076b35689.tar.gz
DiligentCore-59082686112144343073de75986dbb8076b35689.zip
Enabled IOS build
Diffstat (limited to 'Graphics/GraphicsEngineOpenGL')
-rw-r--r--Graphics/GraphicsEngineOpenGL/CMakeLists.txt19
-rw-r--r--Graphics/GraphicsEngineOpenGL/include/GLContext.h2
-rw-r--r--Graphics/GraphicsEngineOpenGL/include/GLContextIOS.h49
-rw-r--r--Graphics/GraphicsEngineOpenGL/include/GLStubsAndroid.h (renamed from Graphics/GraphicsEngineOpenGL/include/GLStubs.h)39
-rw-r--r--Graphics/GraphicsEngineOpenGL/include/GLStubsIOS.h534
-rw-r--r--Graphics/GraphicsEngineOpenGL/include/pch.h8
-rw-r--r--Graphics/GraphicsEngineOpenGL/interface/BaseInterfacesGL.h8
-rw-r--r--Graphics/GraphicsEngineOpenGL/interface/RenderDeviceFactoryOpenGL.h2
-rw-r--r--Graphics/GraphicsEngineOpenGL/src/BufferGLImpl.cpp32
-rw-r--r--Graphics/GraphicsEngineOpenGL/src/BufferViewGLImpl.cpp2
-rw-r--r--Graphics/GraphicsEngineOpenGL/src/DeviceContextGLImpl.cpp18
-rw-r--r--Graphics/GraphicsEngineOpenGL/src/GLContextIOS.mm119
-rw-r--r--Graphics/GraphicsEngineOpenGL/src/GLContextMacOS.mm (renamed from Graphics/GraphicsEngineOpenGL/src/GLContextMacOS.cpp)0
-rw-r--r--Graphics/GraphicsEngineOpenGL/src/GLContextState.cpp10
-rw-r--r--Graphics/GraphicsEngineOpenGL/src/GLProgramResources.cpp8
-rw-r--r--Graphics/GraphicsEngineOpenGL/src/GLStubsAndroid.cpp (renamed from Graphics/GraphicsEngineOpenGL/src/GLStubs.cpp)2
-rw-r--r--Graphics/GraphicsEngineOpenGL/src/RenderDeviceFactoryOpenGL.cpp2
-rw-r--r--Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLImpl.cpp4
-rw-r--r--Graphics/GraphicsEngineOpenGL/src/ShaderGLImpl.cpp21
-rw-r--r--Graphics/GraphicsEngineOpenGL/src/Texture2D_OGL.cpp4
-rw-r--r--Graphics/GraphicsEngineOpenGL/src/TextureBaseGL.cpp62
21 files changed, 902 insertions, 43 deletions
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/GLStubsAndroid.h
index d3d237ab..d51434fb 100644
--- a/Graphics/GraphicsEngineOpenGL/include/GLStubs.h
+++ b/Graphics/GraphicsEngineOpenGL/include/GLStubsAndroid.h
@@ -23,6 +23,8 @@
#pragma once
+#include "Errors.h"
+
// Define unsupported formats for OpenGL ES
#ifndef GL_RGBA16
# define GL_RGBA16 0x805B
@@ -143,6 +145,10 @@
#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
@@ -167,6 +173,10 @@
# 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
@@ -458,6 +468,10 @@
// 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
@@ -488,6 +502,14 @@ 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
@@ -577,6 +599,10 @@ extern PFNGLMEMORYBARRIERPROC glMemoryBarrier;
# 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
@@ -850,6 +876,9 @@ extern PFNGLMEMORYBARRIERPROC glMemoryBarrier;
#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
@@ -874,6 +903,10 @@ extern PFNGLMEMORYBARRIERPROC glMemoryBarrier;
#endif
/* ---------------------- ARB_tessellation_shader --------------------- */
+#ifndef GL_ARB_tessellation_shader
+# define GL_ARB_tessellation_shader 1
+#endif
+
#ifndef GL_PATCHES
# define GL_PATCHES 0xE
#endif
@@ -1008,8 +1041,12 @@ extern PFNGLFRAMEBUFFERTEXTURE1DPROC glFramebufferTexture1D;
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(); \ No newline at end of file
+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<typename T>
+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 <GLES2/gl2platform.h>
# else
# include <GLES3/gl3.h>
# include <GLES3/gl3ext.h>
# endif
+#elif defined(PLATFORM_IOS)
+
+# include <OpenGLES/ES3/gl.h>
+# include <OpenGLES/ES3/glext.h>
+# 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<DeviceContextGLImpl*>(pContext);
+ auto *pDeviceContextGL = ValidatedCast<DeviceContextGLImpl>(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<DeviceContextGLImpl*>(pContext);
-
+ auto *pDeviceContextGL = ValidatedCast<DeviceContextGLImpl>(pContext);
auto *pSrcBufferGL = static_cast<BufferGLImpl*>( 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<DeviceContextGLImpl*>(pContext);
-
- BufferMemoryBarrier(
+ auto *pDeviceContextGL = ValidatedCast<DeviceContextGLImpl>(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<DeviceContextGLImpl>(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<Int32>(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 <AppKit/AppKit.h>
+
+#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.mm
index 81e0efdd..81e0efdd 100644
--- a/Graphics/GraphicsEngineOpenGL/src/GLContextMacOS.cpp
+++ b/Graphics/GraphicsEngineOpenGL/src/GLContextMacOS.mm
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<GLint>(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<GLchar> 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/GLStubsAndroid.cpp
index 1407c2e2..643aad8a 100644
--- a/Graphics/GraphicsEngineOpenGL/src/GLStubs.cpp
+++ b/Graphics/GraphicsEngineOpenGL/src/GLStubsAndroid.cpp
@@ -22,7 +22,7 @@
*/
#include "pch.h"
-#include "GLStubs.h"
+#include "GLStubsAndroid.h"
#include <EGL/egl.h>
#define DECLARE_GL_FUNCTION(Func, FuncType, ...)\
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<Uint32>(TexWidth), "Specified texture width (", TexDesc.Width, ") does not match the actual width (", TexWidth, ")");
+ TexDesc.Width = static_cast<Uint32>(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<Uint32>(TexHeight), "Specified texture height (", TexDesc.Height,") does not match the actual height (", TexHeight, ")");
+ TexDesc.Height = static_cast<Uint32>(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<Uint32>(TexDepth), "Specified texture depth (", TexDesc.Depth, ") does not match the actual depth (", TexDepth, ")");
+ TexDesc.Depth = static_cast<Uint32>(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<GLenum>(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<Uint32>(TexWidth), "Specified texture width (", TexDesc.Width, ") does not match the actual width (", TexWidth, ")");
- VERIFY(TexDesc.Height == 0 || TexDesc.Height == static_cast<Uint32>(TexHeight), "Specified texture height (", TexDesc.Height,") does not match the actual height (", TexHeight, ")");
- TexDesc.Width = static_cast<Uint32>(TexWidth);
- TexDesc.Height = static_cast<Uint32>(TexHeight);
- if (TexDesc.Type == RESOURCE_DIM_TEX_3D)
- {
- VERIFY(TexDesc.Depth == 0 || TexDesc.Depth == static_cast<Uint32>(TexDepth), "Specified texture depth (", TexDesc.Depth, ") does not match the actual depth (", TexDepth, ")");
- TexDesc.Depth = static_cast<Uint32>(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()