hlslAttributes.cpp 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. //
  2. // Copyright (C) 2016 LunarG, Inc.
  3. //
  4. // All rights reserved.
  5. //
  6. // Redistribution and use in source and binary forms, with or without
  7. // modification, are permitted provided that the following conditions
  8. // are met:
  9. //
  10. // Redistributions of source code must retain the above copyright
  11. // notice, this list of conditions and the following disclaimer.
  12. //
  13. // Redistributions in binary form must reproduce the above
  14. // copyright notice, this list of conditions and the following
  15. // disclaimer in the documentation and/or other materials provided
  16. // with the distribution.
  17. //
  18. // Neither the name of Google, Inc., nor the names of its
  19. // contributors may be used to endorse or promote products derived
  20. // from this software without specific prior written permission.
  21. //
  22. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  23. // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  24. // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  25. // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  26. // COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  27. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  28. // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  29. // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  30. // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  31. // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
  32. // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  33. // POSSIBILITY OF SUCH DAMAGE.
  34. //
  35. #include "hlslAttributes.h"
  36. #include "hlslParseHelper.h"
  37. namespace glslang {
  38. // Map the given string to an attribute enum from TAttributeType,
  39. // or EatNone if invalid.
  40. TAttributeType HlslParseContext::attributeFromName(const TString& nameSpace, const TString& name) const
  41. {
  42. // handle names within a namespace
  43. if (nameSpace == "vk") {
  44. if (name == "input_attachment_index")
  45. return EatInputAttachment;
  46. else if (name == "location")
  47. return EatLocation;
  48. else if (name == "binding")
  49. return EatBinding;
  50. else if (name == "global_cbuffer_binding")
  51. return EatGlobalBinding;
  52. else if (name == "builtin")
  53. return EatBuiltIn;
  54. else if (name == "constant_id")
  55. return EatConstantId;
  56. else if (name == "push_constant")
  57. return EatPushConstant;
  58. } else if (nameSpace.size() > 0)
  59. return EatNone;
  60. // handle names with no namespace
  61. if (name == "allow_uav_condition")
  62. return EatAllow_uav_condition;
  63. else if (name == "branch")
  64. return EatBranch;
  65. else if (name == "call")
  66. return EatCall;
  67. else if (name == "domain")
  68. return EatDomain;
  69. else if (name == "earlydepthstencil")
  70. return EatEarlyDepthStencil;
  71. else if (name == "fastopt")
  72. return EatFastOpt;
  73. else if (name == "flatten")
  74. return EatFlatten;
  75. else if (name == "forcecase")
  76. return EatForceCase;
  77. else if (name == "instance")
  78. return EatInstance;
  79. else if (name == "maxtessfactor")
  80. return EatMaxTessFactor;
  81. else if (name == "maxvertexcount")
  82. return EatMaxVertexCount;
  83. else if (name == "numthreads")
  84. return EatNumThreads;
  85. else if (name == "outputcontrolpoints")
  86. return EatOutputControlPoints;
  87. else if (name == "outputtopology")
  88. return EatOutputTopology;
  89. else if (name == "partitioning")
  90. return EatPartitioning;
  91. else if (name == "patchconstantfunc")
  92. return EatPatchConstantFunc;
  93. else if (name == "unroll")
  94. return EatUnroll;
  95. else if (name == "loop")
  96. return EatLoop;
  97. else
  98. return EatNone;
  99. }
  100. } // end namespace glslang