Skip to content

Commit 8a677d2

Browse files
authored
[NFC] add utils for PSV. (microsoft#6869)
Add init functions to help build PSVSignatureElement0/PSVRuntimeInfo/PSVResourceInfo. Add print function for DxilPipelineStateValidation. Add new option -dumppsv to dxa for testing. For microsoft#6817.
1 parent 9018970 commit 8a677d2

File tree

17 files changed

+2296
-484
lines changed

17 files changed

+2296
-484
lines changed

include/dxc/DxilContainer/DxilContainer.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,9 @@ enum class DxilProgramSigSemantic : uint32_t {
166166
InnerCoverage = 70,
167167
};
168168

169+
DxilProgramSigSemantic SemanticKindToSystemValue(DXIL::SemanticKind,
170+
DXIL::TessellatorDomain);
171+
169172
enum class DxilProgramSigCompType : uint32_t {
170173
Unknown = 0,
171174
UInt32 = 1,
@@ -179,6 +182,9 @@ enum class DxilProgramSigCompType : uint32_t {
179182
Float64 = 9,
180183
};
181184

185+
DxilProgramSigCompType CompTypeToSigCompType(DXIL::ComponentType,
186+
bool i1ToUnknownCompat);
187+
182188
struct DxilProgramSignatureElement {
183189
uint32_t Stream; // Stream index (parameters must appear in non-decreasing
184190
// stream order)

include/dxc/DxilContainer/DxilPipelineStateValidation.h

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,14 @@
1313
#define __DXIL_PIPELINE_STATE_VALIDATION__H__
1414

1515
#include "dxc/WinAdapter.h"
16+
#include <assert.h>
1617
#include <cstring>
1718
#include <stdint.h>
1819

20+
namespace llvm {
21+
class raw_ostream;
22+
}
23+
1924
// Don't include assert.h here.
2025
// Since this header is included from multiple environments,
2126
// it is necessary to define assert before this header is included.
@@ -229,11 +234,13 @@ struct PSVResourceBindInfo0 {
229234
uint32_t Space;
230235
uint32_t LowerBound;
231236
uint32_t UpperBound;
237+
void Print(llvm::raw_ostream &O) const;
232238
};
233239

234240
struct PSVResourceBindInfo1 : public PSVResourceBindInfo0 {
235241
uint32_t ResKind; // PSVResourceKind
236242
uint32_t ResFlags; // special characteristics of the resource
243+
void Print(llvm::raw_ostream &O) const;
237244
};
238245

239246
// Helpers for output dependencies (ViewID and Input-Output tables)
@@ -266,7 +273,8 @@ struct PSVComponentMask {
266273
if (ComponentIndex < NumVectors * 4)
267274
Mask[ComponentIndex >> 5] &= ~(1 << (ComponentIndex & 0x1F));
268275
}
269-
bool IsValid() { return Mask != nullptr; }
276+
bool IsValid() const { return Mask != nullptr; }
277+
void Print(llvm::raw_ostream &, const char *, const char *) const;
270278
};
271279

272280
struct PSVDependencyTable {
@@ -282,14 +290,23 @@ struct PSVDependencyTable {
282290
: Table(pTable), InputVectors(inputVectors),
283291
OutputVectors(outputVectors) {}
284292
PSVComponentMask GetMaskForInput(uint32_t inputComponentIndex) {
293+
return getMaskForInput(inputComponentIndex);
294+
}
295+
const PSVComponentMask GetMaskForInput(uint32_t inputComponentIndex) const {
296+
return getMaskForInput(inputComponentIndex);
297+
}
298+
bool IsValid() const { return Table != nullptr; }
299+
void Print(llvm::raw_ostream &, const char *, const char *) const;
300+
301+
private:
302+
PSVComponentMask getMaskForInput(uint32_t inputComponentIndex) const {
285303
if (!Table || !InputVectors || !OutputVectors)
286304
return PSVComponentMask();
287305
return PSVComponentMask(
288306
Table + (PSVComputeMaskDwordsFromVectors(OutputVectors) *
289307
inputComponentIndex),
290308
OutputVectors);
291309
}
292-
bool IsValid() { return Table != nullptr; }
293310
};
294311

295312
struct PSVString {
@@ -431,6 +448,7 @@ class PSVSignatureElement {
431448
uint32_t GetDynamicIndexMask() const {
432449
return !m_pElement0 ? 0 : (uint32_t)m_pElement0->DynamicMaskAndStream & 0xF;
433450
}
451+
void Print(llvm::raw_ostream &O) const;
434452
};
435453

436454
#define MAX_PSV_VERSION 3
@@ -732,6 +750,9 @@ class DxilPipelineStateValidation {
732750
? m_StringTable.Get(m_pPSVRuntimeInfo3->EntryFunctionName)
733751
: "";
734752
}
753+
void PrintPSVRuntimeInfo(llvm::raw_ostream &O, uint8_t ShaderKind,
754+
const char *Comment) const;
755+
void Print(llvm::raw_ostream &O, uint8_t ShaderKind) const;
735756
};
736757

737758
// Return true if size fits in remaing buffer.
@@ -1036,6 +1057,10 @@ DxilPipelineStateValidation::ReadOrWrite(const void *pBits, uint32_t *pSize,
10361057

10371058
namespace hlsl {
10381059

1060+
class DxilResourceBase;
1061+
class DxilSignatureElement;
1062+
class DxilModule;
1063+
10391064
class ViewIDValidator {
10401065
public:
10411066
enum class Result {
@@ -1059,6 +1084,21 @@ class ViewIDValidator {
10591084
ViewIDValidator *NewViewIDValidator(unsigned viewIDCount,
10601085
unsigned gsRastStreamIndex);
10611086

1087+
void InitPSVResourceBinding(PSVResourceBindInfo0 *, PSVResourceBindInfo1 *,
1088+
DxilResourceBase *);
1089+
1090+
// Setup PSVSignatureElement0 with DxilSignatureElement.
1091+
// Note that the SemanticName and SemanticIndexes are not done.
1092+
void InitPSVSignatureElement(PSVSignatureElement0 &E,
1093+
const DxilSignatureElement &SE,
1094+
bool i1ToUnknownCompat);
1095+
1096+
// Setup PSVRuntimeInfo* with DxilModule.
1097+
// Note that the EntryFunctionName is not done.
1098+
void InitPSVRuntimeInfo(PSVRuntimeInfo0 *pInfo, PSVRuntimeInfo1 *pInfo1,
1099+
PSVRuntimeInfo2 *pInfo2, PSVRuntimeInfo3 *pInfo3,
1100+
const DxilModule &DM);
1101+
10621102
} // namespace hlsl
10631103

10641104
#undef PSV_RETB

lib/DxilContainer/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ add_llvm_library(LLVMDxilContainer
77
DxilContainerAssembler.cpp
88
DxilContainerReader.cpp
99
DxcContainerBuilder.cpp
10+
DxilPipelineStateValidation.cpp
1011
DxilRDATBuilder.cpp
1112
DxilRuntimeReflection.cpp
1213
RDATDumper.cpp

0 commit comments

Comments
 (0)