GteGLSLReflection.cpp
Go to the documentation of this file.
1 // David Eberly, Geometric Tools, Redmond WA 98052
2 // Copyright (c) 1998-2017
3 // Distributed under the Boost Software License, Version 1.0.
4 // http://www.boost.org/LICENSE_1_0.txt
5 // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt
6 // File Version: 3.0.1 (2016/07/03)
7 
8 #include <GTEnginePCH.h>
9 #include <LowLevel/GteLogger.h>
11 #include <fstream>
12 using namespace gte;
13 
15  :
16  mHandle(handle)
17 {
18  std::string vendor(reinterpret_cast<char const*>(glGetString(GL_VENDOR)));
19  mVendorIsIntel = (vendor == "Intel");
20  mShaderTypeMap.insert(std::make_pair(GL_VERTEX_SHADER, 3));
21  mShaderTypeMap.insert(std::make_pair(GL_GEOMETRY_SHADER, 4));
22  mShaderTypeMap.insert(std::make_pair(GL_FRAGMENT_SHADER, 5));
23  mShaderTypeMap.insert(std::make_pair(GL_COMPUTE_SHADER, 6));
24  mShaderTypeMap.insert(std::make_pair(GL_TESS_CONTROL_SHADER, 7));
25  mShaderTypeMap.insert(std::make_pair(GL_TESS_EVALUATION_SHADER, 8));
26 
27  if (mHandle > 0)
28  {
58  }
59  else
60  {
61  LogError("The program handle is invalid.");
62  }
63 }
64 
65 void GLSLReflection::GetComputeShaderWorkGroupSize(GLint &numXThreads, GLint& numYThreads, GLint& numZThreads) const
66 {
67  GLint workGroupSize[3];
69  numXThreads = workGroupSize[0];
70  numYThreads = workGroupSize[1];
71  numZThreads = workGroupSize[2];
72 }
73 
74 void GLSLReflection::Print(std::ofstream& ostr) const
75 {
76  // TODO: need some type of pre-amble
77 
78  ostr << "Description:" << std::endl;
79  ostr << "OpenGL version = " << glGetString(GL_VERSION) << std::endl;
80  ostr << "GLSL version = " << glGetString(GL_SHADING_LANGUAGE_VERSION) << std::endl;
81  ostr << "Vendor = " << glGetString(GL_VENDOR) << std::endl;
82  ostr << "Renderer = " << glGetString(GL_RENDERER) << std::endl;
83  ostr << std::endl;
84 
85  ostr << "General:" << std::endl;
86  ostr << "num inputs = " << mInputs.size() << std::endl;
87  ostr << "num outputs = " << mOutputs.size() << std::endl;
88  ostr << "num uniform blocks = " << mUniformBlocks.size() << std::endl;
89  ostr << "num atomic counter buffers = " << mAtomicCounterBuffers.size() << std::endl;
90  ostr << "num uniforms = " << mUniforms.size() << std::endl;
91  ostr << "num shader storage blocks = " << mShaderStorageBlocks.size() << std::endl;
92  ostr << "num buffer variables = " << mBufferVariables.size() << std::endl;
93  ostr << std::endl;
94 
95  for (unsigned i = 0; i < mInputs.size(); ++i)
96  {
97  auto const& input = mInputs[i];
98 
99  ostr << "Input[" << i << "]:" << std::endl;
100  ostr << "name = " << input.name << std::endl;
101  ostr << "type = " << GetEnumName(input.type) << std::endl;
102  ostr << "shader type = " << GetEnumShaderName(input.type) << std::endl;
103  ostr << "location = " << input.location << std::endl;
104  ostr << "array Size = " << input.arraySize << std::endl;
105  ostr << "referenced by shaders = " << GetReferencedByShaderList(input.referencedBy) << std::endl;
106  ostr << "is per patch = " << input.isPerPatch << std::endl;
107  ostr << "location component = " << input.locationComponent << std::endl;
108  ostr << std::endl;
109  }
110 
111  for (unsigned i = 0; i < mOutputs.size(); ++i)
112  {
113  auto const& output = mOutputs[i];
114 
115  ostr << "Output[" << i << "]:" << std::endl;
116  ostr << "name = " << output.name << std::endl;
117  ostr << "type = " << GetEnumName(output.type) << std::endl;
118  ostr << "shader type = " << GetEnumShaderName(output.type) << std::endl;
119  ostr << "location = " << output.location << std::endl;
120  ostr << "array Size = " << output.arraySize << std::endl;
121  ostr << "referenced by shaders = " << GetReferencedByShaderList(output.referencedBy) << std::endl;
122  ostr << "is per patch = " << output.isPerPatch << std::endl;
123  ostr << "location component = " << output.locationIndex << std::endl;
124  ostr << "location index = " << output.locationIndex << std::endl;
125  ostr << std::endl;
126  }
127 
128  for (unsigned i = 0; i < mUniformBlocks.size(); ++i)
129  {
130  auto const& block = mUniformBlocks[i];
131 
132  ostr << "UniformBlock[" << i << "]:" << std::endl;
133  ostr << "name = " << block.name << std::endl;
134  ostr << "buffer binding = " << block.bufferBinding << std::endl;
135  ostr << "buffer data size = " << block.bufferDataSize << std::endl;
136  ostr << "referenced by shaders = " << GetReferencedByShaderList(block.referencedBy) << std::endl;
137  ostr << "active variables = " << block.activeVariables.size() << std::endl;
138 
139  // Format the uniform block and its data members to look like a declaration
140  // in the shader code with helpful comments.
141  ostr << "declaration = " << std::endl;
142  ostr << " uniform " << block.name << std::endl;
143  ostr << " {" << std::endl;
144  for (unsigned v = 0; v < block.activeVariables.size(); ++v)
145  {
146  auto const& uniform = mUniforms[block.activeVariables[v]];
147 
148  ostr << " " << GetEnumShaderName(uniform.type) << " " << uniform.name;
149  if (uniform.arraySize > 1)
150  {
151  ostr << "[" << uniform.arraySize << "]";
152  }
153  ostr << "; //";
154  ostr << " offset=" << uniform.offset;
155  ostr << " size=" << GetEnumSize(uniform.type, uniform.arraySize,
156  uniform.arrayStride, uniform.matrixStride, uniform.isRowMajor);
157  if (uniform.arrayStride > 0)
158  {
159  ostr << " arrayStride=" << uniform.arrayStride;
160  }
161  if (uniform.matrixStride > 0)
162  {
163  ostr << " matrixStride=" << uniform.matrixStride;
164  ostr << " rowMajor=" << uniform.isRowMajor;
165  }
166  ostr << std::endl;
167  }
168  ostr << " };" << std::endl;
169  ostr << std::endl;
170  }
171 
172  for (unsigned i = 0; i < mAtomicCounterBuffers.size(); ++i)
173  {
174  auto const& acBuffer = mAtomicCounterBuffers[i];
175 
176  ostr << "AtomicCounterBuffer[" << i << "]:" << std::endl;
177  ostr << "buffer binding = " << acBuffer.bufferBinding << std::endl;
178  ostr << "buffer data size = " << acBuffer.bufferDataSize << std::endl;
179  ostr << "referenced by shaders = " << GetReferencedByShaderList(acBuffer.referencedBy) << std::endl;
180  ostr << "active variables = " << acBuffer.activeVariables.size() << std::endl;
181  ostr << std::endl;
182  }
183 
184  for (unsigned i = 0; i < mUniforms.size(); ++i)
185  {
186  auto const& uniform = mUniforms[i];
187 
188  ostr << "Uniform[" << i << "]:" << std::endl;
189  ostr << "name = " << uniform.fullName << std::endl;
190  ostr << "type = " << GetEnumName(uniform.type) << std::endl;
191  ostr << "shader type = " << GetEnumShaderName(uniform.type) << std::endl;
192  ostr << "referenced by shaders = " << GetReferencedByShaderList(uniform.referencedBy) << std::endl;
193 
194  // In a uniform block.
195  if (uniform.blockIndex >= 0)
196  {
197  ostr << "array size = " << uniform.arraySize << std::endl;
198  ostr << "offset = " << uniform.offset << std::endl;
199  ostr << "uniform block index = " << uniform.blockIndex << std::endl;
200  ostr << "array stride = " << uniform.arrayStride << std::endl;
201  ostr << "matrix stride = " << uniform.matrixStride << std::endl;
202  ostr << "is row major = " << uniform.isRowMajor << std::endl;
203  ostr << "size=" << GetEnumSize(uniform.type, uniform.arraySize,
204  uniform.arrayStride, uniform.matrixStride, uniform.isRowMajor) << std::endl;
205  }
206 
207  // Atomic counter.
208  else if (uniform.atomicCounterBufferIndex >= 0)
209  {
210  ostr << "atomic counter buffer index = " << uniform.atomicCounterBufferIndex << std::endl;
211 
212  auto const& acBuffer = mAtomicCounterBuffers[uniform.atomicCounterBufferIndex];
213  ostr << "declaration = " << std::endl;
214  ostr << " layout(binding = " << acBuffer.bufferBinding << ", offset = " << uniform.offset;
215  ostr << ") uniform " << GetEnumShaderName(uniform.type) << " " << uniform.name << ";" << std::endl;
216  }
217 
218  // Opaque type is not in a uniform block.
219  else
220  {
221  ostr << "declaration = " << std::endl;
222  ostr << " uniform " << GetEnumShaderName(uniform.type) << " " << uniform.name << ";" << std::endl;
223  }
224 
225  ostr << std::endl;
226  }
227 
228  for (unsigned i = 0; i < mShaderStorageBlocks.size(); ++i)
229  {
230  auto const& block = mShaderStorageBlocks[i];
231 
232  ostr << "ShaderStorageBlock[" << i << "]:" << std::endl;
233  ostr << "name = " << block.name << std::endl;
234  ostr << "buffer binding = " << block.bufferBinding << std::endl;
235  ostr << "buffer data size = " << block.bufferDataSize << std::endl;
236  ostr << "referenced by shaders = " << GetReferencedByShaderList(block.referencedBy) << std::endl;
237  ostr << "active variables = " << block.activeVariables.size() << std::endl;
238 
239  // Format the buffer block and its data members to look like a declaration
240  // in the shader code with helpful comments.
241  ostr << "declaration = " << std::endl;
242  ostr << " buffer " << block.name << std::endl;
243  ostr << " {" << std::endl;
244  GLint topLevelArrayStride = 0;
245  GLint topLevelArrayOffset = 0;
246  for (unsigned v = 0; v < block.activeVariables.size(); ++v)
247  {
248  auto const& bufferVar = mBufferVariables[block.activeVariables[v]];
249 
250  if (bufferVar.topLevelArrayStride != topLevelArrayStride)
251  {
252  if (topLevelArrayStride > 0)
253  {
254  ostr << " " << "} [];" << std::endl;
255  }
256  else
257  {
258  ostr << " struct //";
259  ostr << " offset=" << bufferVar.offset;
260  ostr << " structSize=" << bufferVar.topLevelArrayStride;
261  ostr << std::endl;
262  ostr << " {" << std::endl;
263  }
264  topLevelArrayStride = bufferVar.topLevelArrayStride;
265  topLevelArrayOffset = bufferVar.offset;
266  }
267 
268  // Generate what the declaration for this variable might look like.
269  if (topLevelArrayStride > 0)
270  {
271  ostr << " ";
272  }
273  ostr << " " << GetEnumShaderName(bufferVar.type) << " " << bufferVar.name;
274  if (bufferVar.arrayStride > 0)
275  {
276  auto arraySize = bufferVar.arraySize;
277  if (0 == arraySize)
278  {
279  // Guess array size based on offset for next variable in struct.
280  GLint nextOffset = block.bufferDataSize;
281  if ((v+1) < block.activeVariables.size())
282  {
283  nextOffset = mBufferVariables[block.activeVariables[v+1]].offset;
284  }
285  arraySize = (nextOffset - bufferVar.offset) / bufferVar.arrayStride;
286  }
287  ostr << '[' << arraySize << ']';
288  }
289 
290  ostr << "; //";
291  auto const size = GetEnumSize(bufferVar.type, bufferVar.arraySize,
292  bufferVar.arrayStride, bufferVar.matrixStride, bufferVar.isRowMajor);
293  if (size > 0)
294  {
295  ostr << " size=" << size;
296  }
297  if (topLevelArrayStride > 0)
298  {
299  ostr << " structOffset=" << (bufferVar.offset - topLevelArrayOffset);
300  }
301  ostr << " bufferOffset=" << bufferVar.offset;
302  if (bufferVar.arrayStride > 0)
303  {
304  ostr << " arrayStride=" << bufferVar.arrayStride;
305  }
306  if (bufferVar.matrixStride > 0)
307  {
308  ostr << " matrixStride=" << bufferVar.matrixStride;
309  ostr << " rowMajor=" << bufferVar.isRowMajor;
310  }
311  ostr << std::endl;
312  }
313  if (topLevelArrayStride > 0)
314  {
315  ostr << " " << "} [];" << std::endl;
316  }
317  ostr << " };" << std::endl;
318  ostr << std::endl;
319  }
320 
321  for (unsigned i = 0; i < mBufferVariables.size(); ++i)
322  {
323  auto const& bufferVar = mBufferVariables[i];
324 
325  ostr << "BufferVariable[" << i << "]:" << std::endl;
326  ostr << "name = " << bufferVar.fullName << std::endl;
327  ostr << "type = " << GetEnumName(bufferVar.type) << std::endl;
328  ostr << "shader type = " << GetEnumShaderName(bufferVar.type) << std::endl;
329  ostr << "referenced by shaders = " << GetReferencedByShaderList(bufferVar.referencedBy) << std::endl;
330 
331  // In a buffer block.
332  if (bufferVar.blockIndex >= 0)
333  {
334  ostr << "array size = " << bufferVar.arraySize << std::endl;
335  ostr << "offset = " << bufferVar.offset << std::endl;
336  ostr << "buffer block index = " << bufferVar.blockIndex << std::endl;
337  ostr << "array stride = " << bufferVar.arrayStride << std::endl;
338  ostr << "matrix stride = " << bufferVar.matrixStride << std::endl;
339  ostr << "is row major = " << bufferVar.isRowMajor << std::endl;
340  ostr << "top level array size = " << bufferVar.topLevelArraySize << std::endl;
341  ostr << "top level array stride = " << bufferVar.topLevelArrayStride << std::endl;
342  auto const size = GetEnumSize(bufferVar.type, bufferVar.arraySize,
343  bufferVar.arrayStride, bufferVar.matrixStride, bufferVar.isRowMajor);
344  if (size > 0)
345  {
346  ostr << "size=" << size << std::endl;
347  }
348  }
349 
350  // Opaque type is not in a uniform block.
351  else
352  {
353  ostr << "declaration = " << std::endl;
354  ostr << " buffer " << GetEnumShaderName(bufferVar.type) << " " << bufferVar.name << ";" << std::endl;
355  }
356 
357  ostr << std::endl;
358  }
359 }
360 
362 {
363  GLint numResources = 0;
365  &numResources);
366  if (numResources > 0)
367  {
368  mInputs.resize(numResources);
369 
370  GLenum properties[] =
371  {
373  GL_TYPE,
374  GL_LOCATION,
383  };
384  int const numProperties = sizeof(properties) / sizeof(int);
385  GLint results[numProperties] = { 0 };
386  for (int i = 0; i < numResources; ++i)
387  {
388  Input& info = mInputs[i];
390  numProperties, properties, numProperties, nullptr, results);
391 
392  GLint numBytes = results[0] + 1;
393  std::vector<GLchar> name(numBytes);
394  glGetProgramResourceName(mHandle, GL_PROGRAM_INPUT, i, numBytes, nullptr, name.data());
395  info.name = std::string(name.data());
396 
397  GLint* current = &results[1];
398  info.type = *current++;
399  info.location = *current++;
400  info.arraySize = *current++;
401  info.referencedBy[ST_VERTEX] = *current++;
402  info.referencedBy[ST_GEOMETRY] = *current++;
403  info.referencedBy[ST_PIXEL] = *current++;
404  info.referencedBy[ST_COMPUTE] = *current++;
405  info.referencedBy[ST_TESSCONTROL] = *current++;
406  info.referencedBy[ST_TESSEVALUATION] = *current++;
407  info.isPerPatch = *current++;
408  info.locationComponent = *current++;
409  }
410  }
411 }
412 
414 {
415  GLint numResources = 0;
417  &numResources);
418  if (numResources > 0)
419  {
420  mOutputs.resize(numResources);
421 
422  GLenum properties[] =
423  {
425  GL_TYPE,
426  GL_LOCATION,
436  };
437  int const numProperties = sizeof(properties) / sizeof(int);
438  GLint results[numProperties] = { 0 };
439  for (int i = 0; i < numResources; ++i)
440  {
441  Output& info = mOutputs[i];
443  numProperties, properties, numProperties, nullptr, results);
444 
445  GLint numBytes = results[0] + 1;
446  std::vector<GLchar> name(numBytes);
447  glGetProgramResourceName(mHandle, GL_PROGRAM_OUTPUT, i, numBytes, nullptr, name.data());
448  info.name = std::string(name.data());
449 
450  GLint* current = &results[1];
451  info.type = *current++;
452  info.location = *current++;
453  info.arraySize = *current++;
454  info.referencedBy[ST_VERTEX] = *current++;
455  info.referencedBy[ST_GEOMETRY] = *current++;
456  info.referencedBy[ST_PIXEL] = *current++;
457  info.referencedBy[ST_COMPUTE] = *current++;
458  info.referencedBy[ST_TESSCONTROL] = *current++;
459  info.referencedBy[ST_TESSEVALUATION] = *current++;
460  info.isPerPatch = *current++;
461  info.locationComponent = *current++;
462  info.locationIndex = *current++;
463  }
464  }
465 }
466 
468 {
469  GLint numResources = 0;
471  &numResources);
472 
473  if (numResources > 0)
474  {
475  mUniforms.clear();
476 
477  GLenum properties[] =
478  {
480  GL_TYPE,
481  GL_LOCATION,
483  GL_OFFSET,
495  };
496  int const numProperties = sizeof(properties) / sizeof(int);
497  GLint results[numProperties] = { 0 };
498  for (int i = 0; i < numResources; ++i)
499  {
500  Uniform info;
502  numProperties, properties, numProperties, nullptr, results);
503 
504  GLint numBytes = results[0] + 1;
505  std::vector<GLchar> name(numBytes);
506  glGetProgramResourceName(mHandle, GL_UNIFORM, i, numBytes, nullptr, name.data());
507  info.name = std::string(name.data());
508 
509  GLint* current = &results[1];
510  info.type = *current++;
511  info.location = *current++;
512  info.arraySize = *current++;
513  info.offset = *current++;
514  info.blockIndex = *current++;
515  info.arrayStride = *current++;
516  info.matrixStride = *current++;
517  info.isRowMajor = *current++;
518  info.atomicCounterBufferIndex = *current++;
519  info.referencedBy[ST_VERTEX] = *current++;
520  info.referencedBy[ST_GEOMETRY] = *current++;
521  info.referencedBy[ST_PIXEL] = *current++;
522  info.referencedBy[ST_COMPUTE] = *current++;
523  info.referencedBy[ST_TESSCONTROL] = *current++;
524  info.referencedBy[ST_TESSEVALUATION] = *current++;
525 
526  // To be sure the bufferBinding field is set correctly, use this approach.
527  if (GL_INVALID_INDEX == info.blockIndex)
528  {
529  info.location = glGetUniformLocation(mHandle, info.name.c_str());
530  }
531 
532  // Keep the original full name returned by the reflection.
533  info.fullName = info.name;
534 
535  // For an array member, the name is of the form "someName[...]...".
536  // The GTEngine Shader class currently wants "someName" because
537  // that is how GLSL delivered the name. Let's conform to that
538  // for now.
539  if (info.arraySize > 1)
540  {
541  auto index = info.name.find('[');
542  if (index != std::string::npos)
543  {
544  // Make sure array is not more than single dimensional.
545  auto index2 = info.name.find('[', index+1);
546  if (index2 != std::string::npos)
547  {
548  // TODO: Should this cause compile of shader to fail?
549  LogError("Only single dimensional arrays supported in GLSL uniforms.");
550  }
551 
552  info.name = info.name.substr(0, index);
553  }
554  else
555  {
556  // TODO: For now, trap any occurrence of an array member
557  // whose name is not of the form "someName[0]".
558  LogError("Unexpected condition.");
559  }
560  }
561 
562  mUniforms.push_back(info);
563  }
564  }
565 }
566 
568  std::vector<DataBlock>& blocks)
569 {
570  GLint numResources = 0;
572  &numResources);
573 
574  if (numResources > 0)
575  {
576  blocks.resize(numResources);
577 
578  GLenum properties[] =
579  {
590  };
591  int const numProperties = sizeof(properties) / sizeof(int);
592  GLint results[numProperties] = { 0 };
593  for (int i = 0; i < numResources; ++i)
594  {
595  DataBlock& info = blocks[i];
596  glGetProgramResourceiv(mHandle, programInterface, i,
597  numProperties, properties, numProperties, nullptr, results);
598 
599  GLint numBytes = results[0] + 1;
600  std::vector<GLchar> name(numBytes);
601  glGetProgramResourceName(mHandle, programInterface, i, numBytes, nullptr, name.data());
602  info.name = std::string(name.data());
603 
604  if (mVendorIsIntel && programInterface == GL_SHADER_STORAGE_BLOCK)
605  {
606  IntelWorkaround(info.name, results);
607  }
608 
609  GLint* current = &results[1];
610  info.bufferBinding = *current++;
611  info.bufferDataSize = *current++;
612  info.referencedBy[ST_VERTEX] = *current++;
613  info.referencedBy[ST_GEOMETRY] = *current++;
614  info.referencedBy[ST_PIXEL] = *current++;
615  info.referencedBy[ST_COMPUTE] = *current++;
616  info.referencedBy[ST_TESSCONTROL] = *current++;
617  info.referencedBy[ST_TESSEVALUATION] = *current++;
618 
619  // To be sure the bufferBinding field is set correctly, use this approach.
620  info.bufferBinding = glGetProgramResourceIndex(mHandle, programInterface, info.name.c_str());
621 
622  GLint numActiveVariables = *current++;
623  if (numActiveVariables > 0)
624  {
625  info.activeVariables.resize(numActiveVariables);
626  std::fill(info.activeVariables.begin(),
627  info.activeVariables.end(), 0);
628  GLenum varProperty = GL_ACTIVE_VARIABLES;
629  glGetProgramResourceiv(mHandle, programInterface, i, 1,
630  &varProperty, numActiveVariables, nullptr,
631  &info.activeVariables[0]);
632  }
633  }
634  }
635 }
636 
638 {
639  GLint numResources = 0;
641  GL_ACTIVE_RESOURCES, &numResources);
642 
643  if (numResources > 0)
644  {
645  mAtomicCounterBuffers.resize(numResources);
646 
647  GLenum properties[] =
648  {
658  };
659  int const numProperties = sizeof(properties) / sizeof(int);
660  GLint results[numProperties] = { 0 };
661  for (int i = 0; i < numResources; ++i)
662  {
665  numProperties, properties, numProperties, nullptr, results);
666 
667  GLint* current = &results[0];
668  info.bufferBinding = *current++;
669  info.bufferDataSize = *current++;
670  info.referencedBy[ST_VERTEX] = *current++;
671  info.referencedBy[ST_GEOMETRY] = *current++;
672  info.referencedBy[ST_PIXEL] = *current++;
673  info.referencedBy[ST_COMPUTE] = *current++;
674  info.referencedBy[ST_TESSCONTROL] = *current++;
675  info.referencedBy[ST_TESSEVALUATION] = *current++;
676 
677  GLint numActiveVariables = *current++;
678  if (numActiveVariables > 0)
679  {
680  info.activeVariables.resize(numActiveVariables);
681  std::fill(info.activeVariables.begin(),
682  info.activeVariables.end(), 0);
683  GLenum varProperty = GL_ACTIVE_VARIABLES;
685  1, &varProperty, numActiveVariables, nullptr,
686  &info.activeVariables[0]);
687  }
688  }
689  }
690 }
691 
693  std::vector<std::string>& subroutines)
694 {
695  GLint numResources = 0;
697  &numResources);
698  if (numResources > 0)
699  {
700  subroutines.resize(numResources);
701 
702  GLenum nameLengthProperty = GL_NAME_LENGTH;
703  for (int i = 0; i < numResources; ++i)
704  {
705  GLint result = 0;
706  glGetProgramResourceiv(mHandle, programInterface, i, 1,
707  &nameLengthProperty, 1, nullptr, &result);
708 
709  GLint numBytes = result + 1;
710  std::vector<GLchar> name(numBytes);
711  glGetProgramResourceName(mHandle, programInterface, i, numBytes, nullptr, name.data());
712  subroutines[i] = std::string(name.data());
713  }
714  }
715 }
716 
718  std::vector<SubroutineUniform>& subUniforms)
719 {
720  GLint numResources = 0;
722  &numResources);
723 
724  if (numResources > 0)
725  {
726  subUniforms.resize(numResources);
727 
728  GLenum properties[] =
729  {
731  GL_LOCATION,
734  };
735  int const numProperties = sizeof(properties) / sizeof(int);
736  GLint results[numProperties] = { 0 };
737  for (int i = 0; i < numResources; ++i)
738  {
739  SubroutineUniform& info = subUniforms[i];
740  glGetProgramResourceiv(mHandle, programInterface, i,
741  numProperties, properties, numProperties, nullptr, results);
742 
743  GLint numBytes = results[0] + 1;
744  std::vector<GLchar> name(numBytes);
745  glGetProgramResourceName(mHandle, programInterface, i, numBytes, nullptr, name.data());
746  info.name = std::string(name.data());
747 
748  GLint* current = &results[1];
749  info.location = *current++;
750  info.arraySize = *current++;
751 
752  GLint numCompatibleSubroutines = *current++;
753  if (numCompatibleSubroutines > 0)
754  {
755  info.compatibleSubroutines.resize(numCompatibleSubroutines);
756  std::fill(info.compatibleSubroutines.begin(),
757  info.compatibleSubroutines.end(), 0);
758  GLenum subProperty = GL_COMPATIBLE_SUBROUTINES;
759  glGetProgramResourceiv(mHandle, programInterface, i, 1,
760  &subProperty, numCompatibleSubroutines, nullptr,
761  &info.compatibleSubroutines[0]);
762  }
763  }
764  }
765 }
766 
768 {
769  GLint numResources = 0;
771  &numResources);
772  if (numResources > 0)
773  {
774  mBufferVariables.resize(numResources);
775 
776  GLenum properties[] =
777  {
779  GL_TYPE,
781  GL_OFFSET,
794  };
795  int const numProperties = sizeof(properties) / sizeof(int);
796  GLint results[numProperties] = { 0 };
797  for (int i = 0; i < numResources; ++i)
798  {
799  BufferVariable& info = mBufferVariables[i];
801  numProperties, properties, numProperties, nullptr, results);
802 
803  GLint numBytes = results[0] + 1;
804  std::vector<GLchar> name(numBytes);
805  glGetProgramResourceName(mHandle, GL_BUFFER_VARIABLE, i, numBytes, nullptr, name.data());
806  info.name = std::string(name.data());
807 
808  GLint* current = &results[1];
809  info.type = *current++;
810  info.arraySize = *current++;
811  info.offset = *current++;
812  info.blockIndex = *current++;
813  info.arrayStride = *current++;
814  info.matrixStride = *current++;
815  info.isRowMajor = *current++;
816  info.topLevelArraySize = *current++;
817  info.topLevelArrayStride = *current++;
818  info.referencedBy[ST_VERTEX] = *current++;
819  info.referencedBy[ST_GEOMETRY] = *current++;
820  info.referencedBy[ST_PIXEL] = *current++;
821  info.referencedBy[ST_COMPUTE] = *current++;
822  info.referencedBy[ST_TESSCONTROL] = *current++;
823  info.referencedBy[ST_TESSEVALUATION] = *current++;
824 
825  // Keep the original full name returned by the reflection.
826  info.fullName = info.name;
827 
828  // Look up the buffer block name to which this variable belongs.
829  auto const bufferBlockName = mShaderStorageBlocks[info.blockIndex].name + '.';
830 
831  // If the buffer variable begins with the name of the buffer block name,
832  // then remove it.
833  if (0 == info.name.find(bufferBlockName))
834  {
835  info.name = info.name.substr(bufferBlockName.length());
836  }
837 
838  // For an array member, the name is of the form "someName[...]...".
839  // The GTEngine Shader class currently wants "someName" because
840  // that is how GLSL delivered the name. Let's conform to that
841  // for now. But only if the [...] appears at the end of a name.
842  if (info.topLevelArrayStride > 1)
843  {
844  // Drop anything before the last "." reference.
845  auto index = info.name.find_last_of('.');
846  if (index != std::string::npos)
847  {
848  info.name = info.name.substr(index+1);
849  }
850 
851  // Drop any [...] if it appears at end.
852  index = info.name.find_last_of(']');
853  if (index == info.name.length() - 1)
854  {
855  index = info.name.find_last_of('[');
856  if (index != std::string::npos)
857  {
858  info.name = info.name.substr(0, index);
859  }
860  }
861  }
862  }
863  }
864 }
865 
867 {
868  GLint numResources = 0;
870  GL_ACTIVE_RESOURCES, &numResources);
871  if (numResources > 0)
872  {
873  mInputs.resize(numResources);
874 
875  GLenum properties[] =
876  {
878  GL_TYPE,
880  GL_OFFSET
881  };
882  int const numProperties = sizeof(properties) / sizeof(int);
883  GLint results[numProperties] = { 0 };
884  for (int i = 0; i < numResources; ++i)
885  {
888  numProperties, properties, numProperties, nullptr, results);
889 
890  GLint numBytes = results[0] + 1;
891  std::vector<GLchar> name(numBytes);
892  glGetProgramResourceName(mHandle, GL_TRANSFORM_FEEDBACK_VARYING, i, numBytes, nullptr, name.data());
893  info.name = std::string(name.data());
894 
895  GLint* current = &results[1];
896  info.type = *current++;
897  info.arraySize = *current++;
898  info.offset = *current++;
899  info.transformFeedbackBufferIndex = *current++;
900  }
901  }
902 }
903 
905 {
906  GLint numResources = 0;
908  GL_ACTIVE_RESOURCES, &numResources);
909  if (numResources > 0)
910  {
911  mTransformFeedbackBuffers.resize(numResources);
912 
913  GLenum properties[] =
914  {
917  };
918  int const numProperties = sizeof(properties) / sizeof(int);
919  GLint results[numProperties] = { 0 };
920  for (int i = 0; i < numResources; ++i)
921  {
924  numProperties, properties, numProperties, nullptr, results);
925 
926  GLint* current = &results[0];
927  info.bufferBinding = *current++;
928  info.transformFeedbackBufferStride = *current++;
929 
930  GLint numActiveVariables = *current++;
931  if (numActiveVariables > 0)
932  {
933  info.activeVariables.resize(numActiveVariables);
934  std::fill(info.activeVariables.begin(),
935  info.activeVariables.end(), 0);
936  GLenum varProperty = GL_ACTIVE_VARIABLES;
938  i, 1, &varProperty, numActiveVariables, nullptr,
939  &info.activeVariables[0]);
940  }
941  }
942  }
943 }
944 
945 unsigned GLSLReflection::GetEnumSize(GLenum value, GLint arraySize, GLint arrayStride, GLint matrixStride, GLint isRowMajor)
946 {
947  for (int i = 0; 0 != msEnumMap[i].value; ++i)
948  {
949  auto const& item = msEnumMap[i];
950  if (item.value == value)
951  {
952  if (arrayStride > 0)
953  {
954  return arrayStride * arraySize;
955  }
956  else if (matrixStride > 0)
957  {
958  if (isRowMajor)
959  {
960  return item.rows * matrixStride;
961  }
962  else
963  {
964  return item.cols * matrixStride;
965  }
966  }
967  else if (item.rows > 0)
968  {
969  return item.rows * item.size;
970  }
971  return 0;
972  }
973  }
974 
975  return 0;
976 }
977 
979 {
980  for (int i = 0; 0 != msEnumMap[i].value; ++i)
981  {
982  auto const& item = msEnumMap[i];
983  if (item.value == value)
984  {
985  return item.name;
986  }
987  }
988 
989  return std::string("unknown(type=") + std::to_string(value) + ")";
990 }
991 
993 {
994  for (int i = 0; 0 != msEnumMap[i].value; ++i)
995  {
996  auto const& item = msEnumMap[i];
997  if (item.value == value)
998  {
999  return item.shaderName;
1000  }
1001  }
1002 
1003  return std::string("unknown(type=") + std::to_string(value) + ")";
1004 }
1005 
1007 {
1008  std::string strList;
1009 
1010  if (referencedBy[ST_VERTEX]) strList += "vertex ";
1011  if (referencedBy[ST_GEOMETRY]) strList += "geometry ";
1012  if (referencedBy[ST_PIXEL]) strList += "pixel ";
1013  if (referencedBy[ST_COMPUTE]) strList += "compute ";
1014  if (referencedBy[ST_TESSCONTROL]) strList += "tessControl ";
1015  if (referencedBy[ST_TESSEVALUATION]) strList += "tessEvaluation ";
1016 
1017  return strList;
1018 }
1019 
1021 {
1022  // For each shader reported as NOT referencing the buffer 'name', search
1023  // the shader source code for 'buffer name { Type data[]; } instance'.
1024  // If found, then search the remaining strings for 'instance'. If a match
1025  // is found, then change the results[] reference value from 0 to 1.
1026  GLsizei maxCount = 0;
1028  if (maxCount < 0)
1029  {
1030  return;
1031  }
1032 
1033  std::vector<GLuint> shaders(maxCount);
1034  GLsizei count = 0;
1035  glGetAttachedShaders(mHandle, maxCount, &count, shaders.data());
1036  if (count != maxCount)
1037  {
1038  return;
1039  }
1040 
1041  for (auto shader : shaders)
1042  {
1043  GLint type = 0;
1045  auto iter = mShaderTypeMap.find(type);
1046  if (iter != mShaderTypeMap.end())
1047  {
1048  int index = iter->second;
1049  if (results[index] == 0)
1050  {
1051  // The shader is reported as not referenced. Verify
1052  // whether or not this is correct.
1053  GLint length = 0;
1055  if (length <= 0)
1056  {
1057  return;
1058  }
1059 
1060  std::vector<GLchar> rawSource(length);
1061  glGetShaderSource(shader, length, nullptr, rawSource.data());
1062  std::string source(rawSource.data());
1063 
1064  // Find 'buffer name { Type member[]; } instance;'.
1065  auto beginInstance = source.find("buffer " + name);
1066  if (beginInstance == std::string::npos)
1067  {
1068  return;
1069  }
1070 
1071  beginInstance = source.find('}', beginInstance);
1072  if (beginInstance == std::string::npos)
1073  {
1074  return;
1075  }
1076 
1077  if (++beginInstance >= source.length())
1078  {
1079  return;
1080  }
1081 
1082  if (source[beginInstance] == ';')
1083  {
1084  // Found 'buffer name { Type member[]; };
1085  // TODO: The shader can reference the buffer only via the
1086  // 'member' name. We still need to determine whether this
1087  // happens. For now in GTEngine samples, we always use an
1088  // 'instance'.
1089  return;
1090  }
1091 
1092  beginInstance = source.find_first_not_of(" \t", beginInstance);
1093  if (beginInstance == std::string::npos)
1094  {
1095  return;
1096  }
1097 
1098  auto endInstance = source.find_first_of(" ;\t", beginInstance);
1099  std::string instance = source.substr(beginInstance, endInstance - beginInstance);
1100 
1101  // We have found the 'instance' of the buffer. If it is referenced
1102  // later in the shader, convert the reference result to 1.
1103  if (source.find(instance, endInstance) != std::string::npos)
1104  {
1105  results[index] = 1;
1106  }
1107  }
1108  }
1109  }
1110 }
1111 
1112 #define ENUM(value, shadername, rows, cols, size) { value, #value, #shadername, rows, cols, size }
1114 {
1115  ENUM(GL_FLOAT, float , 1, 0, 4),
1116  ENUM(GL_FLOAT_VEC2, vec2 , 2, 0, 4),
1117  ENUM(GL_FLOAT_VEC3, vec3 , 3, 0, 4),
1118  ENUM(GL_FLOAT_VEC4, vec4 , 4, 0, 4),
1119  ENUM(GL_DOUBLE, double , 1, 0, 8),
1120  ENUM(GL_DOUBLE_VEC2, dvec2 , 2, 0, 8),
1121  ENUM(GL_DOUBLE_VEC3, dvec3 , 3, 0, 8),
1122  ENUM(GL_DOUBLE_VEC4, dvec4 , 4, 0, 8),
1123  ENUM(GL_INT, int , 1, 0, 4),
1124  ENUM(GL_INT_VEC2, ivec2 , 2, 0, 4),
1125  ENUM(GL_INT_VEC3, ivec3 , 3, 0, 4),
1126  ENUM(GL_INT_VEC4, ivec4 , 4, 0, 4),
1127  ENUM(GL_UNSIGNED_INT, uint , 1, 0, 4),
1128  ENUM(GL_UNSIGNED_INT_VEC2, uvec2 , 2, 0, 4),
1129  ENUM(GL_UNSIGNED_INT_VEC3, uvec3 , 3, 0, 4),
1130  ENUM(GL_UNSIGNED_INT_VEC4, uvec4 , 4, 0, 4),
1131  ENUM(GL_BOOL, bool , 1, 0, 4),
1132  ENUM(GL_BOOL_VEC2, bvec2 , 2, 0, 4),
1133  ENUM(GL_BOOL_VEC3, bvec3 , 3, 0, 4),
1134  ENUM(GL_BOOL_VEC4, bvec4 , 4, 0, 4),
1135  ENUM(GL_FLOAT_MAT2, mat2 , 2, 2, 4),
1136  ENUM(GL_FLOAT_MAT3, mat3 , 3, 3, 4),
1137  ENUM(GL_FLOAT_MAT4, mat4 , 4, 4, 4),
1138  ENUM(GL_FLOAT_MAT2x3, mat2x3 , 2, 3, 4),
1139  ENUM(GL_FLOAT_MAT2x4, mat2x4 , 2, 4, 4),
1140  ENUM(GL_FLOAT_MAT3x2, mat3x2 , 3, 2, 4),
1141  ENUM(GL_FLOAT_MAT3x4, mat3x4 , 3, 4, 4),
1142  ENUM(GL_FLOAT_MAT4x2, mat4x2 , 4, 2, 4),
1143  ENUM(GL_FLOAT_MAT4x3, mat4x3 , 4, 3, 4),
1144  ENUM(GL_DOUBLE_MAT2, dmat2 , 2, 2, 8),
1145  ENUM(GL_DOUBLE_MAT3, dmat3 , 3, 3, 8),
1146  ENUM(GL_DOUBLE_MAT4, dmat4 , 4, 4, 8),
1147  ENUM(GL_DOUBLE_MAT2x3, dmat2x3 , 2, 3, 8),
1148  ENUM(GL_DOUBLE_MAT2x4, dmat2x4 , 2, 4, 8),
1149  ENUM(GL_DOUBLE_MAT3x2, dmat3x2 , 3, 2, 8),
1150  ENUM(GL_DOUBLE_MAT3x4, dmat3x4 , 3, 4, 8),
1151  ENUM(GL_DOUBLE_MAT4x2, dmat4x2 , 4, 2, 8),
1152  ENUM(GL_DOUBLE_MAT4x3, dmat4x3 , 4, 3, 8),
1153  ENUM(GL_SAMPLER_1D, sampler1D , 0, 0, 0),
1154  ENUM(GL_SAMPLER_2D, sampler2D , 0, 0, 0),
1155  ENUM(GL_SAMPLER_3D, sampler3D , 0, 0, 0),
1156  ENUM(GL_SAMPLER_CUBE, samplerCube , 0, 0, 0),
1157  ENUM(GL_SAMPLER_1D_SHADOW, sampler1DShadow , 0, 0, 0),
1158  ENUM(GL_SAMPLER_2D_SHADOW, sampler2DShadow , 0, 0, 0),
1159  ENUM(GL_SAMPLER_1D_ARRAY, sampler1DArray , 0, 0, 0),
1160  ENUM(GL_SAMPLER_2D_ARRAY, sampler2DArray , 0, 0, 0),
1161  ENUM(GL_SAMPLER_1D_ARRAY_SHADOW, sampler1DArrayShadow , 0, 0, 0),
1162  ENUM(GL_SAMPLER_2D_ARRAY_SHADOW, sampler2DArrayShadow , 0, 0, 0),
1163  ENUM(GL_SAMPLER_2D_MULTISAMPLE, sampler2DMS , 0, 0, 0),
1164  ENUM(GL_SAMPLER_2D_MULTISAMPLE_ARRAY, sampler2DMSArray , 0, 0, 0),
1165  ENUM(GL_SAMPLER_CUBE_SHADOW, samplerCubeShadow , 0, 0, 0),
1166  ENUM(GL_SAMPLER_CUBE_MAP_ARRAY, samplerCubeArray, 0, 0, 0),
1167  ENUM(GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW, samplerCubeArrayShadow, 0, 0, 0),
1168  ENUM(GL_SAMPLER_BUFFER, samplerBuffer , 0, 0, 0),
1169  ENUM(GL_SAMPLER_2D_RECT, sampler2DRect , 0, 0, 0),
1170  ENUM(GL_SAMPLER_2D_RECT_SHADOW, sampler2DRectShadow , 0, 0, 0),
1171  ENUM(GL_INT_SAMPLER_1D, isampler1D , 0, 0, 0),
1172  ENUM(GL_INT_SAMPLER_2D, isampler2D , 0, 0, 0),
1173  ENUM(GL_INT_SAMPLER_3D, isampler3D , 0, 0, 0),
1174  ENUM(GL_INT_SAMPLER_CUBE, isamplerCube , 0, 0, 0),
1175  ENUM(GL_INT_SAMPLER_1D_ARRAY, isampler1DArray , 0, 0, 0),
1176  ENUM(GL_INT_SAMPLER_2D_ARRAY, isampler2DArray , 0, 0, 0),
1177  ENUM(GL_INT_SAMPLER_2D_MULTISAMPLE, isampler2DMS , 0, 0, 0),
1178  ENUM(GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY, isampler2DMSArray , 0, 0, 0),
1179  ENUM(GL_INT_SAMPLER_CUBE_MAP_ARRAY, isamplerCubeArray , 0, 0, 0),
1180  ENUM(GL_INT_SAMPLER_BUFFER, isamplerBuffer , 0, 0, 0),
1181  ENUM(GL_INT_SAMPLER_2D_RECT, isampler2DRect , 0, 0, 0),
1182  ENUM(GL_UNSIGNED_INT_SAMPLER_1D, usampler1D , 0, 0, 0),
1183  ENUM(GL_UNSIGNED_INT_SAMPLER_2D, usampler2D , 0, 0, 0),
1184  ENUM(GL_UNSIGNED_INT_SAMPLER_3D, usampler3D , 0, 0, 0),
1185  ENUM(GL_UNSIGNED_INT_SAMPLER_CUBE, usamplerCube , 0, 0, 0),
1186  ENUM(GL_UNSIGNED_INT_SAMPLER_1D_ARRAY, usampler2DArray , 0, 0, 0),
1187  ENUM(GL_UNSIGNED_INT_SAMPLER_2D_ARRAY, usampler2DArray , 0, 0, 0),
1188  ENUM(GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE, usampler2DMS , 0, 0, 0),
1189  ENUM(GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY, usampler2DMSArray , 0, 0, 0),
1190  ENUM(GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY, usamplerCubeArray , 0, 0, 0),
1191  ENUM(GL_UNSIGNED_INT_SAMPLER_BUFFER, usamplerBuffer , 0, 0, 0),
1192  ENUM(GL_UNSIGNED_INT_SAMPLER_2D_RECT, usampler2DRect , 0, 0, 0),
1193  ENUM(GL_IMAGE_1D, image1D , 0, 0, 0),
1194  ENUM(GL_IMAGE_2D, image2D , 0, 0, 0),
1195  ENUM(GL_IMAGE_3D, image3D , 0, 0, 0),
1196  ENUM(GL_IMAGE_CUBE, imageCube , 0, 0, 0),
1197  ENUM(GL_IMAGE_1D_ARRAY, image1DArray , 0, 0, 0),
1198  ENUM(GL_IMAGE_2D_ARRAY, image2DArray , 0, 0, 0),
1199  ENUM(GL_IMAGE_2D_MULTISAMPLE, image2DMS , 0, 0, 0),
1200  ENUM(GL_IMAGE_2D_MULTISAMPLE_ARRAY, image2DMSArray , 0, 0, 0),
1201  ENUM(GL_IMAGE_CUBE_MAP_ARRAY, imageCubeArray , 0, 0, 0),
1202  ENUM(GL_IMAGE_BUFFER, imageBuffer , 0, 0, 0),
1203  ENUM(GL_IMAGE_2D_RECT, image2DRect , 0, 0, 0),
1204  ENUM(GL_INT_IMAGE_1D, iimage1D , 0, 0, 0),
1205  ENUM(GL_INT_IMAGE_2D, iimage2D , 0, 0, 0),
1206  ENUM(GL_INT_IMAGE_3D, iimage3D , 0, 0, 0),
1207  ENUM(GL_INT_IMAGE_CUBE, iimageCube , 0, 0, 0),
1208  ENUM(GL_INT_IMAGE_1D_ARRAY, iimage1DArray , 0, 0, 0),
1209  ENUM(GL_INT_IMAGE_2D_ARRAY, iimage2DArray , 0, 0, 0),
1210  ENUM(GL_INT_IMAGE_2D_MULTISAMPLE, iimage2DMS , 0, 0, 0),
1211  ENUM(GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY, iimage2DMSArray , 0, 0, 0),
1212  ENUM(GL_INT_IMAGE_CUBE_MAP_ARRAY, iimageCubeArray , 0, 0, 0),
1213  ENUM(GL_INT_IMAGE_BUFFER, iimageBuffer , 0, 0, 0),
1214  ENUM(GL_INT_IMAGE_2D_RECT, iimage2DRect , 0, 0, 0),
1215  ENUM(GL_UNSIGNED_INT_IMAGE_1D, uimage1D , 0, 0, 0),
1216  ENUM(GL_UNSIGNED_INT_IMAGE_2D, uimage2D , 0, 0, 0),
1217  ENUM(GL_UNSIGNED_INT_IMAGE_3D, uimage3D , 0, 0, 0),
1218  ENUM(GL_UNSIGNED_INT_IMAGE_CUBE, uimageCube , 0, 0, 0),
1219  ENUM(GL_UNSIGNED_INT_IMAGE_1D_ARRAY, uimage2DArray , 0, 0, 0),
1220  ENUM(GL_UNSIGNED_INT_IMAGE_2D_ARRAY, uimage2DArray , 0, 0, 0),
1221  ENUM(GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE, uimage2DMS , 0, 0, 0),
1222  ENUM(GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY, uimage2DMSArray , 0, 0, 0),
1223  ENUM(GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY, uimageCubeArray, 0, 0, 0),
1224  ENUM(GL_UNSIGNED_INT_IMAGE_BUFFER, uimageBuffer , 0, 0, 0),
1225  ENUM(GL_UNSIGNED_INT_IMAGE_2D_RECT, uimage2DRect , 0, 0, 0),
1226  ENUM(GL_UNSIGNED_INT_ATOMIC_COUNTER, atomic_uint , 0, 0, 0),
1227  {0, "", "", 0, 0, 0 }
1228 };
1229 #undef ENUM
void APIENTRY glGetProgramResourceiv(GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei bufSize, GLsizei *length, GLint *params)
Definition: GteOpenGL.cpp:7993
void IntelWorkaround(std::string const &name, GLint results[])
#define GL_IS_PER_PATCH
Definition: glcorearb.h:2467
#define GL_COMPATIBLE_SUBROUTINES
Definition: glcorearb.h:1747
#define GL_INT_SAMPLER_1D_ARRAY
Definition: glcorearb.h:1087
#define GL_SAMPLER_3D
Definition: glcorearb.h:751
#define GL_INT_SAMPLER_2D_ARRAY
Definition: glcorearb.h:1088
#define GL_REFERENCED_BY_TESS_EVALUATION_SHADER
Definition: glcorearb.h:2459
int GLint
Definition: glcorearb.h:85
unsigned int GLuint
Definition: glcorearb.h:89
#define ENUM(value, shadername, rows, cols, size)
#define GL_UNSIGNED_INT_VEC4
Definition: glcorearb.h:1082
#define GL_DOUBLE_MAT4x3
Definition: glcorearb.h:1738
#define GL_REFERENCED_BY_VERTEX_SHADER
Definition: glcorearb.h:2457
#define GL_TESS_CONTROL_SUBROUTINE
Definition: glcorearb.h:2428
#define GL_SAMPLER_2D_MULTISAMPLE
Definition: glcorearb.h:1577
#define GL_COMPUTE_SHADER
Definition: glcorearb.h:2258
#define GL_FRAGMENT_SUBROUTINE
Definition: glcorearb.h:2431
#define GL_TESS_CONTROL_SUBROUTINE_UNIFORM
Definition: glcorearb.h:2434
#define GL_TOP_LEVEL_ARRAY_SIZE
Definition: glcorearb.h:2463
#define GL_TOP_LEVEL_ARRAY_STRIDE
Definition: glcorearb.h:2464
#define GL_UNSIGNED_INT_VEC2
Definition: glcorearb.h:1080
std::vector< std::string > mTessEvaluationSubroutines
#define GL_UNSIGNED_INT_SAMPLER_CUBE
Definition: glcorearb.h:1092
GLint APIENTRY glGetUniformLocation(GLuint program, const GLchar *name)
Definition: GteOpenGL.cpp:2129
#define GL_PROGRAM_OUTPUT
Definition: glcorearb.h:2424
#define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY
Definition: glcorearb.h:2193
#define GL_FLOAT_MAT3x4
Definition: glcorearb.h:974
#define GL_UNSIGNED_INT_IMAGE_2D_RECT
Definition: glcorearb.h:2188
#define GL_GEOMETRY_SUBROUTINE_UNIFORM
Definition: glcorearb.h:2436
void APIENTRY glGetShaderSource(GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source)
Definition: GteOpenGL.cpp:2116
static const EnumMap msEnumMap[]
#define GL_SAMPLER_2D_RECT_SHADOW
Definition: glcorearb.h:1392
#define GL_INT_IMAGE_1D_ARRAY
Definition: glcorearb.h:2180
static std::string GetEnumName(GLenum value)
#define GL_TESS_EVALUATION_SHADER
Definition: glcorearb.h:1778
#define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY
Definition: glcorearb.h:1718
std::vector< Output > mOutputs
void Print(std::ofstream &output) const
#define GL_FLOAT_MAT4x2
Definition: glcorearb.h:975
void APIENTRY glGetAttachedShaders(GLuint program, GLsizei maxCount, GLsizei *count, GLuint *shaders)
Definition: GteOpenGL.cpp:2035
#define GL_PROGRAM_INPUT
Definition: glcorearb.h:2423
std::vector< SubroutineUniform > mTessControlSubroutineUniforms
std::vector< TransformFeedbackBuffer > mTransformFeedbackBuffers
#define GL_UNSIGNED_INT_IMAGE_2D
Definition: glcorearb.h:2186
#define GL_FLOAT_MAT4x3
Definition: glcorearb.h:976
#define GL_BUFFER_VARIABLE
Definition: glcorearb.h:2425
#define GL_DOUBLE_MAT2x4
Definition: glcorearb.h:1734
#define GL_FLOAT
Definition: glcorearb.h:329
#define GL_BUFFER_DATA_SIZE
Definition: glcorearb.h:2454
#define GL_COMPUTE_SUBROUTINE
Definition: glcorearb.h:2432
#define GL_ACTIVE_RESOURCES
Definition: glcorearb.h:2440
#define GL_GEOMETRY_SHADER
Definition: glcorearb.h:1532
#define GL_UNSIGNED_INT_SAMPLER_2D
Definition: glcorearb.h:1090
#define GL_UNIFORM_BLOCK
Definition: glcorearb.h:2422
std::vector< GLint > activeVariables
#define GL_NAME_LENGTH
Definition: glcorearb.h:2444
#define GL_DOUBLE_MAT2
Definition: glcorearb.h:1730
#define GL_UNSIGNED_INT_SAMPLER_1D
Definition: glcorearb.h:1089
#define GL_ACTIVE_VARIABLES
Definition: glcorearb.h:2456
#define GL_SAMPLER_CUBE_SHADOW
Definition: glcorearb.h:1079
static unsigned GetEnumSize(GLenum value, GLint arraySize, GLint arrayStride, GLint matrixStride, GLint isRowMajor)
#define GL_UNSIGNED_INT_SAMPLER_3D
Definition: glcorearb.h:1091
#define GL_INT_VEC3
Definition: glcorearb.h:740
#define GL_SAMPLER_1D_ARRAY_SHADOW
Definition: glcorearb.h:1077
#define GL_DOUBLE
Definition: glcorearb.h:330
#define GL_REFERENCED_BY_GEOMETRY_SHADER
Definition: glcorearb.h:2460
#define GL_UNSIGNED_INT_SAMPLER_BUFFER
Definition: glcorearb.h:1397
GLsizei const GLfloat * value
Definition: glcorearb.h:819
#define GL_INT_SAMPLER_2D_RECT
Definition: glcorearb.h:1394
#define GL_SAMPLER_CUBE_MAP_ARRAY
Definition: glcorearb.h:1715
GLuint const GLchar * name
Definition: glcorearb.h:781
#define GL_UNSIGNED_INT_ATOMIC_COUNTER
Definition: glcorearb.h:2142
void APIENTRY glGetProgramInterfaceiv(GLuint program, GLenum programInterface, GLenum pname, GLint *params)
Definition: GteOpenGL.cpp:7951
#define GL_IMAGE_BUFFER
Definition: glcorearb.h:2168
#define GL_IMAGE_3D
Definition: glcorearb.h:2165
#define GL_UNSIGNED_INT_IMAGE_1D
Definition: glcorearb.h:2185
#define GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY
Definition: glcorearb.h:1581
#define GL_INT_IMAGE_2D_ARRAY
Definition: glcorearb.h:2181
#define GL_INT_SAMPLER_CUBE
Definition: glcorearb.h:1086
#define GL_TESS_EVALUATION_SUBROUTINE_UNIFORM
Definition: glcorearb.h:2435
#define GL_UNSIGNED_INT_SAMPLER_2D_RECT
Definition: glcorearb.h:1396
#define GL_INT_SAMPLER_CUBE_MAP_ARRAY
Definition: glcorearb.h:1717
GLSLReflection(GLuint handle)
#define GL_IMAGE_CUBE
Definition: glcorearb.h:2167
#define GL_OFFSET
Definition: glcorearb.h:2447
#define GL_TRANSFORM_FEEDBACK_VARYING
Definition: glcorearb.h:2439
void APIENTRY glGetProgramiv(GLuint program, GLenum pname, GLint *params)
Definition: GteOpenGL.cpp:2064
#define GL_TESS_EVALUATION_SUBROUTINE
Definition: glcorearb.h:2429
#define GL_INT_SAMPLER_2D_MULTISAMPLE
Definition: glcorearb.h:1578
GLsizeiptr size
Definition: glcorearb.h:659
#define GL_IMAGE_2D
Definition: glcorearb.h:2164
#define GL_IMAGE_CUBE_MAP_ARRAY
Definition: glcorearb.h:2171
#define GL_DOUBLE_MAT4
Definition: glcorearb.h:1732
#define GL_SAMPLER_2D_MULTISAMPLE_ARRAY
Definition: glcorearb.h:1580
#define GL_DOUBLE_MAT4x2
Definition: glcorearb.h:1737
#define GL_SHADER_TYPE
Definition: glcorearb.h:735
void APIENTRY glGetProgramResourceName(GLuint program, GLenum programInterface, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name)
Definition: GteOpenGL.cpp:7980
#define GL_REFERENCED_BY_COMPUTE_SHADER
Definition: glcorearb.h:2462
#define GL_INT_VEC4
Definition: glcorearb.h:741
int GLsizei
Definition: glcorearb.h:86
#define GL_BOOL_VEC4
Definition: glcorearb.h:745
#define GL_ATTACHED_SHADERS
Definition: glcorearb.h:760
#define GL_SAMPLER_2D_SHADOW
Definition: glcorearb.h:754
#define GL_INT_SAMPLER_1D
Definition: glcorearb.h:1083
std::vector< SubroutineUniform > mVertexSubroutineUniforms
#define GL_FLOAT_MAT2
Definition: glcorearb.h:746
#define GL_INT_IMAGE_2D
Definition: glcorearb.h:2175
std::vector< TransformFeedbackVarying > mTransformFeedbackVaryings
std::vector< SubroutineUniform > mPixelSubroutineUniforms
#define GL_GEOMETRY_SUBROUTINE
Definition: glcorearb.h:2430
#define GL_BUFFER_BINDING
Definition: glcorearb.h:2453
#define GL_BOOL_VEC2
Definition: glcorearb.h:743
std::vector< std::string > mGeometrySubroutines
#define GL_FRAGMENT_SUBROUTINE_UNIFORM
Definition: glcorearb.h:2437
#define GL_FLOAT_MAT3
Definition: glcorearb.h:747
#define GL_BLOCK_INDEX
Definition: glcorearb.h:2448
#define GL_DOUBLE_MAT2x3
Definition: glcorearb.h:1733
#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY
Definition: glcorearb.h:1094
#define GL_VERTEX_SUBROUTINE
Definition: glcorearb.h:2427
#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE
Definition: glcorearb.h:1579
std::vector< SubroutineUniform > mComputeSubroutineUniforms
std::vector< Uniform > mUniforms
unsigned int GLenum
Definition: glcorearb.h:83
GLsizei GLsizei GLchar * source
Definition: glcorearb.h:798
#define GL_NUM_ACTIVE_VARIABLES
Definition: glcorearb.h:2455
std::vector< std::string > mTessControlSubroutines
#define GL_TYPE
Definition: glcorearb.h:2445
#define GL_IMAGE_1D
Definition: glcorearb.h:2163
#define GL_UNSIGNED_INT_IMAGE_CUBE
Definition: glcorearb.h:2189
GLsizei const GLchar *const * string
Definition: glcorearb.h:809
#define GL_ARRAY_STRIDE
Definition: glcorearb.h:2449
#define LogError(message)
Definition: GteLogger.h:92
#define GL_DOUBLE_MAT3
Definition: glcorearb.h:1731
#define GL_SHADER_SOURCE_LENGTH
Definition: glcorearb.h:763
#define GL_DOUBLE_MAT3x2
Definition: glcorearb.h:1735
#define GL_FLOAT_VEC3
Definition: glcorearb.h:737
std::vector< DataBlock > mShaderStorageBlocks
#define GL_SHADER_STORAGE_BLOCK
Definition: glcorearb.h:2426
#define GL_INT_IMAGE_CUBE
Definition: glcorearb.h:2178
#define GL_INT_IMAGE_CUBE_MAP_ARRAY
Definition: glcorearb.h:2182
const GLubyte *APIENTRY glGetString(GLenum name)
Definition: GteOpenGL.cpp:645
#define GL_LOCATION_INDEX
Definition: glcorearb.h:2466
#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY
Definition: glcorearb.h:2195
#define GL_FLOAT_MAT4
Definition: glcorearb.h:748
#define GL_RENDERER
Definition: glcorearb.h:369
#define GL_REFERENCED_BY_FRAGMENT_SHADER
Definition: glcorearb.h:2461
GLint GLsizei count
Definition: glcorearb.h:400
#define GL_LOCATION
Definition: glcorearb.h:2465
#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY
Definition: glcorearb.h:1582
#define GL_INT_SAMPLER_BUFFER
Definition: glcorearb.h:1395
GLsizei GLsizei GLuint * shaders
Definition: glcorearb.h:792
#define GL_VERTEX_SHADER
Definition: glcorearb.h:729
#define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY
Definition: glcorearb.h:1093
#define GL_INT_VEC2
Definition: glcorearb.h:739
#define GL_INT_IMAGE_2D_MULTISAMPLE
Definition: glcorearb.h:2183
#define GL_VERSION
Definition: glcorearb.h:370
std::vector< DataBlock > mUniformBlocks
#define GL_DOUBLE_VEC3
Definition: glcorearb.h:1728
#define GL_SAMPLER_1D_ARRAY
Definition: glcorearb.h:1075
#define GL_UNIFORM
Definition: glcorearb.h:2421
#define GL_FRAGMENT_SHADER
Definition: glcorearb.h:728
#define GL_IMAGE_1D_ARRAY
Definition: glcorearb.h:2169
#define GL_ATOMIC_COUNTER_BUFFER_INDEX
Definition: glcorearb.h:2452
#define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW
Definition: glcorearb.h:1716
#define GL_TESS_CONTROL_SHADER
Definition: glcorearb.h:1779
#define GL_FLOAT_VEC4
Definition: glcorearb.h:738
void ReflectSubroutines(GLenum programInterface, std::vector< std::string > &subroutines)
#define GL_BOOL_VEC3
Definition: glcorearb.h:744
#define GL_IS_ROW_MAJOR
Definition: glcorearb.h:2451
void ReflectDataBlocks(GLenum programInterface, std::vector< DataBlock > &blocks)
GLsizei maxCount
Definition: glcorearb.h:792
GLuint GLsizei GLsizei * length
Definition: glcorearb.h:790
#define GL_SAMPLER_1D
Definition: glcorearb.h:749
GLuint shader
Definition: glcorearb.h:780
#define GL_IMAGE_2D_RECT
Definition: glcorearb.h:2166
#define GL_IMAGE_2D_MULTISAMPLE_ARRAY
Definition: glcorearb.h:2173
GLuint APIENTRY glGetProgramResourceIndex(GLuint program, GLenum programInterface, const GLchar *name)
Definition: GteOpenGL.cpp:7964
std::vector< SubroutineUniform > mGeometrySubroutineUniforms
std::vector< BufferVariable > mBufferVariables
#define GL_UNSIGNED_INT
Definition: glcorearb.h:328
const GLdouble * v
Definition: glcorearb.h:832
#define GL_SAMPLER_2D_RECT
Definition: glcorearb.h:1391
GLenum GLenum GLenum input
Definition: glext.h:9913
#define GL_UNSIGNED_INT_IMAGE_3D
Definition: glcorearb.h:2187
#define GL_SAMPLER_BUFFER
Definition: glcorearb.h:1393
GLuint index
Definition: glcorearb.h:781
#define GL_DOUBLE_VEC4
Definition: glcorearb.h:1729
std::vector< std::string > mPixelSubroutines
#define GL_ARRAY_SIZE
Definition: glcorearb.h:2446
#define GL_REFERENCED_BY_TESS_CONTROL_SHADER
Definition: glcorearb.h:2458
#define GL_SAMPLER_2D_ARRAY_SHADOW
Definition: glcorearb.h:1078
void GetComputeShaderWorkGroupSize(GLint &numXThreads, GLint &numYThreads, GLint &numZThreads) const
#define GL_BOOL
Definition: glcorearb.h:742
#define GL_DOUBLE_VEC2
Definition: glcorearb.h:1727
void ReflectSubroutineUniforms(GLenum programInterface, std::vector< SubroutineUniform > &subUniforms)
std::vector< std::string > mVertexSubroutines
#define GL_MATRIX_STRIDE
Definition: glcorearb.h:2450
GLenum programInterface
Definition: glcorearb.h:2517
#define GL_FLOAT_VEC2
Definition: glcorearb.h:736
#define GL_FLOAT_MAT3x2
Definition: glcorearb.h:973
#define GL_SAMPLER_CUBE
Definition: glcorearb.h:752
#define GL_FLOAT_MAT2x3
Definition: glcorearb.h:971
#define GL_FLOAT_MAT2x4
Definition: glcorearb.h:972
#define GL_INT_IMAGE_2D_RECT
Definition: glcorearb.h:2177
#define GL_INT_IMAGE_3D
Definition: glcorearb.h:2176
#define GL_INT_IMAGE_BUFFER
Definition: glcorearb.h:2179
#define GL_ATOMIC_COUNTER_BUFFER
Definition: glcorearb.h:2114
#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE
Definition: glcorearb.h:2194
#define GL_SAMPLER_1D_SHADOW
Definition: glcorearb.h:753
#define GL_IMAGE_2D_ARRAY
Definition: glcorearb.h:2170
#define GL_UNSIGNED_INT_IMAGE_BUFFER
Definition: glcorearb.h:2190
#define GL_UNSIGNED_INT_IMAGE_1D_ARRAY
Definition: glcorearb.h:2191
#define GL_SAMPLER_2D
Definition: glcorearb.h:750
#define GL_VENDOR
Definition: glcorearb.h:368
#define GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY
Definition: glcorearb.h:2184
#define GL_COMPUTE_SUBROUTINE_UNIFORM
Definition: glcorearb.h:2438
#define GL_SAMPLER_2D_ARRAY
Definition: glcorearb.h:1076
#define GL_VERTEX_SUBROUTINE_UNIFORM
Definition: glcorearb.h:2433
#define GL_INT_SAMPLER_2D
Definition: glcorearb.h:1084
GLuint64EXT * result
Definition: glext.h:10003
std::map< GLenum, int > mShaderTypeMap
#define GL_INT_IMAGE_1D
Definition: glcorearb.h:2174
#define GL_COMPUTE_WORK_GROUP_SIZE
Definition: glcorearb.h:2270
std::vector< AtomicCounterBuffer > mAtomicCounterBuffers
std::vector< std::string > mComputeSubroutines
#define GL_UNSIGNED_INT_IMAGE_2D_ARRAY
Definition: glcorearb.h:2192
#define GL_IMAGE_2D_MULTISAMPLE
Definition: glcorearb.h:2172
GLint GLint GLsizei GLint GLenum GLenum type
Definition: glcorearb.h:103
static std::string GetEnumShaderName(GLenum value)
void APIENTRY glGetShaderiv(GLuint shader, GLenum pname, GLint *params)
Definition: GteOpenGL.cpp:2090
std::vector< Input > mInputs
#define GL_INT
Definition: glcorearb.h:327
#define GL_TRANSFORM_FEEDBACK_BUFFER
Definition: glcorearb.h:1054
#define GL_DOUBLE_MAT3x4
Definition: glcorearb.h:1736
static std::string GetReferencedByShaderList(GLint const referencedBy[6])
#define GL_UNSIGNED_INT_VEC3
Definition: glcorearb.h:1081
#define GL_INVALID_INDEX
Definition: glcorearb.h:1451
std::vector< SubroutineUniform > mTessEvaluationSubroutineUniforms
#define GL_INT_SAMPLER_3D
Definition: glcorearb.h:1085
#define GL_SHADING_LANGUAGE_VERSION
Definition: glcorearb.h:767


geometric_tools_engine
Author(s): Yijiang Huang
autogenerated on Thu Jul 18 2019 04:00:00