DxilSemantic.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. ///////////////////////////////////////////////////////////////////////////////
  2. // //
  3. // DxilSemantic.h //
  4. // Copyright (C) Microsoft Corporation. All rights reserved. //
  5. // This file is distributed under the University of Illinois Open Source //
  6. // License. See LICENSE.TXT for details. //
  7. // //
  8. // Representation of HLSL parameter semantics. //
  9. // //
  10. ///////////////////////////////////////////////////////////////////////////////
  11. #pragma once
  12. #include "llvm/ADT/StringRef.h"
  13. #include "DxilConstants.h"
  14. #include "DxilShaderModel.h"
  15. namespace hlsl {
  16. /// Use this class to represent HLSL parameter semantic.
  17. class Semantic {
  18. public:
  19. using Kind = DXIL::SemanticKind;
  20. static const int kUndefinedRow = -1;
  21. static const int kUndefinedCol = -1;
  22. static const Semantic *GetByName(llvm::StringRef name);
  23. static const Semantic *GetByName(llvm::StringRef Name, DXIL::SigPointKind sigPointKind,
  24. unsigned MajorVersion = ShaderModel::kHighestMajor, unsigned MinorVersion = ShaderModel::kHighestMinor);
  25. static const Semantic *Get(Kind kind);
  26. static const Semantic *Get(Kind kind, DXIL::SigPointKind sigPointKind,
  27. unsigned MajorVersion = ShaderModel::kHighestMajor, unsigned MinorVersion = ShaderModel::kHighestMinor);
  28. static const Semantic *GetInvalid();
  29. static const Semantic *GetArbitrary();
  30. static bool HasSVPrefix(llvm::StringRef Name);
  31. static void DecomposeNameAndIndex(llvm::StringRef FullName, llvm::StringRef *pName, unsigned *pIndex);
  32. Kind GetKind() const;
  33. const char *GetName() const;
  34. bool IsArbitrary() const;
  35. bool IsInvalid() const;
  36. private:
  37. Kind m_Kind; // Semantic kind.
  38. const char *m_pszName; // Canonical name (for system semantics).
  39. Semantic() = delete;
  40. Semantic(Kind Kind, const char *pszName);
  41. // Table of all semantic properties.
  42. static const unsigned kNumSemanticRecords = (unsigned)Kind::Invalid + 1;
  43. static const Semantic ms_SemanticTable[kNumSemanticRecords];
  44. friend class ShaderModel;
  45. friend class SignatureElement;
  46. };
  47. } // namespace hlsl