From 6075307e66fa03cc7dbfe5979d2cedd08525219a Mon Sep 17 00:00:00 2001 From: rdb Date: Fri, 3 Feb 2023 15:17:55 +0100 Subject: [PATCH] glgsg: Set maximum vertex attrib stride for WebGL --- panda/src/glstuff/glGraphicsStateGuardian_src.I | 5 ++++- panda/src/glstuff/glGraphicsStateGuardian_src.cxx | 2 +- panda/src/glstuff/glGraphicsStateGuardian_src.h | 4 ++++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.I b/panda/src/glstuff/glGraphicsStateGuardian_src.I index 216c16f259..9571762b6f 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.I +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.I @@ -186,7 +186,10 @@ has_fixed_function_pipeline() const { */ INLINE int CLP(GraphicsStateGuardian):: get_max_vertex_attrib_stride() const { -#ifdef OPENGLES_1 +#ifdef __EMSCRIPTEN__ + // WebGL has a static limit of 255 (yeah, that low). + return 255; +#elif defined(OPENGLES_1) // Best guess. return 2048; #else diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx index 4c578190e7..ce65d2eee1 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx @@ -3522,7 +3522,7 @@ reset() { } #endif -#ifndef OPENGLES_1 +#if !defined(OPENGLES_1) && !defined(__EMSCRIPTEN__) _max_vertex_attrib_stride = -1; #ifdef OPENGLES if (is_at_least_gles_version(3, 1)) diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.h b/panda/src/glstuff/glGraphicsStateGuardian_src.h index 71842f68ed..15b7b8fbe5 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.h +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.h @@ -753,7 +753,11 @@ protected: bool _use_vertex_attrib_binding; CPT(GeomVertexFormat) _current_vertex_format; const GeomVertexColumn *_vertex_attrib_columns[32]; +#ifdef __EMSCRIPTEN__ + static const int _max_vertex_attrib_stride = 255; +#else int _max_vertex_attrib_stride = INT_MAX; +#endif GLuint _current_sbuffer_index; pvector _current_sbuffer_base;