OpenGL: only load extension procs if extension supported.

Only load extension entry points if the extension is supported.

From the eglGetProcAddress manpage:

"A non-NULL return value does not guarantee that an extension function
is actually supported at runtime. The client must also make a
corresponding query, such as glGetString(GL_EXTENSIONS) for OpenGL and
OpenGL ES extensions [...] to determine if a function is supported by
EGL or a specific client API context."

This required moving extension initialization from OpenGLFunctions
into OpenGLFunctionsBase.

Change-Id: Ib4e8360ba455818701990b4476689b651d097ca8
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/121760
Commit-Queue: Stephen White <senorblanco@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
Stephen White
2023-02-27 19:31:08 +00:00
committed by Dawn LUCI CQ
parent 43ffb09247
commit 55183e6c3a
4 changed files with 34 additions and 29 deletions

View File

@@ -26,26 +26,9 @@ MaybeError OpenGLFunctions::Initialize(GetProcAddress getProc) {
DAWN_TRY(LoadDesktopGLProcs(getProc, mVersion.GetMajor(), mVersion.GetMinor()));
}
InitializeSupportedGLExtensions();
return {};
}
void OpenGLFunctions::InitializeSupportedGLExtensions() {
int32_t numExtensions;
GetIntegerv(GL_NUM_EXTENSIONS, &numExtensions);
for (int32_t i = 0; i < numExtensions; ++i) {
const char* extensionName = reinterpret_cast<const char*>(GetStringi(GL_EXTENSIONS, i));
mSupportedGLExtensionsSet.insert(extensionName);
}
}
bool OpenGLFunctions::IsGLExtensionSupported(const char* extension) const {
ASSERT(extension != nullptr);
return mSupportedGLExtensionsSet.count(extension) != 0;
}
const OpenGLVersion& OpenGLFunctions::GetVersion() const {
return mVersion;
}

View File

@@ -16,7 +16,6 @@
#define SRC_DAWN_NATIVE_OPENGL_OPENGLFUNCTIONS_H_
#include <string>
#include <unordered_set>
#include "dawn/native/opengl/OpenGLFunctionsBase_autogen.h"
#include "dawn/native/opengl/OpenGLVersion.h"
@@ -31,14 +30,8 @@ struct OpenGLFunctions : OpenGLFunctionsBase {
bool IsAtLeastGL(uint32_t majorVersion, uint32_t minorVersion) const;
bool IsAtLeastGLES(uint32_t majorVersion, uint32_t minorVersion) const;
bool IsGLExtensionSupported(const char* extension) const;
private:
void InitializeSupportedGLExtensions();
OpenGLVersion mVersion;
std::unordered_set<std::string> mSupportedGLExtensionsSet;
};
} // namespace dawn::native::opengl