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

@@ -15,6 +15,8 @@
#ifndef DAWNNATIVE_OPENGL_OPENGLFUNCTIONSBASE_H_
#define DAWNNATIVE_OPENGL_OPENGLFUNCTIONSBASE_H_
#include <unordered_set>
#include "dawn/native/Error.h"
#include "dawn/native/opengl/opengl_platform.h"
@@ -30,6 +32,7 @@ namespace dawn::native::opengl {
{% endfor %}
{% endfor%}
bool IsGLExtensionSupported(const char* extension) const;
protected:
MaybeError LoadDesktopGLProcs(GetProcAddress getProc, int majorVersion, int minorVersion);
@@ -38,6 +41,9 @@ namespace dawn::native::opengl {
private:
template<typename T>
MaybeError LoadProc(GetProcAddress getProc, T* memberProc, const char* name);
void InitializeSupportedGLExtensions();
std::unordered_set<std::string> mSupportedGLExtensionsSet;
};
} // namespace dawn::native::opengl