[Fix] (Backend): apply the polygon offset clamp on both backends

This commit is contained in:
2026-10-12 08:32:50 -04:00
parent 1469022b53
commit 3b0e6270b7
6 changed files with 117 additions and 10 deletions
@@ -664,6 +664,7 @@ namespace MobileGL::MG_Util::BackendLoader {
INIT_GLES_FUNC_OPTIONAL(glClipControlEXT)
INIT_GLES_FUNC_OPTIONAL(glColorMaskiEXT)
INIT_GLES_FUNC_OPTIONAL(glColorMaskiOES)
INIT_GLES_FUNC_OPTIONAL(glPolygonOffsetClampEXT)
// Extension-only multi-draw entry points. eglGetProcAddress may legally return a
// non-NULL stub for these on drivers that do not implement them (NVIDIA's ES driver
// returns one for glMultiDrawElementsBaseVertexEXT that silently drops every draw),
@@ -1126,6 +1127,7 @@ namespace MobileGL::MG_Util::BackendLoader {
Bool hasBaseInstanceExtension = false;
Bool hasTessellationShaderExtension = false;
Bool hasClipControlExtension = false;
Bool hasPolygonOffsetClampExtension = false;
for (GLint i = 0; i < extCount; ++i) {
const char* extension = (const char*)glesFuncs.glGetStringi(GL_EXTENSIONS, i);
if (extension) {
@@ -1192,6 +1194,9 @@ namespace MobileGL::MG_Util::BackendLoader {
if (std::strcmp(extension, "GL_KHR_parallel_shader_compile") == 0) {
caps.SupportsParallelShaderCompile = true;
}
if (std::strcmp(extension, "GL_EXT_polygon_offset_clamp") == 0) {
hasPolygonOffsetClampExtension = true;
}
if (std::strcmp(extension, "GL_EXT_blend_func_extended") == 0) {
caps.SupportsDualSourceBlend = true;
}
@@ -1254,6 +1259,8 @@ namespace MobileGL::MG_Util::BackendLoader {
glesFuncs.glDrawArraysInstancedBaseInstanceEXT != nullptr &&
glesFuncs.glDrawElementsInstancedBaseInstanceEXT != nullptr &&
glesFuncs.glDrawElementsInstancedBaseVertexBaseInstanceEXT != nullptr;
caps.SupportsPolygonOffsetClamp =
hasPolygonOffsetClampExtension && glesFuncs.glPolygonOffsetClampEXT != nullptr;
// ES has no core texture views at any version, so this is extension-only by nature.
// Each spelling must bring its OWN entry point: a driver that advertises the OES string
// is not required to export glTextureViewEXT.
@@ -654,6 +654,8 @@ namespace MobileGL {
GL_FUNC_TYPEDEF(void, glClipControlEXT, GLenum origin, GLenum depth)
GL_FUNC_TYPEDEF(void, glColorMaskiEXT, GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a)
GL_FUNC_TYPEDEF(void, glColorMaskiOES, GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a)
// GL_EXT_polygon_offset_clamp. ES has no core spelling at any version.
GL_FUNC_TYPEDEF(void, glPolygonOffsetClampEXT, GLfloat factor, GLfloat units, GLfloat clamp)
GL_FUNC_TYPEDEF(void, glMultiDrawArraysIndirectEXT, GLenum mode, const void* indirect, GLsizei drawcount,
GLsizei stride)
@@ -1071,6 +1073,7 @@ namespace MobileGL {
GL_FUNC_DECL(glClipControlEXT)
GL_FUNC_DECL(glColorMaskiEXT)
GL_FUNC_DECL(glColorMaskiOES)
GL_FUNC_DECL(glPolygonOffsetClampEXT)
GL_FUNC_DECL(glMultiDrawArraysIndirectEXT)
GL_FUNC_DECL(glMultiDrawElementsIndirectEXT)
@@ -1216,6 +1219,10 @@ namespace MobileGL {
// factors and layout(index = 1) fragment outputs. GLES core has no dual-source blending,
// so without this a draw using a SRC1 factor cannot proceed.
Bool SupportsDualSourceBlend = false;
// GL_EXT_polygon_offset_clamp is present and glPolygonOffsetClampEXT resolved. Without
// it the GL_POLYGON_OFFSET_CLAMP value cannot be applied and only glPolygonOffset's
// unclamped offset reaches the driver.
Bool SupportsPolygonOffsetClamp = false;
// GL_NV_shader_noperspective_interpolation is present: the driver accepts the
// `noperspective` interpolation qualifier in ESSL. GLES core has none, so without this
// SPIRV-Cross's `#extension ... : require` would fail to compile and MobileGL falls back