[Fix] (MG_Impl/GLImpl, MG_Backend): fix OpenGL 3.1 piglit cases

This commit is contained in:
2026-07-02 10:34:17 +08:00
parent 233277d94b
commit fabae2465b
7 changed files with 52 additions and 2 deletions
@@ -3293,7 +3293,10 @@ void main() {
}
auto vtxUploadOk = UploadAndBindVertexBuffers(frame.commandBuffer, vao, drawParams);
MOBILEGL_ASSERT(vtxUploadOk, "SetupDraw skipped: failed to upload vertex buffers");
if (!vtxUploadOk) {
MGLOG_E("SetupDraw skipped: failed to upload vertex buffers");
return false;
}
if (aspects & DrawSetupAspect::IndexBuffer) {
auto idxUploadOk = UploadAndBindIndexBuffer(frame, vao, pIndexBufferView);
@@ -1275,6 +1275,8 @@ namespace MobileGL::MG_Impl::GLImpl {
return;
}
if (!BufferImpl::ValidateBufferName(buffer, true)) return;
Bool doesBufferObjectCreated = MG_State::pGLContext->ValidateBufferObject(buffer);
if (!doesBufferObjectCreated) {
MG_State::pGLContext->CreateBufferObject(buffer);
@@ -1304,6 +1306,8 @@ namespace MobileGL::MG_Impl::GLImpl {
return;
}
if (!BufferImpl::ValidateBufferName(buffer, true)) return;
Bool doesBufferObjectCreated = MG_State::pGLContext->ValidateBufferObject(buffer);
if (!doesBufferObjectCreated) {
MG_State::pGLContext->CreateBufferObject(buffer);
@@ -9,6 +9,7 @@
#include "GL_Drawing.h"
#include <Config.h>
#include <MG_State/GLState/Core.h>
#include <MG_State/EGLState/Core.h>
#include <MG_Backend/BackendObjects.h>
namespace MobileGL::MG_Impl::GLImpl {
@@ -65,6 +66,15 @@ namespace MobileGL::MG_Impl::GLImpl {
return false;
}
const auto& vao = MG_State::pGLContext->GetBoundVertexArray();
if (MG_State::pEGLContext->IsCurrentContextOpenGLCoreProfile() && vao && vao->GetExternalIndex() == 0) {
MG_State::pGLContext->RecordError(
ErrorCode::InvalidOperation,
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", functionName,
"Default vertex array object cannot be used for drawing in core profile."));
return false;
}
return true;
}
@@ -18,6 +18,7 @@
#include "../Framebuffer/GL_Framebuffer.h"
#include "../VertexArray/GL_VertexArray.h"
#include "../Sync/GL_Sync.h"
#include <MG_State/GLState/Core.h>
#define DECLARE_GL_FUNCTION_STUB_HEAD(type, name, ...) MOBILEGL_GL_API type gl##name(__VA_ARGS__) {
@@ -211,7 +212,15 @@ DECLARE_GL_FUNCTION_HEAD(void, CompressedTexSubImage3D, GLenum target, GLint lev
DECLARE_GL_FUNCTION_STUB_HEAD(void, GenQueries, GLsizei n, GLuint* ids) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, GenQueries, n, ids)
DECLARE_GL_FUNCTION_STUB_HEAD(void, DeleteQueries, GLsizei n, const GLuint* ids) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, DeleteQueries, n, ids)
DECLARE_GL_FUNCTION_STUB_HEAD(GLboolean, IsQuery, GLuint id) DECLARE_GL_FUNCTION_STUB_END(GLboolean, IsQuery, id)
DECLARE_GL_FUNCTION_STUB_HEAD(void, BeginQuery, GLenum target, GLuint id) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, BeginQuery, target, id)
MOBILEGL_GL_API void glBeginQuery(GLenum target, GLuint id) {
MGLOG_W("Stub function: %s(...)", __FUNCTION__);
if (id != 0) {
MobileGL::MG_State::pGLContext->RecordError(
MobileGL::ErrorCode::InvalidOperation,
MobileGL::MakeUnique<MobileGL::GenericErrorInfo>("MG_Impl/GLImpl", __FUNCTION__,
"Query object does not exist."));
}
}
DECLARE_GL_FUNCTION_STUB_HEAD(void, EndQuery, GLenum target) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, EndQuery, target)
DECLARE_GL_FUNCTION_STUB_HEAD(void, GetQueryiv, GLenum target, GLenum pname, GLint* params) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, GetQueryiv, target, pname, params)
DECLARE_GL_FUNCTION_STUB_HEAD(void, GetQueryObjectuiv, GLuint id, GLenum pname, GLuint* params) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, GetQueryObjectuiv, id, pname, params)
@@ -2112,6 +2112,13 @@ namespace MobileGL::MG_Impl::GLImpl {
return;
}
if (!MG_State::pGLContext->ValidateTextureName(texture)) {
MG_State::pGLContext->RecordError(
ErrorCode::InvalidOperation,
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", "BindTexture_State", "Invalid texture name"));
return;
}
if (!TextureImpl::ValidateTextureName(texture, true)) return;
// ======================= Processing ================================
+15
View File
@@ -608,6 +608,9 @@ namespace MobileGL {
if (auto value = ParseAttribValue(attribList, EGL_CONTEXT_MINOR_VERSION); value) {
contextObject.MinorVersion = *value;
}
if (auto value = ParseAttribValue(attribList, EGL_CONTEXT_OPENGL_PROFILE_MASK); value) {
contextObject.OpenGLProfileMask = *value;
}
const auto context = EncodeHandle<EGLContextHandle>(m_nextContextHandle++);
m_contexts[context] = contextObject;
@@ -691,6 +694,18 @@ namespace MobileGL {
return ctx && ctx->Display == display;
}
Bool EGLContext::IsCurrentContextOpenGLCoreProfile() const {
const std::lock_guard<std::recursive_mutex> lock(m_mutex);
auto currentIt = m_threadCurrents.find(CurrentThreadKey());
if (currentIt == m_threadCurrents.end()) {
return false;
}
const auto* ctx = TryGetContext(currentIt->second.Context);
return ctx && ctx->ClientAPI == EGL_OPENGL_API &&
((ctx->OpenGLProfileMask & EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT) ||
ctx->MajorVersion > 3 || (ctx->MajorVersion == 3 && ctx->MinorVersion >= 1));
}
EGLContext::EGLSurfaceHandle EGLContext::CreateWindowSurface(EGLDisplayHandle display,
EGLConfigHandle config,
NativeWindowType window,
+2
View File
@@ -58,6 +58,7 @@ namespace MobileGL {
EGLint* value) const;
Bool ValidateContext(EGLContextHandle context) const;
Bool ValidateContextOnDisplay(EGLDisplayHandle display, EGLContextHandle context) const;
Bool IsCurrentContextOpenGLCoreProfile() const;
// Surface
EGLSurfaceHandle CreateWindowSurface(EGLDisplayHandle display, EGLConfigHandle config,
@@ -158,6 +159,7 @@ namespace MobileGL {
EGLint ClientVersion = 1;
EGLint MajorVersion = 1;
EGLint MinorVersion = 0;
EGLint OpenGLProfileMask = 0;
};
struct SurfaceObject {