[Fix] (Backend): resolve primitive restart per draw - never for a non-indexed one, and never on an index the type cannot hold

This commit is contained in:
Swung0x48
2026-08-27 03:18:09 -04:00
parent e69e939d1a
commit 90b7a689c5
8 changed files with 486 additions and 131 deletions
@@ -10,6 +10,15 @@
namespace MobileGL {
namespace MG_Util {
Uint32 FixedRestartIndexForGLType(GLenum indexType) {
switch (indexType) {
case GL_UNSIGNED_BYTE: return 0xFFu;
case GL_UNSIGNED_SHORT: return 0xFFFFu;
case GL_UNSIGNED_INT: return 0xFFFFFFFFu;
default: return 0;
}
}
SizeT GetGLTypeSize(GLenum type) {
switch (type) {
// Scalars
+14
View File
@@ -12,5 +12,19 @@
namespace MobileGL {
namespace MG_Util {
SizeT GetGLTypeSize(GLenum type);
// The largest value an index of this type can hold, which is also the value
// GL_PRIMITIVE_RESTART_FIXED_INDEX (and its GLES/Vulkan equivalents) restart on. Zero for a
// type that cannot index at all.
//
// Shared rather than re-derived per backend on purpose: three places have to agree about
// what an index of this type can be - whether a rewrite is needed at all, what the rewrite
// compares against, and whether the driver should be told to restart. GL 4.6 core 10.3.6
// compares the FETCHED index, zero-extended, against the full 32-bit
// PRIMITIVE_RESTART_INDEX, so a restart index greater than this value matches no index and
// the draw restarts nowhere. Truncating it to the type's width instead - which one of these
// three places used to do - turns a legal vertex index into a restart.
Uint32 FixedRestartIndexForGLType(GLenum indexType);
} // namespace MG_Util
} // namespace MobileGL