Initialize.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. //
  2. // Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
  3. // Copyright (C) 2013-2016 LunarG, Inc.
  4. //
  5. // All rights reserved.
  6. //
  7. // Redistribution and use in source and binary forms, with or without
  8. // modification, are permitted provided that the following conditions
  9. // are met:
  10. //
  11. // Redistributions of source code must retain the above copyright
  12. // notice, this list of conditions and the following disclaimer.
  13. //
  14. // Redistributions in binary form must reproduce the above
  15. // copyright notice, this list of conditions and the following
  16. // disclaimer in the documentation and/or other materials provided
  17. // with the distribution.
  18. //
  19. // Neither the name of 3Dlabs Inc. Ltd. nor the names of its
  20. // contributors may be used to endorse or promote products derived
  21. // from this software without specific prior written permission.
  22. //
  23. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  24. // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  25. // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  26. // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  27. // COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  28. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  29. // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  30. // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  31. // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  32. // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
  33. // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  34. // POSSIBILITY OF SUCH DAMAGE.
  35. //
  36. #ifndef _INITIALIZE_INCLUDED_
  37. #define _INITIALIZE_INCLUDED_
  38. #include "../Include/ResourceLimits.h"
  39. #include "../Include/Common.h"
  40. #include "../Include/ShHandle.h"
  41. #include "SymbolTable.h"
  42. #include "Versions.h"
  43. namespace glslang {
  44. //
  45. // This is made to hold parseable strings for almost all the built-in
  46. // functions and variables for one specific combination of version
  47. // and profile. (Some still need to be added programmatically.)
  48. // This is a base class for language-specific derivations, which
  49. // can be used for language independent builtins.
  50. //
  51. // The strings are organized by
  52. // commonBuiltins: intersection of all stages' built-ins, processed just once
  53. // stageBuiltins[]: anything a stage needs that's not in commonBuiltins
  54. //
  55. class TBuiltInParseables {
  56. public:
  57. POOL_ALLOCATOR_NEW_DELETE(GetThreadPoolAllocator())
  58. TBuiltInParseables();
  59. virtual ~TBuiltInParseables();
  60. virtual void initialize(int version, EProfile, const SpvVersion& spvVersion) = 0;
  61. virtual void initialize(const TBuiltInResource& resources, int version, EProfile, const SpvVersion& spvVersion, EShLanguage) = 0;
  62. virtual const TString& getCommonString() const { return commonBuiltins; }
  63. virtual const TString& getStageString(EShLanguage language) const { return stageBuiltins[language]; }
  64. virtual void identifyBuiltIns(int version, EProfile profile, const SpvVersion& spvVersion, EShLanguage language, TSymbolTable& symbolTable) = 0;
  65. virtual void identifyBuiltIns(int version, EProfile profile, const SpvVersion& spvVersion, EShLanguage language, TSymbolTable& symbolTable, const TBuiltInResource &resources) = 0;
  66. protected:
  67. TString commonBuiltins;
  68. TString stageBuiltins[EShLangCount];
  69. };
  70. //
  71. // This is a GLSL specific derivation of TBuiltInParseables. To present a stable
  72. // interface and match other similar code, it is called TBuiltIns, rather
  73. // than TBuiltInParseablesGlsl.
  74. //
  75. class TBuiltIns : public TBuiltInParseables {
  76. public:
  77. POOL_ALLOCATOR_NEW_DELETE(GetThreadPoolAllocator())
  78. TBuiltIns();
  79. virtual ~TBuiltIns();
  80. void initialize(int version, EProfile, const SpvVersion& spvVersion);
  81. void initialize(const TBuiltInResource& resources, int version, EProfile, const SpvVersion& spvVersion, EShLanguage);
  82. void identifyBuiltIns(int version, EProfile profile, const SpvVersion& spvVersion, EShLanguage language, TSymbolTable& symbolTable);
  83. void identifyBuiltIns(int version, EProfile profile, const SpvVersion& spvVersion, EShLanguage language, TSymbolTable& symbolTable, const TBuiltInResource &resources);
  84. protected:
  85. void addTabledBuiltins(int version, EProfile profile, const SpvVersion& spvVersion);
  86. void relateTabledBuiltins(int version, EProfile profile, const SpvVersion& spvVersion, EShLanguage, TSymbolTable&);
  87. void add2ndGenerationSamplingImaging(int version, EProfile profile, const SpvVersion& spvVersion);
  88. void addSubpassSampling(TSampler, const TString& typeName, int version, EProfile profile);
  89. void addQueryFunctions(TSampler, const TString& typeName, int version, EProfile profile);
  90. void addImageFunctions(TSampler, const TString& typeName, int version, EProfile profile);
  91. void addSamplingFunctions(TSampler, const TString& typeName, int version, EProfile profile);
  92. void addGatherFunctions(TSampler, const TString& typeName, int version, EProfile profile);
  93. // Helpers for making textual representations of the permutations
  94. // of texturing/imaging functions.
  95. const char* postfixes[5];
  96. const char* prefixes[EbtNumTypes];
  97. int dimMap[EsdNumDims];
  98. };
  99. } // end namespace glslang
  100. #endif // _INITIALIZE_INCLUDED_