GteShader.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.0 (2016/06/19)
7 
8 #include <GTEnginePCH.h>
9 #include <Graphics/GteShader.h>
10 using namespace gte;
11 
12 
13 Shader::Data::Data(GraphicsObjectType inType, std::string const& inName,
14  int inBindPoint, int inNumBytes, unsigned int inExtra,
15  bool inIsGpuWritable)
16  :
17  type(inType),
18  name(inName),
19  bindPoint(inBindPoint),
20  numBytes(inNumBytes),
21  extra(inExtra),
22  isGpuWritable(inIsGpuWritable)
23 {
24 }
25 
26 #if defined(GTE_DEV_OPENGL)
27 Shader::Shader(GLSLReflection const& reflector, int type)
28  :
29  mNumXThreads(0), // TODO: compute shader support
30  mNumYThreads(0),
31  mNumZThreads(0)
32 {
33  // If this is a compute shader, then query the number of threads per group.
35  {
36  GLint sizeX, sizeY, sizeZ;
37  reflector.GetComputeShaderWorkGroupSize(sizeX, sizeY, sizeZ);
38  mNumXThreads = sizeX;
39  mNumYThreads = sizeY;
40  mNumZThreads = sizeZ;
41  }
42 
43  // Will need to access uniforms more than once.
44  auto const& uniforms = reflector.GetUniforms();
45 
46  // Gather the uninforms information to create texture data.
47  for (auto const& uni : uniforms)
48  {
49  if (uni.referencedBy[type])
50  {
51  // Only interested in these particular uniform types (for gsampler* and gimage*)
52  switch (uni.type)
53  {
54  case GL_SAMPLER_1D:
55  case GL_INT_SAMPLER_1D:
58  Data(GT_TEXTURE_SINGLE, uni.name, uni.location, 0, 1, false));
60  Data(GT_SAMPLER_STATE, uni.name, uni.location, 0, GT_TEXTURE1, false));
61  break;
62 
63  case GL_SAMPLER_2D:
64  case GL_INT_SAMPLER_2D:
67  Data(GT_TEXTURE_SINGLE, uni.name, uni.location, 0, 2, false));
69  Data(GT_SAMPLER_STATE, uni.name, uni.location, 0, GT_TEXTURE2, false));
70  break;
71 
72  case GL_SAMPLER_3D:
73  case GL_INT_SAMPLER_3D:
76  Data(GT_TEXTURE_SINGLE, uni.name, uni.location, 0, 3, false));
78  Data(GT_SAMPLER_STATE, uni.name, uni.location, 0, GT_TEXTURE3, false));
79  break;
80 
85  Data(GT_TEXTURE_ARRAY, uni.name, uni.location, 0, 1, false));
87  Data(GT_SAMPLER_STATE, uni.name, uni.location, 0, GT_TEXTURE1_ARRAY, false));
88  break;
89 
94  Data(GT_TEXTURE_ARRAY, uni.name, uni.location, 0, 2, false));
96  Data(GT_SAMPLER_STATE, uni.name, uni.location, 0, GT_TEXTURE2_ARRAY, false));
97  break;
98 
99  case GL_SAMPLER_CUBE:
100  case GL_INT_SAMPLER_CUBE:
103  Data(GT_TEXTURE_ARRAY, uni.name, uni.location, 0, 2, false));
105  Data(GT_SAMPLER_STATE, uni.name, uni.location, 0, GT_TEXTURE_CUBE, false));
106  break;
107 
112  Data(GT_TEXTURE_ARRAY, uni.name, uni.location, 0, 3, false));
114  Data(GT_SAMPLER_STATE, uni.name, uni.location, 0, GT_TEXTURE_CUBE_ARRAY, false));
115  break;
116 
117  case GL_IMAGE_1D:
118  case GL_INT_IMAGE_1D:
121  Data(GT_TEXTURE_SINGLE, uni.name, uni.location, 0, 1, true));
122  break;
123 
124  case GL_IMAGE_2D:
125  case GL_INT_IMAGE_2D:
128  Data(GT_TEXTURE_SINGLE, uni.name, uni.location, 0, 2, true));
129  break;
130 
131  case GL_IMAGE_3D:
132  case GL_INT_IMAGE_3D:
135  Data(GT_TEXTURE_SINGLE, uni.name, uni.location, 0, 3, true));
136  break;
137 
138  case GL_IMAGE_1D_ARRAY:
142  Data(GT_TEXTURE_ARRAY, uni.name, uni.location, 0, 1, true));
143  break;
144 
145  case GL_IMAGE_2D_ARRAY:
149  Data(GT_TEXTURE_ARRAY, uni.name, uni.location, 0, 2, true));
150  break;
151 
152  case GL_IMAGE_CUBE:
153  case GL_INT_IMAGE_CUBE:
156  Data(GT_TEXTURE_ARRAY, uni.name, uni.location, 0, 2, true));
157  break;
158 
163  Data(GT_TEXTURE_ARRAY, uni.name, uni.location, 0, 3, true));
164  break;
165  }
166  }
167  }
168 
169  // Gather the uniform blocks information to create constant buffer data.
170  auto const& uniformBlocks = reflector.GetUniformBlocks();
171  int numUniformBlockReferences = 0;
172  for (auto const& block : uniformBlocks)
173  {
174  if (block.referencedBy[type])
175  {
176  ++numUniformBlockReferences;
177  }
178  }
179  if (numUniformBlockReferences > 0)
180  {
181  mCBufferLayouts.resize(numUniformBlockReferences);
182 
183  // Store information needed by GL4Engine for enabling/disabling the
184  // constant buffers.
185  int blockIndex = 0;
186  int layoutIndex = 0;
187  for (auto const& block : uniformBlocks)
188  {
189  if (block.referencedBy[type])
190  {
192  Data(GT_CONSTANT_BUFFER, block.name, block.bufferBinding,
193  block.bufferDataSize, 0, false));
194 
195  // Assemble the constant buffer layout information.
196  for (auto const& uniform : uniforms)
197  {
198  if (uniform.blockIndex != blockIndex)
199  {
200  continue;
201 
202  }
203  MemberLayout item;
204  item.name = uniform.name;
205  item.offset = uniform.offset;
206  // TODO: The HLSL reflection has numElements of 0 when
207  // the item is not an array, but the actual number when
208  // it is an array. ConstantBuffer::SetMember(...) uses
209  // this information, so we need to adhere to the pattern.
210  // Change this design in a refactor?
211  item.numElements =
212  (uniform.arraySize > 1 ? uniform.arraySize : 0);
213 
214  mCBufferLayouts[layoutIndex].push_back(item);
215  }
216 
217  ++layoutIndex;
218  }
219 
220  ++blockIndex;
221  }
222  }
223 
224  // Gather the atomic counter buffer information to create atomic counter buffer data.
225  auto const& atomicCounterBuffers = reflector.GetAtomicCounterBuffers();
226  int numAtomicCounterBufferReferences = 0;
227  for (auto const& block : atomicCounterBuffers)
228  {
229  if (block.referencedBy[type])
230  {
231  ++numAtomicCounterBufferReferences;
232  }
233  }
234  if (numAtomicCounterBufferReferences > 0)
235  {
236  unsigned blockIndex = 0;
237  for (auto const& block : atomicCounterBuffers)
238  {
239  if (block.referencedBy[type])
240  {
241  // It is possible for the atomic counter buffer to indicate it
242  // only has 4 bytes for a single counter located at offset=4.
243  // But we will want to allocate a buffer large enough to store
244  // from offset=0 to the last counter declared in the buffer.
245  unsigned bufferDataSize = block.bufferDataSize;
246  for (unsigned i=0; i < block.activeVariables.size(); ++i)
247  {
248  auto const& ac = uniforms[block.activeVariables[i]];
249  unsigned const lastByte = ac.offset + 4;
250 
251  bufferDataSize = std::max(bufferDataSize, lastByte);
252  }
253 
254  mData[AtomicCounterBufferShaderDataLookup].push_back(
255  Data(GT_RESOURCE, "atomicCounterBuffer" + std::to_string(blockIndex),
256  block.bufferBinding, bufferDataSize, 0, true));
257  }
258  ++blockIndex;
259  }
260  }
261 
262  // Gather the buffer blocks information to create structured buffer data.
263  auto const& bufferBlocks = reflector.GetBufferBlocks();
264  int numBufferBlockReferences = 0;
265  for (auto const& block : bufferBlocks)
266  {
267  if (block.referencedBy[type])
268  {
269  ++numBufferBlockReferences;
270  }
271  }
272  if (numBufferBlockReferences > 0)
273  {
274  auto const& bufferVariables = reflector.GetBufferVariables();
275  mSBufferLayouts.resize(numBufferBlockReferences);
276 
277  // Store information needed by GL4Engine for enabling/disabling the
278  // structured buffers.
279  int blockIndex = 0;
280  int layoutIndex = 0;
281  for (auto const& block : bufferBlocks)
282  {
283  if (block.referencedBy[type])
284  {
285  // Search through uniforms looking for atomic counter with
286  // the same name and "Counter" suffix. The ID is the index
287  // for this uniform so that it can be looked up later.
288  auto const counterName = block.name + "Counter";
289  bool hasAtomicCounter = false;
290  unsigned int idAtomicCounter = ~0U;
291  for (auto const& uniform : uniforms)
292  {
293  if ((counterName == uniform.name) && (uniform.atomicCounterBufferIndex >= 0))
294  {
295  hasAtomicCounter = true;
296  idAtomicCounter = static_cast<unsigned int>(mData[AtomicCounterShaderDataLookup].size());
297  mData[AtomicCounterShaderDataLookup].push_back(
298  Data(GT_STRUCTURED_BUFFER, uniform.name, uniform.atomicCounterBufferIndex,
299  4, uniform.offset, false));
300  break;
301  }
302  }
303 
304  // Assemble the structured buffer layout information.
305  // Only interested in variables in the buffer that are part of
306  // a top level array stride. Anything up to this block is ignored
307  // and anything after this block is ignored which means only one
308  // top level array is supported.
309  auto& layout = mSBufferLayouts[layoutIndex];
310  GLint structSize = 0;
311  for (unsigned v = 0; v < block.activeVariables.size(); ++v)
312  {
313  auto const& bufferVar = bufferVariables[block.activeVariables[v]];
314 
315  if (bufferVar.topLevelArrayStride != structSize)
316  {
317  // Stop when we were processing buffer variables with a certain
318  // a top-level array stride and that changed.
319  if (0 != structSize)
320  {
321  break;
322  }
323  structSize = bufferVar.topLevelArrayStride;
324  }
325 
326  // These are the variables in the structured buffer.
327  if (structSize > 0)
328  {
329  MemberLayout item;
330  item.name = bufferVar.name;
331  item.offset = bufferVar.offset;
332  // TODO: The HLSL reflection has numElements of 0 when
333  // the item is not an array, but the actual number when
334  // it is an array. ConstantBuffer::SetMember(...) uses
335  // this information, so we need to adhere to the pattern.
336  // Change this design in a refactor?
337  item.numElements =
338  (bufferVar.arraySize > 1 ? bufferVar.arraySize : 0);
339 
340  layout.push_back(item);
341  }
342  }
343 
344  // Use the top level array stride as a better indication
345  // of the overall struct size.
347  Data(GT_STRUCTURED_BUFFER, block.name, block.bufferBinding,
348  structSize, idAtomicCounter, hasAtomicCounter));
349 
350  ++layoutIndex;
351  }
352 
353  ++blockIndex;
354  }
355  }
356 
357  // The conversion depends on the 'type' of the ordering: {vertex = 0,
358  // geometry = 1, pixel = 2, compute = 3}.
359  mType = static_cast<GraphicsObjectType>(GT_SHADER + 1 + type);
360 }
361 #else
363  :
364  mCompiledCode(program.GetCompiledCode()),
365  mNumXThreads(program.GetNumXThreads()),
366  mNumYThreads(program.GetNumYThreads()),
367  mNumZThreads(program.GetNumZThreads())
368 {
369  mCBufferLayouts.resize(program.GetCBuffers().size());
370  int i = 0;
371  for (auto const& cb : program.GetCBuffers())
372  {
374  Data(GT_CONSTANT_BUFFER, cb.GetName(), cb.GetBindPoint(),
375  cb.GetNumBytes(), 0, false));
376 
377  cb.GenerateLayout(mCBufferLayouts[i]);
378  ++i;
379  }
380 
381  mTBufferLayouts.resize(program.GetTBuffers().size());
382  i = 0;
383  for (auto const& tb : program.GetTBuffers())
384  {
386  Data(GT_TEXTURE_BUFFER, tb.GetName(), tb.GetBindPoint(),
387  tb.GetNumBytes(), 0, false));
388 
389  tb.GenerateLayout(mTBufferLayouts[i]);
390  ++i;
391  }
392 
393  for (auto const& sb : program.GetSBuffers())
394  {
395  unsigned int ctrtype = 0xFFFFFFFFu;
396  switch (sb.GetType())
397  {
399  ctrtype = StructuredBuffer::CT_NONE;
400  break;
401 
405  break;
406 
407  case HLSLStructuredBuffer::SBT_COUNTER:
408  ctrtype = StructuredBuffer::CT_COUNTER;
409  break;
410 
411  default:
412  LogError("Unexpected structured buffer option: " +
413  std::to_string(static_cast<int>(sb.GetType())));
414  }
415 
417  Data(GT_STRUCTURED_BUFFER, sb.GetName(), sb.GetBindPoint(),
418  sb.GetNumBytes(), ctrtype, sb.IsGpuWritable()));
419  }
420 
421  for (auto const& rb : program.GetRBuffers())
422  {
424  Data(GT_RAW_BUFFER, rb.GetName(), rb.GetBindPoint(),
425  rb.GetNumBytes(), 0, rb.IsGpuWritable()));
426  }
427 
428  for (auto const& tx : program.GetTextures())
429  {
431  Data(GT_TEXTURE_SINGLE, tx.GetName(), tx.GetBindPoint(), 0,
432  tx.GetNumDimensions(), tx.IsGpuWritable()));
433  }
434 
435  for (auto const& ta : program.GetTextureArrays())
436  {
438  Data(GT_TEXTURE_ARRAY, ta.GetName(), ta.GetBindPoint(), 0,
439  ta.GetNumDimensions(), ta.IsGpuWritable()));
440  }
441 
442  for (auto const& s : program.GetSamplerStates())
443  {
445  Data(GT_SAMPLER_STATE, s.GetName(), s.GetBindPoint(), 0, 0,
446  false));
447  }
448 
449  // The conversion depends on the HLSLShader::Type ordering to be the
450  // same as GraphicsObjectType for GL_SHADER through GL_COMPUTE_SHADER.
451  int index = program.GetShaderTypeIndex();
452  mType = static_cast<GraphicsObjectType>(GT_SHADER + 1 + index);
453 }
454 #endif
455 
456 int Shader::Get(std::string const& name) const
457 {
458  for (int lookup = 0; lookup < NUM_LOOKUP_INDICES; ++lookup)
459  {
460  int handle = 0;
461  for (auto const& data : mData[lookup])
462  {
463  if (name == data.name)
464  {
465  return handle;
466  }
467  ++handle;
468  }
469  }
470  return -1;
471 }
472 
473 unsigned int Shader::GetConstantBufferSize(int handle) const
474 {
476  if (0 <= handle && handle < static_cast<int>(data.size()))
477  {
478  return data[handle].numBytes;
479  }
480 
481  LogError("Invalid handle for object.");
482  return 0;
483 }
484 
486 {
487  int handle = 0;
489  {
490  if (name == data.name)
491  {
492  return data.numBytes;
493  }
494  ++handle;
495  }
496 
497  LogError("Cannot find object " + name + ".");
498  return 0;
499 }
500 
501 unsigned int Shader::GetTextureBufferSize(int handle) const
502 {
504  if (0 <= handle && handle < static_cast<int>(data.size()))
505  {
506  return data[handle].numBytes;
507  }
508 
509  LogError("Invalid handle for object.");
510  return 0;
511 }
512 
514 {
515  int handle = 0;
517  {
518  if (name == data.name)
519  {
520  return data.numBytes;
521  }
522  ++handle;
523  }
524 
525  LogError("Cannot find object " + name + ".");
526  return 0;
527 }
528 
529 unsigned int Shader::GetStructuredBufferSize(int handle) const
530 {
532  if (0 <= handle && handle < static_cast<int>(data.size()))
533  {
534  return data[handle].numBytes;
535  }
536 
537  LogError("Invalid handle for object.");
538  return 0;
539 }
540 
542 {
543  int handle = 0;
545  {
546  if (name == data.name)
547  {
548  return data.numBytes;
549  }
550  ++handle;
551  }
552 
553  LogError("Cannot find object " + name + ".");
554  return 0;
555 }
556 
557 bool Shader::GetConstantBufferLayout(int handle, BufferLayout& layout) const
558 {
560  if (0 <= handle && handle < static_cast<int>(data.size()))
561  {
562  layout = mCBufferLayouts[handle];
563  return true;
564  }
565 
566  LogError("Invalid handle for object.");
567  return false;
568 }
569 
571 {
572  int handle = 0;
574  {
575  if (name == data.name)
576  {
577  layout = mCBufferLayouts[handle];
578  return true;
579  }
580  ++handle;
581  }
582 
583  LogError("Cannot find object " + name + ".");
584  return false;
585 }
586 
587 bool Shader::GetTextureBufferLayout(int handle, BufferLayout& layout) const
588 {
590  if (0 <= handle && handle < static_cast<int>(data.size()))
591  {
592  layout = mTBufferLayouts[handle];
593  return true;
594  }
595 
596  LogError("Invalid handle for object.");
597  return false;
598 }
599 
601 {
602  int handle = 0;
604  {
605  if (name == data.name)
606  {
607  layout = mTBufferLayouts[handle];
608  return true;
609  }
610  ++handle;
611  }
612 
613  LogError("Cannot find object " + name + ".");
614  return false;
615 }
616 
617 #if defined(GTE_DEV_OPENGL)
618 bool Shader::GetStructuredBufferLayout(int handle, BufferLayout& layout) const
619 {
621  if (0 <= handle && handle < static_cast<int>(data.size()))
622  {
623  layout = mSBufferLayouts[handle];
624  return true;
625  }
626 
627  LogError("Invalid handle for object.");
628  return false;
629 }
630 
631 bool Shader::GetStructuredBufferLayout(std::string const& name, BufferLayout& layout) const
632 {
633  int handle = 0;
635  {
636  if (name == data.name)
637  {
638  layout = mSBufferLayouts[handle];
639  return true;
640  }
641  ++handle;
642  }
643 
644  LogError("Cannot find object " + name + ".");
645  return false;
646 }
647 #endif
648 
649 bool Shader::IsValid(Data const& goal, ConstantBuffer* resource) const
650 {
651  if (!resource)
652  {
653  LogError("Resource is null.");
654  return false;
655  }
656 
657  if (goal.type != GT_CONSTANT_BUFFER)
658  {
659  LogError("Mismatch of buffer type.");
660  return false;
661  }
662 
663  if (resource->GetNumBytes() >= static_cast<size_t>(goal.numBytes))
664  {
665  return true;
666  }
667 
668  LogError("Invalid number of bytes.");
669  return false;
670 }
671 
672 bool Shader::IsValid(Data const& goal, TextureBuffer* resource) const
673 {
674  if (!resource)
675  {
676  LogError("Resource is null.");
677  return false;
678  }
679 
680  if (goal.type != GT_TEXTURE_BUFFER)
681  {
682  LogError("Mismatch of buffer type.");
683  return false;
684  }
685 
686  if (resource->GetNumBytes() >= static_cast<size_t>(goal.numBytes))
687  {
688  return true;
689  }
690 
691  LogError("Invalid number of bytes.");
692  return false;
693 }
694 
695 bool Shader::IsValid(Data const& goal, StructuredBuffer* resource) const
696 {
697  if (!resource)
698  {
699  LogError("Resource is null.");
700  return false;
701  }
702 
703  if (goal.type != GT_STRUCTURED_BUFFER)
704  {
705  LogError("Mismatch of buffer type.");
706  return false;
707  }
708 
709 #if !defined(GTE_DEV_OPENGL)
710  // GL4 reflection does not provide information about writable access of
711  // buffer objects in a shader because by definition, shader storage buffer
712  // objects can be read-write by shaders. For GL4, the isGpuWritable flag is
713  // used to indicate whether the structured buffer has a counter attached or not.
714  if (goal.isGpuWritable && resource->GetUsage() != Resource::SHADER_OUTPUT)
715  {
716  LogError("Mismatch of GPU write flag.");
717  return false;
718  }
719 #endif
720 
721 #if defined(GTE_DEV_OPENGL)
722  // OpenGL does not have the concept of an append-consume type structured
723  // buffer nor does it have the concept of a structured buffer with counter.
724  // But, this GL4 support does associate an atomic counter with a structured
725  // buffer as long as it has the same name. If the shader is expecting
726  // a counter, then the structured buffer needs to be declared with one.
727  if (goal.isGpuWritable && (StructuredBuffer::CT_NONE == resource->GetCounterType()))
728  {
729  LogError("Mismatch of counter type.");
730  return false;
731  }
732 #else
733  // A countered structure buffer can be attached as a read-only input to
734  // a shader. We care about the mismatch in counter type only when the
735  // shader needs a countered structure buffer but the attached resource
736  // does not have one.
737  if (goal.extra != 0
738  && goal.extra != static_cast<unsigned int>(resource->GetCounterType()))
739  {
740  LogError("Mismatch of counter type.");
741  return false;
742  }
743 #endif
744 
745  return true;
746 }
747 
748 bool Shader::IsValid(Data const& goal, RawBuffer* resource) const
749 {
750  if (!resource)
751  {
752  LogError("Resource is null.");
753  return false;
754  }
755 
756  if (goal.type != GT_RAW_BUFFER)
757  {
758  LogError("Mismatch of buffer type.");
759  return false;
760  }
761 
762  if (goal.isGpuWritable && resource->GetUsage() != Resource::SHADER_OUTPUT)
763  {
764  LogError("Mismatch of GPU write flag.");
765  return false;
766  }
767 
768  return true;
769 }
770 
771 bool Shader::IsValid(Data const& goal, TextureSingle* resource) const
772 {
773  if (!resource)
774  {
775  LogError("Resource is null.");
776  return false;
777  }
778 
779  if (goal.type != GT_TEXTURE_SINGLE)
780  {
781  LogError("Mismatch of texture type.");
782  return false;
783  }
784 
785 #if !defined(GTE_DEV_OPENGL)
786  // GL4 reflection does not provide information about writable access
787  // of gimage* and gsampler* objects in a shader. For GL4, the isGpuWritable flag is
788  // used to indicate whether the texture could be writable in shader which
789  // is false for gshader* objects and is true for gimage* objects.
790  if (goal.isGpuWritable && resource->GetUsage() != Resource::SHADER_OUTPUT)
791  {
792  LogError("Mismatch of GPU write flag.");
793  return false;
794  }
795 #endif
796 
797  if (goal.extra != resource->GetNumDimensions())
798  {
799  LogError("Mismatch of texture dimensions.");
800  return false;
801  }
802 
803  // TODO: Add validation for HLSLTexture::Component and number of
804  // components (requires comparison to TextureFormat value).
805  return true;
806 }
807 
808 bool Shader::IsValid(Data const& goal, TextureArray* resource) const
809 {
810  if (!resource)
811  {
812  LogError("Resource is null.");
813  return false;
814  }
815 
816  if (goal.type != GT_TEXTURE_ARRAY)
817  {
818  LogError("Mismatch of texture type.");
819  return false;
820  }
821 
822 #if !defined(GTE_DEV_OPENGL)
823  // GL4 reflection does not provide information about writable access
824  // of gimage* and gsampler* objects in a shader. For GL4, the isGpuWritable flag is
825  // used to indicate whether the texture could be writable in shader which
826  // is false for gshader* objects and is true for gimage* objects.
827  if (goal.isGpuWritable && resource->GetUsage() != Resource::SHADER_OUTPUT)
828  {
829  LogError("Mismatch of GPU write flag.");
830  return false;
831  }
832 #endif
833 
834  if (goal.extra != resource->GetNumDimensions())
835  {
836  LogError("Mismatch of texture dimensions.");
837  return false;
838  }
839 
840  // TODO: Add validation for HLSLTexture::Component and number of
841  // components (requires comparison to TextureFormat value).
842  return true;
843 }
844 
845 bool Shader::IsValid(Data const& goal, SamplerState* resource) const
846 {
847  if (!resource)
848  {
849  LogError("Resource is null.");
850  return false;
851  }
852 
853  if (goal.type != GT_SAMPLER_STATE)
854  {
855  LogError("Mismatch of state.");
856  return false;
857  }
858 
859  return true;
860 }
861 
unsigned int offset
std::vector< HLSLStructuredBuffer > const & GetSBuffers() const
#define GL_INT_SAMPLER_1D_ARRAY
Definition: glcorearb.h:1087
#define GL_SAMPLER_3D
Definition: glcorearb.h:751
GT_SHADER
#define GL_INT_SAMPLER_2D_ARRAY
Definition: glcorearb.h:1088
static int const shaderDataLookup
int GLint
Definition: glcorearb.h:85
GT_TEXTURE2
CounterType GetCounterType() const
std::vector< BufferLayout > mTBufferLayouts
Definition: GteShader.h:206
#define GL_UNSIGNED_INT_SAMPLER_CUBE
Definition: glcorearb.h:1092
#define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY
Definition: glcorearb.h:2193
CT_APPEND_CONSUME
static int const shaderDataLookup
#define GL_INT_IMAGE_1D_ARRAY
Definition: glcorearb.h:2180
std::vector< BufferVariable > const & GetBufferVariables() const
#define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY
Definition: glcorearb.h:1718
std::vector< AtomicCounterBuffer > const & GetAtomicCounterBuffers() const
GT_TEXTURE_SINGLE
Usage GetUsage() const
Definition: GteResource.h:126
#define GL_UNSIGNED_INT_IMAGE_2D
Definition: glcorearb.h:2186
std::vector< MemberLayout > BufferLayout
GraphicsObjectType mType
std::vector< HLSLTextureArray > const & GetTextureArrays() const
#define GL_UNSIGNED_INT_SAMPLER_2D
Definition: glcorearb.h:1090
GLbitfield GLuint program
Definition: glcorearb.h:1926
GT_RESOURCE
#define GL_UNSIGNED_INT_SAMPLER_1D
Definition: glcorearb.h:1089
GT_SAMPLER_STATE
GraphicsObjectType type
Definition: GteShader.h:181
#define GL_UNSIGNED_INT_SAMPLER_3D
Definition: glcorearb.h:1091
std::vector< Data > mData[NUM_LOOKUP_INDICES]
Definition: GteShader.h:198
std::vector< DataBlock > const & GetBufferBlocks() const
#define GL_SAMPLER_CUBE_MAP_ARRAY
Definition: glcorearb.h:1715
GLuint const GLchar * name
Definition: glcorearb.h:781
#define GL_IMAGE_3D
Definition: glcorearb.h:2165
#define GL_UNSIGNED_INT_IMAGE_1D
Definition: glcorearb.h:2185
#define GL_INT_IMAGE_2D_ARRAY
Definition: glcorearb.h:2181
#define GL_INT_SAMPLER_CUBE
Definition: glcorearb.h:1086
static int const shaderDataLookup
#define GL_INT_SAMPLER_CUBE_MAP_ARRAY
Definition: glcorearb.h:1717
#define GL_IMAGE_CUBE
Definition: glcorearb.h:2167
static int const shaderDataLookup
#define GL_IMAGE_2D
Definition: glcorearb.h:2164
#define GL_IMAGE_CUBE_MAP_ARRAY
Definition: glcorearb.h:2171
unsigned int GetStructuredBufferSize(int handle) const
Definition: GteShader.cpp:529
unsigned int GetNumDimensions() const
Definition: GteTexture.h:105
int Get(std::string const &name) const
Definition: GteShader.cpp:456
unsigned int extra
Definition: GteShader.h:185
GT_TEXTURE_ARRAY
#define GL_INT_SAMPLER_1D
Definition: glcorearb.h:1083
#define GL_INT_IMAGE_2D
Definition: glcorearb.h:2175
static int const shaderDataLookup
Definition: GteRawBuffer.h:23
int GetShaderTypeIndex() const
std::vector< HLSLByteAddressBuffer > const & GetRBuffers() const
std::vector< HLSLSamplerState > const & GetSamplerStates() const
GLuint GLuint GLchar * counterName
Definition: glext.h:8697
#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY
Definition: glcorearb.h:1094
unsigned int GetTextureBufferSize(int handle) const
Definition: GteShader.cpp:501
#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 LogError(message)
Definition: GteLogger.h:92
bool GetConstantBufferLayout(int handle, BufferLayout &layout) const
Definition: GteShader.cpp:557
unsigned int numElements
GT_TEXTURE2_ARRAY
GT_TEXTURE_CUBE_ARRAY
GLboolean * data
Definition: glcorearb.h:126
#define GL_INT_IMAGE_CUBE
Definition: glcorearb.h:2178
std::vector< HLSLTexture > const & GetTextures() const
#define GL_INT_IMAGE_CUBE_MAP_ARRAY
Definition: glcorearb.h:2182
GT_TEXTURE_CUBE
static int const shaderDataLookup
unsigned int GetNumYThreads() const
Definition: GteShader.h:378
bool GetTextureBufferLayout(int handle, BufferLayout &layout) const
Definition: GteShader.cpp:587
unsigned int GetNumBytes() const
Definition: GteResource.h:116
unsigned int GetConstantBufferSize(int handle) const
Definition: GteShader.cpp:473
#define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY
Definition: glcorearb.h:1093
#define GL_SAMPLER_1D_ARRAY
Definition: glcorearb.h:1075
#define GL_IMAGE_1D_ARRAY
Definition: glcorearb.h:2169
GT_STRUCTURED_BUFFER
GT_TEXTURE1_ARRAY
unsigned int mNumXThreads
Definition: GteShader.h:200
#define GL_SAMPLER_1D
Definition: glcorearb.h:749
std::vector< HLSLConstantBuffer > const & GetCBuffers() const
bool IsValid(Data const &goal, ConstantBuffer *resource) const
Definition: GteShader.cpp:649
const GLdouble * v
Definition: glcorearb.h:832
GT_CONSTANT_BUFFER
unsigned int mNumYThreads
Definition: GteShader.h:201
GLdouble s
Definition: glext.h:231
#define GL_UNSIGNED_INT_IMAGE_3D
Definition: glcorearb.h:2187
GLuint index
Definition: glcorearb.h:781
std::vector< BufferLayout > mCBufferLayouts
Definition: GteShader.h:205
void GetComputeShaderWorkGroupSize(GLint &numXThreads, GLint &numYThreads, GLint &numZThreads) const
std::vector< unsigned char > mCompiledCode
Definition: GteShader.h:199
std::vector< HLSLTextureBuffer > const & GetTBuffers() const
unsigned int mNumZThreads
Definition: GteShader.h:202
Data(GraphicsObjectType inType, std::string const &inName, int inBindPoint, int inNumBytes, unsigned int inExtra, bool inIsGpuWritable)
Definition: GteShader.cpp:13
#define GL_SAMPLER_CUBE
Definition: glcorearb.h:752
GT_TEXTURE_BUFFER
#define GL_INT_IMAGE_3D
Definition: glcorearb.h:2176
#define GL_IMAGE_2D_ARRAY
Definition: glcorearb.h:2170
GT_TEXTURE3
static int const shaderDataLookup
#define GL_UNSIGNED_INT_IMAGE_1D_ARRAY
Definition: glcorearb.h:2191
Shader(HLSLShader const &program)
Definition: GteShader.cpp:362
#define GL_SAMPLER_2D
Definition: glcorearb.h:750
#define GL_SAMPLER_2D_ARRAY
Definition: glcorearb.h:1076
unsigned int GetNumZThreads() const
Definition: GteShader.h:383
#define GL_INT_SAMPLER_2D
Definition: glcorearb.h:1084
GT_TEXTURE1
unsigned int GetNumXThreads() const
Definition: GteShader.h:373
#define GL_INT_IMAGE_1D
Definition: glcorearb.h:2174
std::vector< DataBlock > const & GetUniformBlocks() const
std::vector< unsigned char > const & GetCompiledCode() const
Definition: GteShader.h:388
#define GL_UNSIGNED_INT_IMAGE_2D_ARRAY
Definition: glcorearb.h:2192
GLint GLint GLsizei GLint GLenum GLenum type
Definition: glcorearb.h:103
#define GL_INT_SAMPLER_3D
Definition: glcorearb.h:1085
std::vector< Uniform > const & GetUniforms() const
GT_RAW_BUFFER


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