[Drape] Remove GLES2-related code

Signed-off-by: renderexpert <expert@renderconsulting.co.uk>
This commit is contained in:
renderexpert
2025-01-20 11:05:45 +00:00
committed by Konstantin Pastbin
parent 705c715356
commit b23c2ba3e3
47 changed files with 235 additions and 623 deletions

View File

@@ -229,8 +229,7 @@ bool Framework::CreateDrapeEngine(JNIEnv * env, jobject jSurface, int densityDpi
LOG(LWARNING, ("Invalid GL context."));
return false;
}
p.m_apiVersion = oglFactory->IsSupportedOpenGLES3() ? dp::ApiVersion::OpenGLES3 :
dp::ApiVersion::OpenGLES2;
p.m_apiVersion = dp::ApiVersion::OpenGLES3;
p.m_surfaceWidth = oglFactory->GetWidth();
p.m_surfaceHeight = oglFactory->GetHeight();

View File

@@ -8,20 +8,16 @@
namespace android
{
static EGLint * getContextAttributesList(bool supportedES3)
static EGLint * getContextAttributesList()
{
static EGLint contextAttrList[] = {
EGL_CONTEXT_CLIENT_VERSION, 2,
EGL_NONE
};
static EGLint contextAttrListES3[] = {
EGL_CONTEXT_CLIENT_VERSION, 3,
EGL_NONE
};
return supportedES3 ? contextAttrListES3 : contextAttrList;
return contextAttrList;
}
AndroidOGLContext::AndroidOGLContext(bool supportedES3, EGLDisplay display, EGLSurface surface,
AndroidOGLContext::AndroidOGLContext(EGLDisplay display, EGLSurface surface,
EGLConfig config, AndroidOGLContext * contextToShareWith)
: m_nativeContext(EGL_NO_CONTEXT)
, m_surface(surface)
@@ -32,7 +28,7 @@ AndroidOGLContext::AndroidOGLContext(bool supportedES3, EGLDisplay display, EGLS
ASSERT(m_display != EGL_NO_DISPLAY, ());
EGLContext sharedContext = (contextToShareWith == NULL) ? EGL_NO_CONTEXT : contextToShareWith->m_nativeContext;
m_nativeContext = eglCreateContext(m_display, config, sharedContext, getContextAttributesList(supportedES3));
m_nativeContext = eglCreateContext(m_display, config, sharedContext, getContextAttributesList());
CHECK(m_nativeContext != EGL_NO_CONTEXT, ());
}

View File

@@ -10,7 +10,7 @@ namespace android
class AndroidOGLContext : public dp::OGLContext
{
public:
AndroidOGLContext(bool supportedES3, EGLDisplay display, EGLSurface surface,
AndroidOGLContext(EGLDisplay display, EGLSurface surface,
EGLConfig config, AndroidOGLContext * contextToShareWith);
~AndroidOGLContext();

View File

@@ -16,26 +16,13 @@
#define EGL_OPENGL_ES3_BIT 0x00000040
int constexpr kMinSdkVersionForES3 = 21;
namespace android
{
namespace
{
static EGLint * getConfigAttributesListRGB8(bool supportedES3)
static EGLint * getConfigAttributesListRGB8()
{
static EGLint attr_list[] = {
EGL_RED_SIZE, 8,
EGL_GREEN_SIZE, 8,
EGL_BLUE_SIZE, 8,
EGL_ALPHA_SIZE, 0,
EGL_STENCIL_SIZE, 0,
EGL_DEPTH_SIZE, 16,
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
EGL_SURFACE_TYPE, EGL_PBUFFER_BIT | EGL_WINDOW_BIT,
EGL_NONE
};
static EGLint attr_list_es3[] = {
EGL_RED_SIZE, 8,
EGL_GREEN_SIZE, 8,
EGL_BLUE_SIZE, 8,
@@ -46,33 +33,16 @@ static EGLint * getConfigAttributesListRGB8(bool supportedES3)
EGL_SURFACE_TYPE, EGL_PBUFFER_BIT | EGL_WINDOW_BIT,
EGL_NONE
};
return supportedES3 ? attr_list_es3 : attr_list;
return attr_list;
}
int const kMaxConfigCount = 40;
static EGLint * getConfigAttributesListR5G6B5()
{
// We do not support OpenGL ES3 for R5G6B5, because some Android devices
// are not able to create OpenGL context in such mode.
static EGLint attr_list[] = {
EGL_RED_SIZE, 5,
EGL_GREEN_SIZE, 6,
EGL_BLUE_SIZE, 5,
EGL_STENCIL_SIZE, 0,
EGL_DEPTH_SIZE, 16,
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
EGL_SURFACE_TYPE, EGL_PBUFFER_BIT | EGL_WINDOW_BIT,
EGL_NONE
};
return attr_list;
}
bool IsSupportedRGB8(EGLDisplay display, bool es3)
bool IsSupportedRGB8(EGLDisplay display)
{
EGLConfig configs[kMaxConfigCount];
int count = 0;
return eglChooseConfig(display, getConfigAttributesListRGB8(es3), configs,
return eglChooseConfig(display, getConfigAttributesListRGB8(), configs,
kMaxConfigCount, &count) == EGL_TRUE && count != 0;
}
@@ -90,7 +60,6 @@ AndroidOGLContextFactory::AndroidOGLContextFactory(JNIEnv * env, jobject jsurfac
, m_surfaceWidth(0)
, m_surfaceHeight(0)
, m_windowSurfaceValid(false)
, m_supportedES3(false)
{
m_display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
if (m_display == EGL_NO_DISPLAY)
@@ -106,10 +75,7 @@ AndroidOGLContextFactory::AndroidOGLContextFactory(JNIEnv * env, jobject jsurfac
return;
}
// Check ES3 availability.
bool const isES3Supported = IsSupportedRGB8(m_display, true /* es3 */) &&
android_get_device_api_level() >= kMinSdkVersionForES3;
m_supportedES3 = isES3Supported && gl3stubInit();
CHECK(gl3stubInit(), ("Could not initialize OpenGL ES3"));
SetSurface(env, jsurface);
@@ -266,7 +232,7 @@ dp::GraphicsContext * AndroidOGLContextFactory::GetDrawContext()
ASSERT(m_windowSurface != EGL_NO_SURFACE, ());
if (m_drawContext == nullptr)
{
m_drawContext = new AndroidOGLContext(m_supportedES3, m_display, m_windowSurface,
m_drawContext = new AndroidOGLContext(m_display, m_windowSurface,
m_config, m_uploadContext);
}
return m_drawContext;
@@ -278,7 +244,7 @@ dp::GraphicsContext * AndroidOGLContextFactory::GetResourcesUploadContext()
ASSERT(m_pixelbufferSurface != EGL_NO_SURFACE, ());
if (m_uploadContext == nullptr)
{
m_uploadContext = new AndroidOGLContext(m_supportedES3, m_display, m_pixelbufferSurface,
m_uploadContext = new AndroidOGLContext(m_display, m_pixelbufferSurface,
m_config, m_drawContext);
}
return m_uploadContext;
@@ -322,17 +288,15 @@ bool AndroidOGLContextFactory::CreateWindowSurface()
{
EGLConfig configs[kMaxConfigCount];
int count = 0;
if (eglChooseConfig(m_display, getConfigAttributesListRGB8(m_supportedES3), configs,
kMaxConfigCount, &count) != EGL_TRUE)
if (eglChooseConfig(m_display, getConfigAttributesListRGB8(), configs,
kMaxConfigCount, &count) == EGL_TRUE)
{
ASSERT(!m_supportedES3, ());
VERIFY(eglChooseConfig(m_display, getConfigAttributesListR5G6B5(), configs,
kMaxConfigCount, &count) == EGL_TRUE, ());
LOG(LDEBUG, ("Backbuffer format: R5G6B5"));
CHECK(IsSupportedRGB8(m_display), ("RGB8 is not suported on this device"));
LOG(LDEBUG, ("Backbuffer format: RGB8"));
}
else
{
LOG(LDEBUG, ("Backbuffer format: RGB8"));
CHECK(false, ("OpenGL ES3 is not supported"));
}
ASSERT(count > 0, ("Didn't find any configs."));

View File

@@ -33,8 +33,6 @@ public:
int GetHeight() const;
void UpdateSurfaceSize(int w, int h);
bool IsSupportedOpenGLES3() const { return m_supportedES3; }
private:
bool QuerySurfaceSize();
@@ -56,7 +54,6 @@ private:
int m_surfaceHeight;
bool m_windowSurfaceValid;
bool m_supportedES3;
bool m_isInitialized = false;
size_t m_initializationCounter = 0;