DxilSigPoint.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. ///////////////////////////////////////////////////////////////////////////////
  2. // //
  3. // DxilSigPoint.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 points. //
  9. // //
  10. ///////////////////////////////////////////////////////////////////////////////
  11. #pragma once
  12. #include "DxilConstants.h"
  13. namespace hlsl {
  14. struct VersionedSemanticInterpretation {
  15. VersionedSemanticInterpretation(DXIL::SemanticInterpretationKind k, unsigned MajorVersion=0, unsigned MinorVersion=0) :
  16. Kind(k), Major((unsigned short)MajorVersion), Minor((unsigned short)MinorVersion)
  17. {}
  18. DXIL::SemanticInterpretationKind Kind;
  19. unsigned short Major, Minor;
  20. };
  21. /// Use this class to describe an HLSL signature point.
  22. /// A signature point is a set of signature parameters at a particular shader stage,
  23. /// grouped by input/output/patch constant and value frequency.
  24. class SigPoint {
  25. public:
  26. using Kind = DXIL::SigPointKind;
  27. SigPoint(DXIL::SigPointKind spk, const char *name, DXIL::SigPointKind rspk, DXIL::ShaderKind shk, DXIL::SignatureKind sigk, DXIL::PackingKind pk);
  28. bool IsInput() const { return m_SignatureKind == DXIL::SignatureKind::Input; }
  29. bool IsOutput() const { return m_SignatureKind == DXIL::SignatureKind::Output; }
  30. bool IsPatchConstOrPrim() const { return m_SignatureKind == DXIL::SignatureKind::PatchConstOrPrim; }
  31. Kind GetKind() const { return m_Kind; }
  32. const char *GetName() const { return m_pszName; }
  33. DXIL::ShaderKind GetShaderKind() const { return m_ShaderKind; }
  34. Kind GetRelatedKind() const { return m_RelatedKind; }
  35. DXIL::SignatureKind GetSignatureKind() const { return m_SignatureKind; }
  36. DXIL::SignatureKind GetSignatureKindWithFallback() const;
  37. DXIL::PackingKind GetPackingKind() const { return m_PackingKind; }
  38. bool NeedsInterpMode() const { return m_PackingKind == DXIL::PackingKind::Vertex; }
  39. static const SigPoint* GetSigPoint(Kind K);
  40. // isSpecialInput selects a signature point outside the normal input/output/patch constant signatures.
  41. // These are used for a few system values that should not be included as part of the regular input
  42. // structure because they do not have the same dimensionality as other inputs, such as
  43. // SV_PrimitiveID for Geometry, Hull, and Patch Constant Functions.
  44. static DXIL::SigPointKind GetKind(DXIL::ShaderKind shaderKind, DXIL::SignatureKind sigKind, bool isPatchConstantFunction, bool isSpecialInput);
  45. // Interpretations are how system values are intrepeted at a particular signature point.
  46. static DXIL::SemanticInterpretationKind GetInterpretation(DXIL::SemanticKind SK, Kind K, unsigned MajorVersion, unsigned MinorVersion);
  47. // For Shadow elements, recover original SigPointKind
  48. static Kind RecoverKind(DXIL::SemanticKind SK, Kind K);
  49. private:
  50. static const unsigned kNumSigPointRecords = (unsigned)Kind::Invalid + 1;
  51. static const SigPoint ms_SigPoints[kNumSigPointRecords];
  52. static const VersionedSemanticInterpretation ms_SemanticInterpretationTable[(unsigned)DXIL::SemanticKind::Invalid][(unsigned)Kind::Invalid];
  53. Kind m_Kind;
  54. Kind m_RelatedKind;
  55. DXIL::ShaderKind m_ShaderKind;
  56. DXIL::SignatureKind m_SignatureKind;
  57. const char *m_pszName;
  58. DXIL::PackingKind m_PackingKind;
  59. };
  60. } // namespace hlsl