@@ -54,7 +54,7 @@ namespace Slang
54
54
* Precompile the module for the given target.
55
55
*
56
56
* This function creates a target program and emits the precompiled blob as
57
- * an embedded blob in the module IR, e.g. DXIL.
57
+ * an embedded blob in the module IR, e.g. DXIL, SPIR-V .
58
58
* Because the IR for the Slang Module may violate the restrictions of the
59
59
* target language, the emitted target blob may not be able to include the
60
60
* full module, but rather only the subset that can be precompiled. For
@@ -77,7 +77,7 @@ namespace Slang
77
77
* in the linked IR which survived the additional pruning.
78
78
*
79
79
* Functions that are rejected after linking+legalization (inside
80
- * emitPrecompiled* ):
80
+ * emitPrecompiledDownstreamIR ):
81
81
* - (DXIL) Functions that return or take a HLSLStructuredBufferType
82
82
* - (DXIL) Functions that return or take a Matrix type
83
83
*
@@ -86,17 +86,13 @@ namespace Slang
86
86
* phase of filtering.
87
87
*
88
88
* The original module IR functions matching those are then marked with
89
- * "AvailableIn*" (e.g. AvailableInDXILDecoration) to indicate to future
89
+ * "AvailableInDownstreamIRDecoration" to indicate to future
90
90
* module users which functions are present in the precompiled blob.
91
91
*/
92
92
SLANG_NO_THROW SlangResult SLANG_MCALL Module::precompileForTarget (
93
93
SlangCompileTarget target,
94
94
slang::IBlob** outDiagnostics)
95
95
{
96
- if (target != SLANG_DXIL)
97
- {
98
- return SLANG_FAIL;
99
- }
100
96
CodeGenTarget targetEnum = CodeGenTarget (target);
101
97
102
98
auto module = getIRModule ();
@@ -130,10 +126,15 @@ namespace Slang
130
126
{
131
127
case CodeGenTarget::DXIL:
132
128
tp.getOptionSet ().add (CompilerOptionName::Profile, Profile::RawEnum::DX_Lib_6_6);
133
- tp.getOptionSet ().add (CompilerOptionName::EmbedDXIL, true );
134
129
break ;
130
+ case CodeGenTarget::SPIRV:
131
+ break ;
132
+ default :
133
+ return SLANG_FAIL;
135
134
}
136
135
136
+ tp.getOptionSet ().add (CompilerOptionName::EmbedDownstreamIR, true );
137
+
137
138
CodeGenContext::EntryPointIndices entryPointIndices;
138
139
139
140
entryPointIndices.setCount (entryPointCount);
@@ -166,7 +167,7 @@ namespace Slang
166
167
}
167
168
168
169
ComPtr<IArtifact> outArtifact;
169
- SlangResult res = codeGenContext.emitPrecompiledDXIL (outArtifact);
170
+ SlangResult res = codeGenContext.emitPrecompiledDownstreamIR (outArtifact);
170
171
171
172
sink.getBlobIfNeeded (outDiagnostics);
172
173
if (res != SLANG_OK)
@@ -183,7 +184,8 @@ namespace Slang
183
184
for (const auto & mangledName : metadata->getExportedFunctionMangledNames ())
184
185
{
185
186
auto moduleInst = nameToFunction[mangledName];
186
- builder.addDecoration (moduleInst, kIROp_AvailableInDXILDecoration );
187
+ builder.addDecoration (moduleInst, kIROp_AvailableInDownstreamIRDecoration ,
188
+ builder.getIntValue (builder.getIntType (), (int )targetReq->getTarget ()));
187
189
auto moduleDec = moduleInst->findDecoration <IRDownstreamModuleExportDecoration>();
188
190
moduleDec->removeAndDeallocate ();
189
191
}
@@ -207,12 +209,7 @@ namespace Slang
207
209
// Add the precompiled blob to the module
208
210
builder.setInsertInto (module);
209
211
210
- switch (targetReq->getTarget ())
211
- {
212
- case CodeGenTarget::DXIL:
213
- builder.emitEmbeddedDXIL (blob);
214
- break ;
215
- }
212
+ builder.emitEmbeddedDownstreamIR (targetReq->getTarget (), blob);
216
213
217
214
return SLANG_OK;
218
215
}
0 commit comments