mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-08 20:28:32 +09:00
[Feat] (MG_Impl/GLImpl, MG_State): implement glPrimitiveRestartIndex
Store the primitive restart index as render state and report it through glGetIntegerv(GL_PRIMITIVE_RESTART_INDEX), replacing the stub and the hardcoded 0 in the getter. - RenderState gains a PrimitiveRestartIndex field (default 0) with set/get accessors and GLContext wrappers. - glPrimitiveRestartIndex accepts any GLuint and generates no error. - glGetIntegerv(GL_PRIMITIVE_RESTART_INDEX) now reads the stored value. This is the state layer only. The backends do not yet honor an arbitrary restart index at draw time -- Vulkan and GLES support only the fixed all-ones restart value (GL_PRIMITIVE_RESTART_FIXED_INDEX) -- so a non- default index is tracked and queryable but not yet applied to indexed draws. Tests: RenderStateSanity round-trip (default 0, mid value, and the full 32-bit range). Full SanityTest sweep green (31/31).
This commit is contained in:
@@ -907,3 +907,28 @@ TEST(RenderStateSanity, ColorMaskIndexedStoresAndReadsBack) {
|
||||
|
||||
MG_State::pGLContext.reset();
|
||||
}
|
||||
|
||||
TEST(RenderStateSanity, PrimitiveRestartIndexStoresAndReadsBack) {
|
||||
using namespace MobileGL;
|
||||
using namespace MobileGL::MG_Impl::GLImpl;
|
||||
MG_State::pGLContext = MakeUnique<MG_State::GLState::GLContext>();
|
||||
|
||||
// Default is 0.
|
||||
GLint value = -1;
|
||||
GetIntegerv(GL_PRIMITIVE_RESTART_INDEX, &value);
|
||||
EXPECT_EQ(value, 0);
|
||||
|
||||
// Any GLuint round-trips and generates no error.
|
||||
PrimitiveRestartIndex(0xFFFFu);
|
||||
EXPECT_EQ(GetError(), GL_NO_ERROR);
|
||||
GetIntegerv(GL_PRIMITIVE_RESTART_INDEX, &value);
|
||||
EXPECT_EQ(value, 0xFFFF);
|
||||
|
||||
// The full 32-bit range round-trips (read back as the same bit pattern).
|
||||
PrimitiveRestartIndex(0xFFFFFFFFu);
|
||||
GetIntegerv(GL_PRIMITIVE_RESTART_INDEX, &value);
|
||||
EXPECT_EQ(static_cast<GLuint>(value), 0xFFFFFFFFu);
|
||||
EXPECT_EQ(GetError(), GL_NO_ERROR);
|
||||
|
||||
MG_State::pGLContext.reset();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user