KhronosGroup / KhronosGroup/OpenGL-API
Ill-specified interaction of display lists and primitive restart
- Dominant language
- No language data
- Stars
- 42
- Forks
- 8
- PR merge metrics
- No merged PRs in 30d
Description
A few bits of the OpenGL 3.1+ specification combine to generate an interaction that may be impossible to satisfy.
- Starting in OpenGL 3.1, primitive restart enable became server state.
- `glPrimitiveRestartIndex` cannot be compiled into a display list.
- From section 21.4 (Display Lists) of the OpenGL 4.6 Compatibility Profile spec:
> Vertex array pointers are dereferenced when the commands `ArrayElement`, `DrawArrays`, `DrawElements`, or `DrawRangeElementsare` accumulated into a display list.
Based on that, what should the following code do?
```
glDisable(GL_PRIMITIVE_RESTART);
glPrimitiveRestartIndex(0x7fffffff);
glNewList(1, GL_COMPILE);
glBegin(GL_TRIANGLES);
glArrayIndex(0); glArrayIndex(1); glArrayIndex(2);
glArrayIndex(0x7fffffff);
glArrayIndex(3); glArrayIndex(4); glArrayIndex(5);
glEnd();
glEndList();
glEnable(GL_PRIMITIVE_RESTART);
glCallList(1);
glPrimitiveRestartIndex(0x12345678);
glCallList(1);
```
The difficulty is that `glArrayIndex(0x7fffffff)` is supposed to dereference the vertex array at the time it is called. However, the state of `GL_PRIMITIVE_RESTART` and the primitive restart index aren't known until `glCallList`. It is impossible for the implementation to know if `0x7fffffff` should start a new primitive or dereference a very large memory address.
On at least one implementation, it crashes inside `glArrayIndex(0x7fffffff)`.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with section 21.4 of the OpenGL 4.6 Compatibility Profile specification and the documented behavior of primitive restart, display lists, and glArrayIndex. Reproduce the supplied sequence on an implementation if possible, then determine the normative behavior or the conflicting requirements. Done means the interaction is resolved through a clear specification interpretation or correction.
Written by the indexing model from the issue text.
Assessment
- Domain
- computer-graphics
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100