DxilPackSignatureElement.h 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. // Class to pack 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 "dxc/HLSL/DxilSignatureAllocator.h"
  17. #include <string>
  18. #include <vector>
  19. #include <limits.h>
  20. namespace hlsl {
  21. class ShaderModel;
  22. class DxilPackElement : public DxilSignatureAllocator::PackElement {
  23. DxilSignatureElement *m_pSE;
  24. bool m_bUseMinPrecision;
  25. public:
  26. DxilPackElement(DxilSignatureElement *pSE, bool useMinPrecision) : m_pSE(pSE), m_bUseMinPrecision(useMinPrecision) {}
  27. ~DxilPackElement() override {}
  28. uint32_t GetID() const override { return m_pSE->GetID(); }
  29. DXIL::SemanticKind GetKind() const override { return m_pSE->GetKind(); }
  30. DXIL::InterpolationMode GetInterpolationMode() const override { return m_pSE->GetInterpolationMode()->GetKind(); }
  31. DXIL::SemanticInterpretationKind GetInterpretation() const override { return m_pSE->GetInterpretation(); }
  32. DXIL::SignatureDataWidth GetDataBitWidth() const override {
  33. uint8_t size = m_pSE->GetCompType().GetSizeInBits();
  34. // bool, min precision, or 32 bit types map to 32 bit size.
  35. if (size == 16) {
  36. return m_bUseMinPrecision ? DXIL::SignatureDataWidth::Bits32 : DXIL::SignatureDataWidth::Bits16;
  37. }
  38. else if (size == 1 || size == 32) {
  39. return DXIL::SignatureDataWidth::Bits32;
  40. }
  41. return DXIL::SignatureDataWidth::Undefined;
  42. }
  43. uint32_t GetRows() const override { return m_pSE->GetRows(); }
  44. uint32_t GetCols() const override { return m_pSE->GetCols(); }
  45. bool IsAllocated() const override { return m_pSE->IsAllocated(); }
  46. uint32_t GetStartRow() const override { return m_pSE->GetStartRow(); }
  47. uint32_t GetStartCol() const override { return m_pSE->GetStartCol(); }
  48. void ClearLocation() override {
  49. m_pSE->SetStartRow(-1);
  50. m_pSE->SetStartCol(-1);
  51. }
  52. void SetLocation(uint32_t Row, uint32_t Col) override {
  53. m_pSE->SetStartRow(Row);
  54. m_pSE->SetStartCol(Col);
  55. }
  56. DxilSignatureElement *Get() { return m_pSE; }
  57. };
  58. class DxilSignature;
  59. // Packs the signature elements per DXIL constraints and returns the number of rows used for the signature.
  60. unsigned PackDxilSignature(DxilSignature &sig, DXIL::PackingStrategy packing);
  61. } // namespace hlsl