LLVM 24.0.0git
SemanticSignaturePacking.h
Go to the documentation of this file.
1//===- SemanticSignaturePacking.h - HLSL signature packing helpers -------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8///
9/// \file This file declares helpers for packing HLSL semantic signatures.
10///
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_FRONTEND_HLSL_SEMANTICSIGNATUREPACKING_H
14#define LLVM_FRONTEND_HLSL_SEMANTICSIGNATUREPACKING_H
15
16#include "llvm/ADT/ArrayRef.h"
19#include "llvm/Support/Error.h"
21
22namespace llvm::hlsl {
23
24static constexpr unsigned MaxSignatureRows = 32;
25static constexpr unsigned MaxSignatureCols = 4;
26static constexpr unsigned MaxClipCullRows = 2;
27static constexpr unsigned MaxGeometryStreams = 4;
28
29/// Denotes the element that could not be packed and why.
30class LLVM_ABI SignaturePackingError : public ErrorInfo<SignaturePackingError> {
31public:
39
40 static char ID;
41
42 SignaturePackingError(ErrorKind Kind, unsigned ElementIndex)
43 : Kind(Kind), ElementIndex(ElementIndex) {}
44
45 ErrorKind getErrorKind() const { return Kind; }
46 unsigned getElementIndex() const { return ElementIndex; }
47
48 void log(raw_ostream &OS) const override;
49
50 std::error_code convertToErrorCode() const override {
52 }
53
54private:
55 ErrorKind Kind;
56 unsigned ElementIndex;
57};
58
59/// Packs eligible signature elements into consecutive rows.
60///
61/// See llvm/docs/DirectX/SemanticSignatures.md#stacked-packing for details.
62///
63/// On failure, Elements is left partially packed: the elements preceding the
64/// one reported by the returned SignaturePackingError keep the locations
65/// they were assigned, while that element and the ones following it retain the
66/// unallocated row and column sentinels.
69 Triple::EnvironmentType ShaderStage, IOType IOTy);
70
71/// Packs eligible signature elements without moving previously placed
72/// elements. Only StartRow and StartCol are modified.
73///
74/// See llvm/docs/DirectX/SemanticSignatures.md#prefix-stable-packing for
75/// details.
76///
77/// Returns one past the highest allocated row, or zero if no elements were
78/// allocated. For geometry outputs this is the maximum extent of any stream,
79/// not the sum of their extents.
80///
81/// On failure, Elements is left partially packed: the elements preceding the
82/// one reported by the returned SignaturePackingError keep the locations
83/// they were assigned, while that element and the ones following it retain the
84/// unallocated row and column sentinels.
87 Triple::EnvironmentType ShaderStage, IOType IOTy,
88 bool UseNative16BitTypes);
89
90/// Packs eligible signature elements at rows selected by semantic index.
91///
92/// See llvm/docs/DirectX/SemanticSignatures.md#indexed-packing for details.
93///
94/// Requires each eligible element to occupy exactly one row and have exactly
95/// one semantic index. Semantic indices must be unique among eligible elements.
96///
97/// Returns one past the highest allocated row, or zero if no elements were
98/// allocated. Gaps between semantic indices count towards this row extent.
99///
100/// On failure, Elements is left partially packed: the elements preceding the
101/// one reported by the returned SignaturePackingError keep the locations
102/// they were assigned, while that element and the ones following it retain the
103/// unallocated row and column sentinels.
106 Triple::EnvironmentType ShaderStage, IOType IOTy);
107
108/// Packs eligible signature elements in an optimized order by reordering
109/// elements into an optimal packing order and allowing clip/cull to share
110/// compatible rows. Only StartRow and StartCol are modified.
111///
112/// See llvm/docs/DirectX/SemanticSignatures.md#optimized-packing for details.
113///
114/// Returns the number of allocated rows, or zero if no elements were
115/// allocated. For geometry outputs this is the maximum extent of any stream,
116/// not the sum of their extents.
117///
118/// On failure, Elements are left partially packed: the elements preceding the
119/// one reported by the returned SignaturePackingError keep the locations
120/// they were assigned, while that element and the ones following it retain the
121/// unallocated row and column sentinels.
124 Triple::EnvironmentType ShaderStage, IOType IOTy,
125 bool UseNative16BitTypes);
126
127} // namespace llvm::hlsl
128
129#endif // LLVM_FRONTEND_HLSL_SEMANTICSIGNATUREPACKING_H
#define LLVM_ABI
Definition Compiler.h:215
Base class for user error types.
Definition Error.h:354
Tagged union holding either a T or a Error.
Definition Error.h:485
Represent a mutable reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:294
SignaturePackingError(ErrorKind Kind, unsigned ElementIndex)
std::error_code convertToErrorCode() const override
Convert this error to a std::error_code.
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition raw_ostream.h:53
static constexpr unsigned MaxGeometryStreams
LLVM_ABI Expected< unsigned > packSignatureStacked(MutableArrayRef< SemanticSignatureElement > Elements, Triple::EnvironmentType ShaderStage, IOType IOTy)
Packs eligible signature elements into consecutive rows.
LLVM_ABI Expected< unsigned > packSignaturePrefixStable(MutableArrayRef< SemanticSignatureElement > Elements, Triple::EnvironmentType ShaderStage, IOType IOTy, bool UseNative16BitTypes)
Packs eligible signature elements without moving previously placed elements.
LLVM_ABI Expected< unsigned > packSignatureIndexed(MutableArrayRef< SemanticSignatureElement > Elements, Triple::EnvironmentType ShaderStage, IOType IOTy)
Packs eligible signature elements at rows selected by semantic index.
LLVM_ABI Expected< unsigned > packSignatureOptimized(MutableArrayRef< SemanticSignatureElement > Elements, Triple::EnvironmentType ShaderStage, IOType IOTy, bool UseNative16BitTypes)
Packs eligible signature elements in an optimized order by reordering elements into an optimal packin...
static constexpr unsigned MaxClipCullRows
static constexpr unsigned MaxSignatureRows
static constexpr unsigned MaxSignatureCols
LLVM_ABI std::error_code inconvertibleErrorCode()
The value returned by this function can be returned from convertToErrorCode for Error values where no...
Definition Error.cpp:94