Skip to content

Commit ef51831

Browse files
authored
Remove OpenGL ES 2.0 support (#2633)
* Remove OpenGL ES 2.0 support * Fix win32 dll link error [skip ci]
1 parent 766e972 commit ef51831

File tree

18 files changed

+32
-362
lines changed

18 files changed

+32
-362
lines changed

core/CMakeLists.txt

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -83,23 +83,17 @@ endif()
8383
# macos, linux or (win32, ios, tvos) not use GLES profile
8484
set(_GLES_PROFILE 0) # _GLES_PROFILE is the default GLES profile
8585

86-
if (AX_RENDER_API STREQUAL "gl")
87-
if(ANDROID) # android force use GLES profile
88-
set(_GLES_PROFILE 200)
89-
elseif(WINRT OR WASM) # winuwp/wasm fore use GLES profile
86+
if(AX_RENDER_API STREQUAL "gl")
87+
if(ANDROID OR WINRT OR WASM OR (WINDOWS AND AX_USE_ANGLE) OR IOS OR TVOS)
9088
set(_GLES_PROFILE 300)
91-
elseif((NOT MACOSX) AND(NOT LINUX)) # win32, ios, tvos
92-
if((WINDOWS AND AX_USE_ANGLE) OR IOS OR TVOS)
93-
set(_GLES_PROFILE 300)
94-
endif()
9589
endif()
9690
endif()
9791

9892
if(_GLES_PROFILE)
9993
set(AX_GLES_PROFILE ${_GLES_PROFILE} CACHE STRING "")
10094

101-
if(NOT(AX_GLES_PROFILE EQUAL 200 OR AX_GLES_PROFILE EQUAL 300))
102-
message(FATAL_ERROR "${MACOSX} Invalid GLES profile ${AX_GLES_PROFILE}, must be 200 or 300, default ${_GLES_PROFILE}")
95+
if(AX_GLES_PROFILE LESS 300)
96+
message(FATAL_ERROR "${MACOSX} Invalid GLES profile ${AX_GLES_PROFILE}, must be 300 or later, default ${_GLES_PROFILE}")
10397
endif()
10498
else() # force disable GLES profile
10599
set(AX_GLES_PROFILE 0 CACHE STRING "" FORCE)

core/math/Mat3.h

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@
44

55
NS_AX_MATH_BEGIN
66

7-
// both metal and GLSL3/ESSL3 mat3 is identical to mat3x4,
7+
// both metal, d3d11, gl-3.3, gles-3.0 mat3 in shader is identical to mat3x4,
88
// so provide this helper struct to construct mat3 match with GPU
99
struct Mat3
1010
{
11-
#if AX_GLES_PROFILE != 200
1211
enum Index
1312
{
1413
_M00 = 0,
@@ -21,20 +20,7 @@ struct Mat3
2120
_M21 = 9,
2221
_M22 = 10
2322
};
24-
#else
25-
enum Index
26-
{
27-
_M00 = 0,
28-
_M01 = 1,
29-
_M02 = 2,
30-
_M10 = 3,
31-
_M11 = 4,
32-
_M12 = 5,
33-
_M20 = 6,
34-
_M21 = 7,
35-
_M22 = 8
36-
};
37-
#endif
23+
3824
Mat3() = default;
3925
Mat3(float m00, float m01, float m02, float m10, float m11, float m12, float m20, float m21, float m22)
4026
{
@@ -57,19 +43,11 @@ struct Mat3
5743
}
5844
float* operator[](size_t rowIndex)
5945
{
60-
#if AX_GLES_PROFILE != 200
6146
assert(rowIndex < 3);
6247
return &m[rowIndex * 4];
63-
#else
64-
assert(rowIndex < 2);
65-
return &m[rowIndex * 3];
66-
#endif
6748
}
68-
#if AX_GLES_PROFILE != 200
49+
6950
float m[12] = {};
70-
#else
71-
float m[9] = {};
72-
#endif
7351
};
7452

7553
NS_AX_MATH_END

core/platform/PlatformConfig.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,9 @@ THE SOFTWARE.
126126
// render configure
127127
//////////////////////////////////////////////////////////////////////////
128128

129-
#define AX_RENDER_API_GL 1
130-
#define AX_RENDER_API_MTL 2
131-
#define AX_RENDER_API_D3D 3
129+
#define AX_RENDER_API_GL 1
130+
#define AX_RENDER_API_MTL 2
131+
#define AX_RENDER_API_D3D 3
132132

133133
#ifndef AX_RENDER_API
134134
# if defined(__APPLE__)
@@ -150,9 +150,9 @@ Linux: Desktop GL/Vulkan
150150
// mac/iOS/android use system builtin GL/GLES, not ANGLE
151151
// Windows: use ANGLE GLES
152152
#ifndef AX_GLES_PROFILE
153-
# if defined(__ANDROID__)
154-
# define AX_GLES_PROFILE 200
155-
# elif (AX_TARGET_PLATFORM == AX_PLATFORM_WINRT)
153+
# if defined(__ANDROID__) || defined(_WIN32) || \
154+
(AX_RENDER_API == AX_RENDER_API_GL && \
155+
(AX_TARGET_PLATFORM == AX_PLATFORM_IOS || AX_TARGET_PLATFORM == AX_PLATFORM_TVOS))
156156
# define AX_GLES_PROFILE 300
157157
# else
158158
# define AX_GLES_PROFILE 0

core/renderer/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ if(AX_RENDER_API STREQUAL "gl")
8080
renderer/backend/opengl/OpenGLState.h
8181
renderer/backend/opengl/BufferGL.h
8282
renderer/backend/opengl/CommandBufferGL.h
83-
renderer/backend/opengl/CommandBufferGLES2.h
8483
renderer/backend/opengl/DepthStencilStateGL.h
8584
renderer/backend/opengl/DriverGL.h
8685
renderer/backend/opengl/MacrosGL.h
@@ -96,7 +95,6 @@ if(AX_RENDER_API STREQUAL "gl")
9695
renderer/backend/opengl/OpenGLState.cpp
9796
renderer/backend/opengl/BufferGL.cpp
9897
renderer/backend/opengl/CommandBufferGL.cpp
99-
renderer/backend/opengl/CommandBufferGLES2.cpp
10098
renderer/backend/opengl/DepthStencilStateGL.cpp
10199
renderer/backend/opengl/DriverGL.cpp
102100
renderer/backend/opengl/ProgramGL.cpp

core/renderer/backend/ProgramManager.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,6 @@ class AX_DLL ProgramManager
151151
static ProgramManager* _sharedProgramManager; ///< A shared instance of the program cache.
152152
};
153153

