DxilSignatureElement.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. ///////////////////////////////////////////////////////////////////////////////
  2. // //
  3. // DxilSignatureElement.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 signature element. //
  9. // //
  10. ///////////////////////////////////////////////////////////////////////////////
  11. #pragma once
  12. #include "llvm/ADT/StringRef.h"
  13. #include "dxc/DXIL/DxilSemantic.h"
  14. #include "dxc/DXIL/DxilInterpolationMode.h"
  15. #include "dxc/DXIL/DxilCompType.h"
  16. #include <string>
  17. #include <vector>
  18. #include <limits.h>
  19. namespace hlsl {
  20. class ShaderModel;
  21. /// Use this class to represent HLSL signature elements.
  22. class DxilSignatureElement {
  23. friend class DxilSignature;
  24. public:
  25. using Kind = DXIL::SigPointKind;
  26. static const unsigned kUndefinedID = UINT_MAX;
  27. DxilSignatureElement(Kind K);
  28. virtual ~DxilSignatureElement();
  29. void Initialize(llvm::StringRef Name, const CompType &ElementType, const InterpolationMode &InterpMode,
  30. unsigned Rows, unsigned Cols,
  31. int StartRow = Semantic::kUndefinedRow, int StartCol = Semantic::kUndefinedCol,
  32. unsigned ID = kUndefinedID, const std::vector<unsigned> &IndexVector = std::vector<unsigned>());
  33. unsigned GetID() const;
  34. void SetID(unsigned ID);
  35. DXIL::ShaderKind GetShaderKind() const;
  36. DXIL::SigPointKind GetSigPointKind() const;
  37. void SetSigPointKind(DXIL::SigPointKind K);
  38. bool IsInput() const;
  39. bool IsOutput() const;
  40. bool IsPatchConstOrPrim() const;
  41. const char *GetName() const;
  42. unsigned GetRows() const;
  43. void SetRows(unsigned Rows);
  44. unsigned GetCols() const;
  45. void SetCols(unsigned Cols);
  46. const InterpolationMode *GetInterpolationMode() const;
  47. CompType GetCompType() const;
  48. unsigned GetOutputStream() const;
  49. void SetOutputStream(unsigned Stream);
  50. // Semantic properties.
  51. const Semantic *GetSemantic() const;
  52. void SetKind(Semantic::Kind kind);
  53. Semantic::Kind GetKind() const;
  54. bool IsArbitrary() const;
  55. bool IsDepth() const;
  56. bool IsDepthLE() const;
  57. bool IsDepthGE() const;
  58. bool IsAnyDepth() const;
  59. DXIL::SemanticInterpretationKind GetInterpretation() const;
  60. llvm::StringRef GetSemanticName() const;
  61. unsigned GetSemanticStartIndex() const;
  62. // Low-level properties.
  63. int GetStartRow() const;
  64. void SetStartRow(int StartRow);
  65. int GetStartCol() const;
  66. void SetStartCol(int Component);
  67. const std::vector<unsigned> &GetSemanticIndexVec() const;
  68. void SetSemanticIndexVec(const std::vector<unsigned> &Vec);
  69. void AppendSemanticIndex(unsigned SemIdx);
  70. void SetCompType(CompType CT);
  71. uint8_t GetColsAsMask() const;
  72. bool IsAllocated() const;
  73. unsigned GetDynIdxCompMask() const;
  74. void SetDynIdxCompMask(unsigned DynIdxCompMask);
  75. uint8_t GetUsageMask() const;
  76. void SetUsageMask(unsigned UsageMask);
  77. protected:
  78. DXIL::SigPointKind m_sigPointKind;
  79. const Semantic *m_pSemantic;
  80. unsigned m_ID;
  81. std::string m_Name;
  82. llvm::StringRef m_SemanticName;
  83. unsigned m_SemanticStartIndex;
  84. CompType m_CompType;
  85. InterpolationMode m_InterpMode;
  86. std::vector<unsigned> m_SemanticIndex;
  87. unsigned m_Rows;
  88. unsigned m_Cols;
  89. int m_StartRow;
  90. int m_StartCol;
  91. unsigned m_OutputStream;
  92. unsigned m_DynIdxCompMask;
  93. // UsageMask is meant to match the signature usage mask, used for validation:
  94. // for output: may-write, for input: always-reads
  95. unsigned m_UsageMask;
  96. };
  97. } // namespace hlsl