From b78a1729d3c1660da6e45298c36a2f007150af7a Mon Sep 17 00:00:00 2001 From: "Eunki, Hong" Date: Wed, 22 Feb 2023 04:53:33 +0900 Subject: [PATCH] [Tizen] CleanUp gles version setter + Get exact FBO MSAA sample level Avoid some useless duplicated GLES version setter. It will reduce complexity of gles version relative logics. Change-Id: Ibffe2894d9fab34188861d77aad28593aea6ac54 Signed-off-by: Eunki, Hong --- .../graphics/gles-impl/gles-graphics-types.h | 5 ++++ dali/internal/graphics/gles/egl-graphics.cpp | 30 ++++++++++------------ dali/internal/graphics/gles/egl-graphics.h | 8 +----- dali/internal/graphics/gles/gl-implementation.h | 27 ++++++++++++++----- 4 files changed, 41 insertions(+), 29 deletions(-) diff --git a/dali/internal/graphics/gles-impl/gles-graphics-types.h b/dali/internal/graphics/gles-impl/gles-graphics-types.h index 836439d..5e0025e 100644 --- a/dali/internal/graphics/gles-impl/gles-graphics-types.h +++ b/dali/internal/graphics/gles-impl/gles-graphics-types.h @@ -1283,6 +1283,11 @@ struct GLIndexFormat format = GL_UNSIGNED_SHORT; break; } + case Format::R32_UINT: + { + format = GL_UNSIGNED_INT; + break; + } default: { format = 0; diff --git a/dali/internal/graphics/gles/egl-graphics.cpp b/dali/internal/graphics/gles/egl-graphics.cpp index 15e17f1..d1f79e9 100644 --- a/dali/internal/graphics/gles/egl-graphics.cpp +++ b/dali/internal/graphics/gles/egl-graphics.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Samsung Electronics Co., Ltd. + * Copyright (c) 2023 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -54,18 +54,6 @@ EglGraphics::~EglGraphics() { } -void EglGraphics::SetGlesVersion(const int32_t glesVersion) -{ - if(mEglImplementation) - { - mEglImplementation->SetGlesVersion(glesVersion); - } - - mGLES->SetGlesVersion(glesVersion); - - mGraphicsController.SetGLESVersion(static_cast(glesVersion)); -} - void EglGraphics::SetIsSurfacelessContextSupported(const bool isSupported) { mGLES->SetIsSurfacelessContextSupported(isSupported); @@ -152,7 +140,12 @@ void EglGraphics::ConfigureSurface(Dali::RenderSurfaceInterface* surface) if(!mEglImplementation->ChooseConfig(true, COLOR_DEPTH_32)) { // Retry to use OpenGL es 2.0 - SetGlesVersion(20); + mEglImplementation->SetGlesVersion(20); + + // Mark gles that we will use gles 2.0 version. + // After this call, we will not change mGLES version anymore. + mGLES->SetGlesVersion(20); + mEglImplementation->ChooseConfig(true, COLOR_DEPTH_32); } @@ -176,8 +169,13 @@ void EglGraphics::ConfigureSurface(Dali::RenderSurfaceInterface* surface) } } - mGLES->ContextCreated(); - SetGlesVersion(mGLES->GetGlesVersion()); + mGLES->ContextCreated(); // After this call, we can know exact gles version. + auto glesVersion = mGLES->GetGlesVersion(); + + // Set more detail GLES version to egl and graphics controller. + // Note. usually we don't need EGL client's minor version. So don't need to choose config one more time. + mEglImplementation->SetGlesVersion(glesVersion); + mGraphicsController.SetGLESVersion(static_cast(glesVersion)); } void EglGraphics::Shutdown() diff --git a/dali/internal/graphics/gles/egl-graphics.h b/dali/internal/graphics/gles/egl-graphics.h index 48dd0b7..88558ba 100644 --- a/dali/internal/graphics/gles/egl-graphics.h +++ b/dali/internal/graphics/gles/egl-graphics.h @@ -2,7 +2,7 @@ #define DALI_INTERNAL_BASE_GRAPHICS_IMPLEMENTATION_H /* - * Copyright (c) 2022 Samsung Electronics Co., Ltd. + * Copyright (c) 2023 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -67,12 +67,6 @@ public: void ConfigureSurface(Dali::RenderSurfaceInterface* surface) override; /** - * Set gles version - * Default version is gles 3.0 - */ - void SetGlesVersion(const int32_t glesVersion); - - /** * Set whether the surfaceless context is supported * @param[in] isSupported Whether the surfaceless context is supported */ diff --git a/dali/internal/graphics/gles/gl-implementation.h b/dali/internal/graphics/gles/gl-implementation.h index 2ba344a..b252942 100644 --- a/dali/internal/graphics/gles/gl-implementation.h +++ b/dali/internal/graphics/gles/gl-implementation.h @@ -2,7 +2,7 @@ #define DALI_INTERNAL_GL_IMPLEMENTATION_H /* - * Copyright (c) 2022 Samsung Electronics Co., Ltd. + * Copyright (c) 2023 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -43,9 +43,12 @@ namespace Adaptor { namespace { -static constexpr int32_t INITIAL_GLES_VERSION = 30; -static constexpr int32_t GLES_VERSION_SUPPORT_BLEND_EQUATION_ADVANCED = 32; -static constexpr const char* LEGACY_SHADING_LANGUAGE_VERSION = "100"; +static constexpr int32_t INITIAL_GLES_VERSION = 30; +static constexpr int32_t GLES_VERSION_SUPPORT_BLEND_EQUATION_ADVANCED = 32; + +static constexpr int32_t MINIMUM_GLES_VERSION_GET_MAXIMUM_MULTISAMPLES_TO_TEXTURE = 30; + +static constexpr const char* LEGACY_SHADING_LANGUAGE_VERSION = "100"; static constexpr const char* DEFAULT_SAMPLER_TYPE = "sampler2D"; @@ -108,6 +111,7 @@ public: { glGetIntegerv(GL_MAX_TEXTURE_SIZE, &mMaxTextureSize); + // Since gles 2.0 didn't return well for GL_MAJOR_VERSION and GL_MINOR_VERSION, // Only change gles version for the device that support above gles 3.0. if(mGlesVersion >= INITIAL_GLES_VERSION) { @@ -130,7 +134,18 @@ public: if(IsMultisampledRenderToTextureSupported()) { - glGetIntegerv(GL_MAX_SAMPLES_EXT, &mMaxTextureSamples); + mMaxTextureSamples = 0; + + if(mGlesVersion >= MINIMUM_GLES_VERSION_GET_MAXIMUM_MULTISAMPLES_TO_TEXTURE) + { + // Try to get maximum FBO MSAA sampling level from GL_RENDERBUFFER first. + // If false, than ask again to GL_MAX_SAMPLES_EXT. + GetInternalformativ(GL_RENDERBUFFER, GL_RGBA8, GL_SAMPLES, 1, &mMaxTextureSamples); + } + if(mMaxTextureSamples == 0) + { + glGetIntegerv(GL_MAX_SAMPLES_EXT, &mMaxTextureSamples); + } } if(!mShadingLanguageVersionCached) @@ -360,7 +375,7 @@ public: return mMaxTextureSamples; } - int GetGlesVersion() + int32_t GetGlesVersion() { ConditionalWait::ScopedLock lock(mContextCreatedWaitCondition); if(!mIsContextCreated) -- 2.7.4