mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-12 06:08:30 +09:00
[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:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user