MCPcopy Create free account
hub / github.com/davideberly/GeometricTools / IntelWorkaround

Method IntelWorkaround

GTE/Graphics/GL46/GLSLReflection.cpp:1146–1237  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1144}
1145
1146void GLSLReflection::IntelWorkaround(std::string const& name, GLint results[])
1147{
1148 // For each shader reported as NOT referencing the buffer 'name', search
1149 // the shader source code for 'buffer name { Type data[]; } instance'.
1150 // If found, then search the remaining strings for 'instance'. If a match
1151 // is found, then change the results[] reference value from 0 to 1.
1152 GLsizei maxCount = 0;
1153 glGetProgramiv(mHandle, GL_ATTACHED_SHADERS, &maxCount);
1154 if (maxCount < 0)
1155 {
1156 return;
1157 }
1158
1159 std::vector<GLuint> shaders(maxCount);
1160 GLsizei count = 0;
1161 glGetAttachedShaders(mHandle, maxCount, &count, shaders.data());
1162 if (count != maxCount)
1163 {
1164 return;
1165 }
1166
1167 for (auto shader : shaders)
1168 {
1169 GLint type = 0;
1170 glGetShaderiv(shader, GL_SHADER_TYPE, &type);
1171 auto iter = mShaderTypeMap.find(type);
1172 if (iter != mShaderTypeMap.end())
1173 {
1174 int32_t index = iter->second;
1175 if (results[index] == 0)
1176 {
1177 // The shader is reported as not referenced. Verify
1178 // whether or not this is correct.
1179 GLint length = 0;
1180 glGetShaderiv(shader, GL_SHADER_SOURCE_LENGTH, &length);
1181 if (length <= 0)
1182 {
1183 return;
1184 }
1185
1186 std::vector<GLchar> rawSource(length);
1187 glGetShaderSource(shader, length, nullptr, rawSource.data());
1188 std::string source(rawSource.data());
1189
1190 // Find 'buffer name { Type member[]; } instance;'.
1191 auto beginInstance = source.find("buffer " + name);
1192 if (beginInstance == std::string::npos)
1193 {
1194 return;
1195 }
1196
1197 beginInstance = source.find('}', beginInstance);
1198 if (beginInstance == std::string::npos)
1199 {
1200 return;
1201 }
1202
1203 if (++beginInstance >= source.length())

Callers

nothing calls this directly

Calls 5

glGetProgramivFunction · 0.85
glGetAttachedShadersFunction · 0.85
glGetShaderivFunction · 0.85
glGetShaderSourceFunction · 0.85
endMethod · 0.80

Tested by

no test coverage detected