154-
using ProgramCache = ProgramManager; // for compatible
155-
156154
// end of _backend group
157155
/// @}
158156
}

core/renderer/backend/ProgramState.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -266,13 +266,8 @@ void ProgramState::setVertexUniform(int location, const void* data, std::size_t
266266
if (location < 0 || offset < 0)
267267
return;
268268

269-
#if AX_GLES_PROFILE != 200
270269
assert(location + offset + size <= _vertexUniformBufferSize);
271270
memcpy(_uniformBuffers.data() + location + offset, data, size);
272-
#else
273-
assert(offset + size <= _vertexUniformBufferSize);
274-
memcpy(_uniformBuffers.data() + offset, data, size);
275-
#endif
276271
}
277272

278273
#if AX_RENDER_API == AX_RENDER_API_MTL || AX_RENDER_API == AX_RENDER_API_D3D

core/renderer/backend/opengl/CommandBufferGL.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@
4040

4141
namespace ax::backend {
4242

43-
#if AX_GLES_PROFILE != 200 && AX_TARGET_PLATFORM != AX_PLATFORM_WASM
43+
// !!Note: WebGL 2.0 on (Open GELS 3.0) not support map buffer range
44+
#if AX_TARGET_PLATFORM != AX_PLATFORM_WASM
4445
# define AX_HAVE_MAP_BUFFER_RANGE 1
4546
#else
4647
# define AX_HAVE_MAP_BUFFER_RANGE 0

core/renderer/backend/opengl/CommandBufferGLES2.cpp

Lines changed: 0 additions & 64 deletions
This file was deleted.

core/renderer/backend/opengl/CommandBufferGLES2.h

Lines changed: 0 additions & 59 deletions
This file was deleted.

core/renderer/backend/opengl/DriverGL.cpp

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,6 @@
3535
#include "RenderTargetGL.h"
3636
#include "MacrosGL.h"
3737
#include "renderer/backend/ProgramManager.h"
38-
#if !defined(__APPLE__) && AX_TARGET_PLATFORM != AX_PLATFORM_WINRT
39-
# include "CommandBufferGLES2.h"
40-
#endif
4138

4239
#include "base/axstd.h"
4340
#include "base/format.h"
@@ -61,7 +58,6 @@ static inline uint32_t hashString(std::string_view str)
6158
template <typename _Fty>
6259
static void GL_EnumAllExtensions(_Fty&& func)
6360
{
64-
#if AX_GLES_PROFILE != 200 // NOT GLES2.0
6561
GLint NumberOfExtensions{0};
6662
glGetIntegerv(GL_NUM_EXTENSIONS, &NumberOfExtensions);
6763
for (GLint i = 0; i < NumberOfExtensions; ++i)
@@ -70,16 +66,6 @@ static void GL_EnumAllExtensions(_Fty&& func)
7066
if (extName)
7167
func(std::string_view{extName});
7268
}
73-
#else
74-
auto extensions = (const char*)glGetString(GL_EXTENSIONS);
75-
if (extensions)
76-
{
77-
axstd::split_of_cb(extensions, " \f\n\r\t\v", [&func](const char* start, const char* end, char /*delim*/) {
78-
if (start != end)
79-
func(std::string_view{start, static_cast<size_t>(end - start)});
80-
});
81-
}
82-
#endif
8369
}
8470

8571
DriverBase* DriverBase::getInstance()
@@ -166,11 +152,9 @@ DriverGL::DriverGL()
166152

167153
glGetIntegerv(GL_FRAMEBUFFER_BINDING, &_defaultFBO);
168154

169-
#if AX_GLES_PROFILE != 200
170-
glGenVertexArrays(1, &_defaultVAO);
171-
glBindVertexArray(_defaultVAO);
155+
resetState();
156+
172157
CHECK_GL_ERROR_DEBUG();
173-
#endif
174158
}
175159

176160
DriverGL::~DriverGL()
@@ -185,11 +169,7 @@ GLint DriverGL::getDefaultFBO() const
185169

186170
CommandBuffer* DriverGL::createCommandBuffer(void*)
187171
{
188-
#if !defined(__APPLE__) && AX_TARGET_PLATFORM != AX_PLATFORM_WINRT
189-
return !isGLES2Only() ? new CommandBufferGL() : new CommandBufferGLES2();
190-
#else
191172
return new CommandBufferGL();
192-
#endif
193173
}
194174

195175
Buffer* DriverGL::createBuffer(std::size_t size, BufferType type, BufferUsage usage)

0 commit comments

Comments
 (0)