mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-13 23:26:24 +00:00
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:
committed by
Dawn LUCI CQ
parent
43ffb09247
commit
55183e6c3a
@@ -36,11 +36,15 @@ MaybeError OpenGLFunctionsBase::LoadOpenGLESProcs(GetProcAddress getProc, int ma
|
||||
|
||||
{% endfor %}
|
||||
|
||||
InitializeSupportedGLExtensions();
|
||||
|
||||
{% for block in extension_gles_blocks %}
|
||||
// {{block.extension}}
|
||||
{% for proc in block.procs %}
|
||||
DAWN_TRY(LoadProc(getProc, &{{proc.ProcName()}}, "{{proc.glProcName()}}"));
|
||||
if (IsGLExtensionSupported("{{block.extension}}")) {
|
||||
{% for proc in block.procs %}
|
||||
DAWN_TRY(LoadProc(getProc, &{{proc.ProcName()}}, "{{proc.glProcName()}}"));
|
||||
{% endfor %}
|
||||
}
|
||||
{% endfor %}
|
||||
|
||||
return {};
|
||||
@@ -57,14 +61,33 @@ MaybeError OpenGLFunctionsBase::LoadDesktopGLProcs(GetProcAddress getProc, int m
|
||||
|
||||
{% endfor %}
|
||||
|
||||
InitializeSupportedGLExtensions();
|
||||
|
||||
{% for block in extension_desktop_gl_blocks %}
|
||||
// {{block.extension}}
|
||||
{% for proc in block.procs %}
|
||||
DAWN_TRY(LoadProc(getProc, &{{proc.ProcName()}}, "{{proc.glProcName()}}"));
|
||||
{% endfor %}
|
||||
if (IsGLExtensionSupported("{{block.extension}}")) {
|
||||
{% for proc in block.procs %}
|
||||
DAWN_TRY(LoadProc(getProc, &{{proc.ProcName()}}, "{{proc.glProcName()}}"));
|
||||
{% endfor %}
|
||||
}
|
||||
{% endfor %}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
void OpenGLFunctionsBase::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 OpenGLFunctionsBase::IsGLExtensionSupported(const char* extension) const {
|
||||
ASSERT(extension != nullptr);
|
||||
return mSupportedGLExtensionsSet.count(extension) != 0;
|
||||
}
|
||||
|
||||
} // namespace dawn::native::opengl
|
||||
|
||||
Reference in New Issue
Block a user