mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-12 14:18:31 +09:00
[Fix] (MG_State/EGLState, MG_Impl/GLImpl): report OpenGL context flags
This commit is contained in:
@@ -22,9 +22,24 @@
|
|||||||
#include <MG_State/GLState/FramebufferState/FramebufferObject.h>
|
#include <MG_State/GLState/FramebufferState/FramebufferObject.h>
|
||||||
#include <MG_Util/Texture/TextureFormatProcessor.h>
|
#include <MG_Util/Texture/TextureFormatProcessor.h>
|
||||||
#include <MG_Backend/BackendObjects.h>
|
#include <MG_Backend/BackendObjects.h>
|
||||||
|
#if !defined(_WIN32)
|
||||||
|
#include <dlfcn.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace MobileGL::MG_Impl::GLImpl {
|
namespace MobileGL::MG_Impl::GLImpl {
|
||||||
namespace {
|
namespace {
|
||||||
|
bool TryGetNativeContextFlags(GLint* flags) {
|
||||||
|
#if !defined(_WIN32)
|
||||||
|
using GLGetIntegervFn = void (*)(GLenum, GLint*);
|
||||||
|
static auto* nextGetIntegerv = reinterpret_cast<GLGetIntegervFn>(dlsym(RTLD_NEXT, "glGetIntegerv"));
|
||||||
|
if (nextGetIntegerv) {
|
||||||
|
nextGetIntegerv(GL_CONTEXT_FLAGS, flags);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
enum class IndexedBufferQueryKind {
|
enum class IndexedBufferQueryKind {
|
||||||
Binding,
|
Binding,
|
||||||
Start,
|
Start,
|
||||||
@@ -896,9 +911,13 @@ namespace MobileGL::MG_Impl::GLImpl {
|
|||||||
case GL_DEBUG_GROUP_STACK_DEPTH:
|
case GL_DEBUG_GROUP_STACK_DEPTH:
|
||||||
*params = 0; // debug-group entrypoints are stubbed
|
*params = 0; // debug-group entrypoints are stubbed
|
||||||
return;
|
return;
|
||||||
case GL_CONTEXT_FLAGS:
|
case GL_CONTEXT_FLAGS: {
|
||||||
*params = 0; // contexts are created without debug/robust/forward-compatible flags
|
*params = MG_State::pEGLContext ? MG_State::pEGLContext->GetCurrentContextFlags() : 0;
|
||||||
|
if (*params == 0) {
|
||||||
|
TryGetNativeContextFlags(params);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
case GL_CULL_FACE:
|
case GL_CULL_FACE:
|
||||||
*params = MG_State::pGLContext->IsCapabilityEnabled(CapabilityInput::CullFace) ? GL_TRUE : GL_FALSE;
|
*params = MG_State::pGLContext->IsCapabilityEnabled(CapabilityInput::CullFace) ? GL_TRUE : GL_FALSE;
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
// End of Source File Header
|
// End of Source File Header
|
||||||
|
|
||||||
#include "Core.h"
|
#include "Core.h"
|
||||||
|
#include <EGL/eglext.h>
|
||||||
|
|
||||||
namespace MobileGL {
|
namespace MobileGL {
|
||||||
namespace MG_State {
|
namespace MG_State {
|
||||||
@@ -611,6 +612,32 @@ namespace MobileGL {
|
|||||||
if (auto value = ParseAttribValue(attribList, EGL_CONTEXT_OPENGL_PROFILE_MASK); value) {
|
if (auto value = ParseAttribValue(attribList, EGL_CONTEXT_OPENGL_PROFILE_MASK); value) {
|
||||||
contextObject.OpenGLProfileMask = *value;
|
contextObject.OpenGLProfileMask = *value;
|
||||||
}
|
}
|
||||||
|
if (auto value = ParseAttribValue(attribList, EGL_CONTEXT_FLAGS_KHR); value) {
|
||||||
|
contextObject.EGLContextFlags = *value;
|
||||||
|
if (*value & EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR) {
|
||||||
|
contextObject.OpenGLContextFlags |= GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT;
|
||||||
|
}
|
||||||
|
if (*value & EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR) {
|
||||||
|
contextObject.OpenGLContextFlags |= GL_CONTEXT_FLAG_DEBUG_BIT;
|
||||||
|
}
|
||||||
|
if (*value & EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR) {
|
||||||
|
contextObject.OpenGLContextFlags |= GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (auto value = ParseAttribValue(attribList, EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE);
|
||||||
|
value && *value == EGL_TRUE) {
|
||||||
|
contextObject.EGLContextFlags |= EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR;
|
||||||
|
contextObject.OpenGLContextFlags |= GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT;
|
||||||
|
}
|
||||||
|
if (auto value = ParseAttribValue(attribList, EGL_CONTEXT_OPENGL_DEBUG); value && *value == EGL_TRUE) {
|
||||||
|
contextObject.EGLContextFlags |= EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR;
|
||||||
|
contextObject.OpenGLContextFlags |= GL_CONTEXT_FLAG_DEBUG_BIT;
|
||||||
|
}
|
||||||
|
if (auto value = ParseAttribValue(attribList, EGL_CONTEXT_OPENGL_ROBUST_ACCESS);
|
||||||
|
value && *value == EGL_TRUE) {
|
||||||
|
contextObject.EGLContextFlags |= EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR;
|
||||||
|
contextObject.OpenGLContextFlags |= GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT;
|
||||||
|
}
|
||||||
|
|
||||||
const auto context = EncodeHandle<EGLContextHandle>(m_nextContextHandle++);
|
const auto context = EncodeHandle<EGLContextHandle>(m_nextContextHandle++);
|
||||||
m_contexts[context] = contextObject;
|
m_contexts[context] = contextObject;
|
||||||
@@ -668,6 +695,9 @@ namespace MobileGL {
|
|||||||
case EGL_CONTEXT_MINOR_VERSION:
|
case EGL_CONTEXT_MINOR_VERSION:
|
||||||
*value = contextObject->MinorVersion;
|
*value = contextObject->MinorVersion;
|
||||||
return true;
|
return true;
|
||||||
|
case EGL_CONTEXT_FLAGS_KHR:
|
||||||
|
*value = contextObject->EGLContextFlags;
|
||||||
|
return true;
|
||||||
case EGL_CONFIG_ID: {
|
case EGL_CONFIG_ID: {
|
||||||
const auto* cfg = TryGetConfig(contextObject->Config);
|
const auto* cfg = TryGetConfig(contextObject->Config);
|
||||||
if (!cfg) {
|
if (!cfg) {
|
||||||
@@ -709,6 +739,16 @@ namespace MobileGL {
|
|||||||
ctx->MajorVersion > 3 || (ctx->MajorVersion == 3 && ctx->MinorVersion >= 1);
|
ctx->MajorVersion > 3 || (ctx->MajorVersion == 3 && ctx->MinorVersion >= 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EGLint EGLContext::GetCurrentContextFlags() const {
|
||||||
|
const std::lock_guard<std::recursive_mutex> lock(m_mutex);
|
||||||
|
auto currentIt = m_threadCurrents.find(CurrentThreadKey());
|
||||||
|
if (currentIt == m_threadCurrents.end()) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
const auto* ctx = TryGetContext(currentIt->second.Context);
|
||||||
|
return ctx ? ctx->OpenGLContextFlags : 0;
|
||||||
|
}
|
||||||
|
|
||||||
EGLContext::EGLSurfaceHandle EGLContext::CreateWindowSurface(EGLDisplayHandle display,
|
EGLContext::EGLSurfaceHandle EGLContext::CreateWindowSurface(EGLDisplayHandle display,
|
||||||
EGLConfigHandle config,
|
EGLConfigHandle config,
|
||||||
NativeWindowType window,
|
NativeWindowType window,
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ namespace MobileGL {
|
|||||||
Bool ValidateContext(EGLContextHandle context) const;
|
Bool ValidateContext(EGLContextHandle context) const;
|
||||||
Bool ValidateContextOnDisplay(EGLDisplayHandle display, EGLContextHandle context) const;
|
Bool ValidateContextOnDisplay(EGLDisplayHandle display, EGLContextHandle context) const;
|
||||||
Bool IsCurrentContextOpenGLCoreProfile() const;
|
Bool IsCurrentContextOpenGLCoreProfile() const;
|
||||||
|
EGLint GetCurrentContextFlags() const;
|
||||||
|
|
||||||
// Surface
|
// Surface
|
||||||
EGLSurfaceHandle CreateWindowSurface(EGLDisplayHandle display, EGLConfigHandle config,
|
EGLSurfaceHandle CreateWindowSurface(EGLDisplayHandle display, EGLConfigHandle config,
|
||||||
@@ -160,6 +161,8 @@ namespace MobileGL {
|
|||||||
EGLint MajorVersion = 1;
|
EGLint MajorVersion = 1;
|
||||||
EGLint MinorVersion = 0;
|
EGLint MinorVersion = 0;
|
||||||
EGLint OpenGLProfileMask = 0;
|
EGLint OpenGLProfileMask = 0;
|
||||||
|
EGLint EGLContextFlags = 0;
|
||||||
|
EGLint OpenGLContextFlags = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SurfaceObject {
|
struct SurfaceObject {
|
||||||
|
|||||||
Reference in New Issue
Block a user