mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-06-06 06:33:30 +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:
parent
43ffb09247
commit
55183e6c3a
@ -36,11 +36,15 @@ MaybeError OpenGLFunctionsBase::LoadOpenGLESProcs(GetProcAddress getProc, int ma
|
|||||||
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
|
InitializeSupportedGLExtensions();
|
||||||
|
|
||||||
{% for block in extension_gles_blocks %}
|
{% for block in extension_gles_blocks %}
|
||||||
// {{block.extension}}
|
// {{block.extension}}
|
||||||
{% for proc in block.procs %}
|
if (IsGLExtensionSupported("{{block.extension}}")) {
|
||||||
DAWN_TRY(LoadProc(getProc, &{{proc.ProcName()}}, "{{proc.glProcName()}}"));
|
{% for proc in block.procs %}
|
||||||
|
DAWN_TRY(LoadProc(getProc, &{{proc.ProcName()}}, "{{proc.glProcName()}}"));
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
@ -57,14 +61,33 @@ MaybeError OpenGLFunctionsBase::LoadDesktopGLProcs(GetProcAddress getProc, int m
|
|||||||
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
|
InitializeSupportedGLExtensions();
|
||||||
|
|
||||||
{% for block in extension_desktop_gl_blocks %}
|
{% for block in extension_desktop_gl_blocks %}
|
||||||
// {{block.extension}}
|
// {{block.extension}}
|
||||||
{% for proc in block.procs %}
|
if (IsGLExtensionSupported("{{block.extension}}")) {
|
||||||
DAWN_TRY(LoadProc(getProc, &{{proc.ProcName()}}, "{{proc.glProcName()}}"));
|
{% for proc in block.procs %}
|
||||||
{% endfor %}
|
DAWN_TRY(LoadProc(getProc, &{{proc.ProcName()}}, "{{proc.glProcName()}}"));
|
||||||
|
{% endfor %}
|
||||||
|
}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
return {};
|
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
|
} // namespace dawn::native::opengl
|
||||||
|
@ -15,6 +15,8 @@
|
|||||||
#ifndef DAWNNATIVE_OPENGL_OPENGLFUNCTIONSBASE_H_
|
#ifndef DAWNNATIVE_OPENGL_OPENGLFUNCTIONSBASE_H_
|
||||||
#define DAWNNATIVE_OPENGL_OPENGLFUNCTIONSBASE_H_
|
#define DAWNNATIVE_OPENGL_OPENGLFUNCTIONSBASE_H_
|
||||||
|
|
||||||
|
#include <unordered_set>
|
||||||
|
|
||||||
#include "dawn/native/Error.h"
|
#include "dawn/native/Error.h"
|
||||||
#include "dawn/native/opengl/opengl_platform.h"
|
#include "dawn/native/opengl/opengl_platform.h"
|
||||||
|
|
||||||
@ -30,6 +32,7 @@ namespace dawn::native::opengl {
|
|||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
{% endfor%}
|
{% endfor%}
|
||||||
|
bool IsGLExtensionSupported(const char* extension) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
MaybeError LoadDesktopGLProcs(GetProcAddress getProc, int majorVersion, int minorVersion);
|
MaybeError LoadDesktopGLProcs(GetProcAddress getProc, int majorVersion, int minorVersion);
|
||||||
@ -38,6 +41,9 @@ namespace dawn::native::opengl {
|
|||||||
private:
|
private:
|
||||||
template<typename T>
|
template<typename T>
|
||||||
MaybeError LoadProc(GetProcAddress getProc, T* memberProc, const char* name);
|
MaybeError LoadProc(GetProcAddress getProc, T* memberProc, const char* name);
|
||||||
|
void InitializeSupportedGLExtensions();
|
||||||
|
|
||||||
|
std::unordered_set<std::string> mSupportedGLExtensionsSet;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace dawn::native::opengl
|
} // namespace dawn::native::opengl
|
||||||
|
@ -26,26 +26,9 @@ MaybeError OpenGLFunctions::Initialize(GetProcAddress getProc) {
|
|||||||
DAWN_TRY(LoadDesktopGLProcs(getProc, mVersion.GetMajor(), mVersion.GetMinor()));
|
DAWN_TRY(LoadDesktopGLProcs(getProc, mVersion.GetMajor(), mVersion.GetMinor()));
|
||||||
}
|
}
|
||||||
|
|
||||||
InitializeSupportedGLExtensions();
|
|
||||||
|
|
||||||
return {};
|
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 {
|
const OpenGLVersion& OpenGLFunctions::GetVersion() const {
|
||||||
return mVersion;
|
return mVersion;
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
#define SRC_DAWN_NATIVE_OPENGL_OPENGLFUNCTIONS_H_
|
#define SRC_DAWN_NATIVE_OPENGL_OPENGLFUNCTIONS_H_
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <unordered_set>
|
|
||||||
|
|
||||||
#include "dawn/native/opengl/OpenGLFunctionsBase_autogen.h"
|
#include "dawn/native/opengl/OpenGLFunctionsBase_autogen.h"
|
||||||
#include "dawn/native/opengl/OpenGLVersion.h"
|
#include "dawn/native/opengl/OpenGLVersion.h"
|
||||||
@ -31,14 +30,8 @@ struct OpenGLFunctions : OpenGLFunctionsBase {
|
|||||||
bool IsAtLeastGL(uint32_t majorVersion, uint32_t minorVersion) const;
|
bool IsAtLeastGL(uint32_t majorVersion, uint32_t minorVersion) const;
|
||||||
bool IsAtLeastGLES(uint32_t majorVersion, uint32_t minorVersion) const;
|
bool IsAtLeastGLES(uint32_t majorVersion, uint32_t minorVersion) const;
|
||||||
|
|
||||||
bool IsGLExtensionSupported(const char* extension) const;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void InitializeSupportedGLExtensions();
|
|
||||||
|
|
||||||
OpenGLVersion mVersion;
|
OpenGLVersion mVersion;
|
||||||
|
|
||||||
std::unordered_set<std::string> mSupportedGLExtensionsSet;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace dawn::native::opengl
|
} // namespace dawn::native::opengl
|
||||||
|
Loading…
x
Reference in New Issue
Block a user