From 805fa5a36ab8e37eab4ec739d5a9733c7fc0ae2d Mon Sep 17 00:00:00 2001 From: rdb Date: Fri, 3 Feb 2023 15:09:32 +0100 Subject: [PATCH] glgsg: Guess max vertex attrib stride if not queryable Or should we just assume the most restrictive possibility? --- .../glstuff/glGraphicsStateGuardian_src.cxx | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx index f90701f4f4..4c578190e7 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx @@ -3523,27 +3523,39 @@ reset() { #endif #ifndef OPENGLES_1 + _max_vertex_attrib_stride = -1; #ifdef OPENGLES if (is_at_least_gles_version(3, 1)) #else if (is_at_least_gl_version(4, 4)) #endif { - _max_vertex_attrib_stride = -1; glGetIntegerv(GL_MAX_VERTEX_ATTRIB_STRIDE, &_max_vertex_attrib_stride); if (_max_vertex_attrib_stride < 0) { GLCAT.warning() << "Failed to query GL_MAX_VERTEX_ATTRIB_STRIDE.\n"; - _max_vertex_attrib_stride = INT_MAX; } else if (GLCAT.is_debug()) { GLCAT.debug() << "max vertex attrib stride = " << _max_vertex_attrib_stride << "\n"; } } - else { - _max_vertex_attrib_stride = INT_MAX; + if (_max_vertex_attrib_stride < 0) { + // OpenGL doesn't specify a maximum before version 4.4 / ES 3.1, but + // drivers really do have one. Make an educated guess. +#ifdef OPENGLES + _max_vertex_attrib_stride = (_gl_vendor == "Qualcomm") ? INT_MAX : 2048; +#elif defined(_WIN32) + _max_vertex_attrib_stride = (_gl_vendor == "Intel") ? 4095 : 2048; +#else + _max_vertex_attrib_stride = 2048; +#endif + if (GLCAT.is_debug()) { + GLCAT.debug() + << "max vertex attrib stride = " << _max_vertex_attrib_stride + << " (guessed)\n"; + } } #endif // !OPENGLES_1