@@ -37,6 +37,8 @@ class DXContainerGlobals : public llvm::ModulePass {
37
37
GlobalVariable *buildSignature (Module &M, Signature &Sig, StringRef Name,
38
38
StringRef SectionName);
39
39
void addSignature (Module &M, SmallVector<GlobalValue *> &Globals);
40
+ void addPipelineStateValidationInfo (Module &M,
41
+ SmallVector<GlobalValue *> &Globals);
40
42
41
43
public:
42
44
static char ID; // Pass identification, replacement for typeid
@@ -63,6 +65,7 @@ bool DXContainerGlobals::runOnModule(Module &M) {
63
65
Globals.push_back (getFeatureFlags (M));
64
66
Globals.push_back (computeShaderHash (M));
65
67
addSignature (M, Globals);
68
+ addPipelineStateValidationInfo (M, Globals);
66
69
appendToCompilerUsed (M, Globals);
67
70
return true ;
68
71
}
@@ -133,6 +136,34 @@ void DXContainerGlobals::addSignature(Module &M,
133
136
Globals.emplace_back (buildSignature (M, OutputSig, " dx.osg1" , " OSG1" ));
134
137
}
135
138
139
+ void DXContainerGlobals::addPipelineStateValidationInfo (
140
+ Module &M, SmallVector<GlobalValue *> &Globals) {
141
+ SmallString<256 > Data;
142
+ raw_svector_ostream OS (Data);
143
+ PSVRuntimeInfo PSV;
144
+ Triple TT (M.getTargetTriple ());
145
+ PSV.BaseData .MinimumWaveLaneCount = 0 ;
146
+ PSV.BaseData .MaximumWaveLaneCount = std::numeric_limits<uint32_t >::max ();
147
+ PSV.BaseData .ShaderStage =
148
+ static_cast <uint8_t >(TT.getEnvironment () - Triple::Pixel);
149
+
150
+ // Hardcoded values here to unblock loading the shader into D3D.
151
+ //
152
+ // TODO: Lots more stuff to do here!
153
+ //
154
+ // See issue https://github.com/llvm/llvm-project/issues/96674.
155
+ PSV.BaseData .NumThreadsX = 1 ;
156
+ PSV.BaseData .NumThreadsY = 1 ;
157
+ PSV.BaseData .NumThreadsZ = 1 ;
158
+ PSV.EntryName = " main" ;
159
+
160
+ PSV.finalize (TT.getEnvironment ());
161
+ PSV.write (OS);
162
+ Constant *Constant =
163
+ ConstantDataArray::getString (M.getContext (), Data, /* AddNull*/ false );
164
+ Globals.emplace_back (buildContainerGlobal (M, Constant, " dx.psv0" , " PSV0" ));
165
+ }
166
+
136
167
char DXContainerGlobals::ID = 0 ;
137
168
INITIALIZE_PASS_BEGIN (DXContainerGlobals, " dxil-globals" ,
138
169
" DXContainer Global Emitter" , false , true )
0 commit comments