Skip to content

Commit 4745fc4

Browse files
GL: fixed issue with GL_MAX_ELEMENT_INDEX on Mac
1 parent fbd98ec commit 4745fc4

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLImpl.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -949,6 +949,9 @@ void RenderDeviceGLImpl::InitAdapterInfo()
949949

950950
if (GLVersion >= Version{4, 6} || CheckExtension("GL_ARB_indirect_parameters"))
951951
DrawCommandProps.CapFlags |= DRAW_COMMAND_CAP_FLAG_DRAW_INDIRECT_COUNTER_BUFFER;
952+
953+
// Always 2^32-1 on desktop
954+
DrawCommandProps.MaxIndexValue = ~Uint32{0};
952955
}
953956
else if (m_DeviceInfo.Type == RENDER_DEVICE_TYPE_GLES)
954957
{
@@ -964,11 +967,17 @@ void RenderDeviceGLImpl::InitAdapterInfo()
964967

965968
if (strstr(Extensions, "multi_draw_indirect"))
966969
DrawCommandProps.CapFlags |= DRAW_COMMAND_CAP_FLAG_NATIVE_MULTI_DRAW_INDIRECT | DRAW_COMMAND_CAP_FLAG_DRAW_INDIRECT_COUNTER_BUFFER;
970+
971+
DrawCommandProps.MaxIndexValue = 0;
972+
glGetIntegerv(GL_MAX_ELEMENT_INDEX, reinterpret_cast<GLint*>(&DrawCommandProps.MaxIndexValue));
973+
if (glGetError() != GL_NO_ERROR)
974+
{
975+
// Note that on desktop, GL_MAX_ELEMENT_INDEX was added only in 4.3 and always returns 2^32-1
976+
LOG_ERROR_MESSAGE("glGetIntegerv(GL_MAX_ELEMENT_INDEX) failed");
977+
DrawCommandProps.MaxIndexValue = (1u << 24) - 1; // Guaranteed by the spec
978+
}
967979
}
968980

969-
DrawCommandProps.MaxIndexValue = 0;
970-
glGetIntegerv(GL_MAX_ELEMENT_INDEX, reinterpret_cast<GLint*>(&DrawCommandProps.MaxIndexValue));
971-
CHECK_GL_ERROR("glGetIntegerv(GL_MAX_ELEMENT_INDEX)");
972981
#if defined(_MSC_VER) && defined(_WIN64)
973982
static_assert(sizeof(DrawCommandProps) == 12, "Did you add a new member to DrawCommandProperties? Please initialize it here.");
974983
#endif

0 commit comments

Comments
 (0)