| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151 |
- ///////////////////////////////////////////////////////////////////////////////
- // //
- // DxilSignatureElement.h //
- // Copyright (C) Microsoft Corporation. All rights reserved. //
- // This file is distributed under the University of Illinois Open Source //
- // License. See LICENSE.TXT for details. //
- // //
- // Representation of HLSL signature element. //
- // //
- ///////////////////////////////////////////////////////////////////////////////
- #pragma once
- #include "llvm/ADT/StringRef.h"
- #include "dxc/HLSL/DxilSemantic.h"
- #include "dxc/HLSL/DxilInterpolationMode.h"
- #include "dxc/HLSL/DxilCompType.h"
- #include "dxc/HLSL/DxilSignatureAllocator.h"
- #include <string>
- #include <vector>
- namespace hlsl {
- class ShaderModel;
- /// Use this class to represent HLSL signature elements.
- class DxilSignatureElement {
- friend class DxilSignature;
- public:
- using Kind = DXIL::SigPointKind;
- static const unsigned kUndefinedID = UINT_MAX;
- DxilSignatureElement(Kind K);
- virtual ~DxilSignatureElement();
- void Initialize(llvm::StringRef Name, const CompType &ElementType, const InterpolationMode &InterpMode,
- unsigned Rows, unsigned Cols,
- int StartRow = Semantic::kUndefinedRow, int StartCol = Semantic::kUndefinedCol,
- unsigned ID = kUndefinedID, const std::vector<unsigned> &IndexVector = std::vector<unsigned>());
- unsigned GetID() const;
- void SetID(unsigned ID);
- DXIL::ShaderKind GetShaderKind() const;
- DXIL::SigPointKind GetSigPointKind() const;
- void SetSigPointKind(DXIL::SigPointKind K);
- bool IsInput() const;
- bool IsOutput() const;
- bool IsPatchConstant() const;
- const char *GetName() const;
- unsigned GetRows() const;
- void SetRows(unsigned Rows);
- unsigned GetCols() const;
- void SetCols(unsigned Cols);
- const InterpolationMode *GetInterpolationMode() const;
- CompType GetCompType() const;
- unsigned GetOutputStream() const;
- void SetOutputStream(unsigned Stream);
- // Semantic properties.
- const Semantic *GetSemantic() const;
- void SetKind(Semantic::Kind kind);
- Semantic::Kind GetKind() const;
- bool IsArbitrary() const;
- bool IsDepth() const;
- bool IsDepthLE() const;
- bool IsDepthGE() const;
- bool IsAnyDepth() const;
- DXIL::SemanticInterpretationKind GetInterpretation() const;
- llvm::StringRef GetSemanticName() const;
- unsigned GetSemanticStartIndex() const;
- // Low-level properties.
- int GetStartRow() const;
- void SetStartRow(int StartRow);
- int GetStartCol() const;
- void SetStartCol(int Component);
- const std::vector<unsigned> &GetSemanticIndexVec() const;
- void SetSemanticIndexVec(const std::vector<unsigned> &Vec);
- void AppendSemanticIndex(unsigned SemIdx);
- void SetCompType(CompType CT);
- uint8_t GetColsAsMask() const;
- bool IsAllocated() const;
- unsigned GetDynIdxCompMask() const;
- void SetDynIdxCompMask(unsigned DynIdxCompMask);
- protected:
- DXIL::SigPointKind m_sigPointKind;
- const Semantic *m_pSemantic;
- unsigned m_ID;
- std::string m_Name;
- llvm::StringRef m_SemanticName;
- unsigned m_SemanticStartIndex;
- CompType m_CompType;
- InterpolationMode m_InterpMode;
- std::vector<unsigned> m_SemanticIndex;
- unsigned m_Rows;
- unsigned m_Cols;
- int m_StartRow;
- int m_StartCol;
- unsigned m_OutputStream;
- unsigned m_DynIdxCompMask;
- };
- class DxilPackElement : public DxilSignatureAllocator::PackElement {
- DxilSignatureElement *m_pSE;
- bool m_bUseMinPrecision;
- public:
- DxilPackElement(DxilSignatureElement *pSE, bool useMinPrecision) : m_pSE(pSE), m_bUseMinPrecision(useMinPrecision) {}
- __override ~DxilPackElement() {}
- __override uint32_t GetID() const { return m_pSE->GetID(); }
- __override DXIL::SemanticKind GetKind() const { return m_pSE->GetKind(); }
- __override DXIL::InterpolationMode GetInterpolationMode() const { return m_pSE->GetInterpolationMode()->GetKind(); }
- __override DXIL::SemanticInterpretationKind GetInterpretation() const { return m_pSE->GetInterpretation(); }
- __override DXIL::SignatureDataWidth GetDataBitWidth() const {
- uint8_t size = m_pSE->GetCompType().GetSizeInBits();
- // bool, min precision, or 32 bit types map to 32 bit size.
- if (size == 16) {
- return m_bUseMinPrecision ? DXIL::SignatureDataWidth::Bits32 : DXIL::SignatureDataWidth::Bits16;
- }
- else if (size == 1 || size == 32) {
- return DXIL::SignatureDataWidth::Bits32;
- }
- return DXIL::SignatureDataWidth::Undefined;
- }
- __override uint32_t GetRows() const { return m_pSE->GetRows(); }
- __override uint32_t GetCols() const { return m_pSE->GetCols(); }
- __override bool IsAllocated() const { return m_pSE->IsAllocated(); }
- __override uint32_t GetStartRow() const { return m_pSE->GetStartRow(); }
- __override uint32_t GetStartCol() const { return m_pSE->GetStartCol(); }
- __override void ClearLocation() {
- m_pSE->SetStartRow(-1);
- m_pSE->SetStartCol(-1);
- }
- __override void SetLocation(uint32_t Row, uint32_t Col) {
- m_pSE->SetStartRow(Row);
- m_pSE->SetStartCol(Col);
- }
- DxilSignatureElement *Get() { return m_pSE; }
- };
- } // namespace hlsl
|