mirror of https://github.com/bkaradzic/bgfx
GL: Fixed crash when reading active attributes with ARB_program_interface_query.
This commit is contained in:
parent
3a35dbcf39
commit
c360ab23f3
|
@ -3779,6 +3779,8 @@ namespace bgfx { namespace gl
|
|||
GL_CHECK(glBindFragDataLocation(m_id, 0, "bgfx_FragColor") );
|
||||
#endif // BGFX_CONFIG_RENDERER_OPENGL >= 31
|
||||
|
||||
GLint max0, max1;
|
||||
|
||||
bool piqSupported = true
|
||||
&& s_extension[Extension::ARB_program_interface_query ].m_supported
|
||||
&& s_extension[Extension::ARB_shader_storage_buffer_object].m_supported
|
||||
|
@ -3789,16 +3791,18 @@ namespace bgfx { namespace gl
|
|||
GL_CHECK(glGetProgramInterfaceiv(m_id, GL_PROGRAM_INPUT, GL_ACTIVE_RESOURCES, &activeAttribs ) );
|
||||
GL_CHECK(glGetProgramInterfaceiv(m_id, GL_UNIFORM, GL_ACTIVE_RESOURCES, &activeUniforms) );
|
||||
GL_CHECK(glGetProgramInterfaceiv(m_id, GL_BUFFER_VARIABLE, GL_ACTIVE_RESOURCES, &activeBuffers ) );
|
||||
GL_CHECK(glGetProgramInterfaceiv(m_id, GL_PROGRAM_INPUT, GL_MAX_NAME_LENGTH, &max0 ) );
|
||||
GL_CHECK(glGetProgramInterfaceiv(m_id, GL_UNIFORM, GL_MAX_NAME_LENGTH, &max1 ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
GL_CHECK(glGetProgramiv(m_id, GL_ACTIVE_ATTRIBUTES, &activeAttribs ) );
|
||||
GL_CHECK(glGetProgramiv(m_id, GL_ACTIVE_UNIFORMS, &activeUniforms) );
|
||||
|
||||
GL_CHECK(glGetProgramiv(m_id, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &max0) );
|
||||
GL_CHECK(glGetProgramiv(m_id, GL_ACTIVE_UNIFORM_MAX_LENGTH, &max1) );
|
||||
}
|
||||
|
||||
GLint max0, max1;
|
||||
GL_CHECK(glGetProgramiv(m_id, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &max0) );
|
||||
GL_CHECK(glGetProgramiv(m_id, GL_ACTIVE_UNIFORM_MAX_LENGTH, &max1) );
|
||||
uint32_t maxLength = bx::uint32_max(max0, max1);
|
||||
char* name = (char*)alloca(maxLength + 1);
|
||||
|
||||
|
@ -3807,9 +3811,18 @@ namespace bgfx { namespace gl
|
|||
for (int32_t ii = 0; ii < activeAttribs; ++ii)
|
||||
{
|
||||
GLint size;
|
||||
GLenum type;
|
||||
GLenum type = 0;
|
||||
|
||||
GL_CHECK(glGetActiveAttrib(m_id, ii, maxLength + 1, NULL, &size, &type, name) );
|
||||
if (piqSupported)
|
||||
{
|
||||
GL_CHECK(glGetProgramResourceName(m_id, GL_PROGRAM_INPUT, ii, maxLength + 1, &size, name) );
|
||||
GLenum typeProp[] = { GL_TYPE };
|
||||
GL_CHECK(glGetProgramResourceiv(m_id, GL_PROGRAM_INPUT, ii, BX_COUNTOF(typeProp), typeProp, 1, NULL, (GLint *)&type) );
|
||||
}
|
||||
else
|
||||
{
|
||||
GL_CHECK(glGetActiveAttrib(m_id, ii, maxLength + 1, NULL, &size, &type, name) );
|
||||
}
|
||||
|
||||
BX_TRACE("\t%s %s is at location %d"
|
||||
, glslTypeName(type)
|
||||
|
|
Loading…
Reference in New Issue