| 5103 | } |
| 5104 | |
| 5105 | void ProgramGL::init() |
| 5106 | { |
| 5107 | GLint activeAttribs = 0; |
| 5108 | GLint activeUniforms = 0; |
| 5109 | GLint activeBuffers = 0; |
| 5110 | |
| 5111 | #if BGFX_CONFIG_RENDERER_OPENGL >= 31 |
| 5112 | GL_CHECK(glBindFragDataLocation(m_id, 0, "bgfx_FragColor") ); |
| 5113 | #endif // BGFX_CONFIG_RENDERER_OPENGL >= 31 |
| 5114 | |
| 5115 | GLint max0, max1; |
| 5116 | |
| 5117 | bool piqSupported = true |
| 5118 | && s_extension[Extension::ARB_program_interface_query ].m_supported |
| 5119 | && s_extension[Extension::ARB_shader_storage_buffer_object].m_supported |
| 5120 | ; |
| 5121 | |
| 5122 | if (piqSupported) |
| 5123 | { |
| 5124 | GL_CHECK(glGetProgramInterfaceiv(m_id, GL_PROGRAM_INPUT, GL_ACTIVE_RESOURCES, &activeAttribs ) ); |
| 5125 | GL_CHECK(glGetProgramInterfaceiv(m_id, GL_UNIFORM, GL_ACTIVE_RESOURCES, &activeUniforms) ); |
| 5126 | GL_CHECK(glGetProgramInterfaceiv(m_id, GL_BUFFER_VARIABLE, GL_ACTIVE_RESOURCES, &activeBuffers ) ); |
| 5127 | GL_CHECK(glGetProgramInterfaceiv(m_id, GL_PROGRAM_INPUT, GL_MAX_NAME_LENGTH, &max0 ) ); |
| 5128 | GL_CHECK(glGetProgramInterfaceiv(m_id, GL_UNIFORM, GL_MAX_NAME_LENGTH, &max1 ) ); |
| 5129 | } |
| 5130 | else |
| 5131 | { |
| 5132 | GL_CHECK(glGetProgramiv(m_id, GL_ACTIVE_ATTRIBUTES, &activeAttribs ) ); |
| 5133 | GL_CHECK(glGetProgramiv(m_id, GL_ACTIVE_UNIFORMS, &activeUniforms) ); |
| 5134 | |
| 5135 | GL_CHECK(glGetProgramiv(m_id, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &max0) ); |
| 5136 | GL_CHECK(glGetProgramiv(m_id, GL_ACTIVE_UNIFORM_MAX_LENGTH, &max1) ); |
| 5137 | } |
| 5138 | |
| 5139 | uint32_t maxLength = bx::uint32_max(max0, max1); |
| 5140 | char* name = (char*)BX_STACK_ALLOC(maxLength + 1); |
| 5141 | |
| 5142 | BX_TRACE("Program %d", m_id); |
| 5143 | BX_TRACE("Attributes (%d):", activeAttribs); |
| 5144 | for (int32_t ii = 0; ii < activeAttribs; ++ii) |
| 5145 | { |
| 5146 | GLint size; |
| 5147 | GLenum type = 0; |
| 5148 | |
| 5149 | if (piqSupported) |
| 5150 | { |
| 5151 | GL_CHECK(glGetProgramResourceName(m_id, GL_PROGRAM_INPUT, ii, maxLength + 1, &size, name) ); |
| 5152 | GLenum typeProp[] = { GL_TYPE }; |
| 5153 | GL_CHECK(glGetProgramResourceiv(m_id |
| 5154 | , GL_PROGRAM_INPUT |
| 5155 | , ii |
| 5156 | , BX_COUNTOF(typeProp) |
| 5157 | , typeProp |
| 5158 | , 1 |
| 5159 | , NULL |
| 5160 | , (GLint *)&type) |
| 5161 | ); |
| 5162 | } |
no test coverage detected