|
@@ -1529,7 +1529,7 @@ void hlsl::SerializeDxilContainerForModule(DxilModule *pModule,
|
|
pModule->GetDxilVersion(major, minor);
|
|
pModule->GetDxilVersion(major, minor);
|
|
RootSignatureWriter rootSigWriter(pModule->GetSerializedRootSignature());
|
|
RootSignatureWriter rootSigWriter(pModule->GetSerializedRootSignature());
|
|
|
|
|
|
- bool bModuleDirty = false;
|
|
|
|
|
|
+ bool bMetadataStripped = false;
|
|
if (pModule->GetShaderModel()->IsLib()) {
|
|
if (pModule->GetShaderModel()->IsLib()) {
|
|
DXASSERT(pModule->GetSerializedRootSignature().empty(),
|
|
DXASSERT(pModule->GetSerializedRootSignature().empty(),
|
|
"otherwise, library has root signature outside subobject definitions");
|
|
"otherwise, library has root signature outside subobject definitions");
|
|
@@ -1538,7 +1538,7 @@ void hlsl::SerializeDxilContainerForModule(DxilModule *pModule,
|
|
writer.AddPart(
|
|
writer.AddPart(
|
|
DFCC_RuntimeData, pRDATWriter->size(),
|
|
DFCC_RuntimeData, pRDATWriter->size(),
|
|
[&](AbstractMemoryStream *pStream) { pRDATWriter->write(pStream); });
|
|
[&](AbstractMemoryStream *pStream) { pRDATWriter->write(pStream); });
|
|
- bModuleDirty |= pModule->StripSubobjectsFromMetadata();
|
|
|
|
|
|
+ bMetadataStripped |= pModule->StripSubobjectsFromMetadata();
|
|
} else {
|
|
} else {
|
|
// Write the DxilPipelineStateValidation (PSV0) part.
|
|
// Write the DxilPipelineStateValidation (PSV0) part.
|
|
pPSVWriter = llvm::make_unique<DxilPSVWriter>(*pModule);
|
|
pPSVWriter = llvm::make_unique<DxilPSVWriter>(*pModule);
|
|
@@ -1550,13 +1550,13 @@ void hlsl::SerializeDxilContainerForModule(DxilModule *pModule,
|
|
writer.AddPart(
|
|
writer.AddPart(
|
|
DFCC_RootSignature, rootSigWriter.size(),
|
|
DFCC_RootSignature, rootSigWriter.size(),
|
|
[&](AbstractMemoryStream *pStream) { rootSigWriter.write(pStream); });
|
|
[&](AbstractMemoryStream *pStream) { rootSigWriter.write(pStream); });
|
|
- bModuleDirty |= pModule->StripRootSignatureFromMetadata();
|
|
|
|
|
|
+ bMetadataStripped |= pModule->StripRootSignatureFromMetadata();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- // If metadata was stripped, re-serialize the module.
|
|
|
|
|
|
+ // If metadata was stripped, re-serialize the input module.
|
|
CComPtr<AbstractMemoryStream> pInputProgramStream = pModuleBitcode;
|
|
CComPtr<AbstractMemoryStream> pInputProgramStream = pModuleBitcode;
|
|
- if (bModuleDirty) {
|
|
|
|
|
|
+ if (bMetadataStripped) {
|
|
pInputProgramStream.Release();
|
|
pInputProgramStream.Release();
|
|
IFT(CreateMemoryStream(DxcGetThreadMallocNoRef(), &pInputProgramStream));
|
|
IFT(CreateMemoryStream(DxcGetThreadMallocNoRef(), &pInputProgramStream));
|
|
raw_stream_ostream outStream(pInputProgramStream.p);
|
|
raw_stream_ostream outStream(pInputProgramStream.p);
|
|
@@ -1565,7 +1565,9 @@ void hlsl::SerializeDxilContainerForModule(DxilModule *pModule,
|
|
|
|
|
|
// If we have debug information present, serialize it to a debug part, then use the stripped version as the canonical program version.
|
|
// If we have debug information present, serialize it to a debug part, then use the stripped version as the canonical program version.
|
|
CComPtr<AbstractMemoryStream> pProgramStream = pInputProgramStream;
|
|
CComPtr<AbstractMemoryStream> pProgramStream = pInputProgramStream;
|
|
- if (HasDebugInfo(*pModule->GetModule())) {
|
|
|
|
|
|
+ bool bModuleStripped = false;
|
|
|
|
+ bool bHasDebugInfo = HasDebugInfo(*pModule->GetModule());
|
|
|
|
+ if (bHasDebugInfo) {
|
|
uint32_t debugInUInt32, debugPaddingBytes;
|
|
uint32_t debugInUInt32, debugPaddingBytes;
|
|
GetPaddedProgramPartSize(pInputProgramStream, debugInUInt32, debugPaddingBytes);
|
|
GetPaddedProgramPartSize(pInputProgramStream, debugInUInt32, debugPaddingBytes);
|
|
if (Flags & SerializeDxilFlags::IncludeDebugInfoPart) {
|
|
if (Flags & SerializeDxilFlags::IncludeDebugInfoPart) {
|
|
@@ -1574,20 +1576,28 @@ void hlsl::SerializeDxilContainerForModule(DxilModule *pModule,
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
- pProgramStream.Release();
|
|
|
|
-
|
|
|
|
llvm::StripDebugInfo(*pModule->GetModule());
|
|
llvm::StripDebugInfo(*pModule->GetModule());
|
|
pModule->StripDebugRelatedCode();
|
|
pModule->StripDebugRelatedCode();
|
|
-
|
|
|
|
- IFT(CreateMemoryStream(DxcGetThreadMallocNoRef(), &pProgramStream));
|
|
|
|
- raw_stream_ostream outStream(pProgramStream.p);
|
|
|
|
- WriteBitcodeToFile(pModule->GetModule(), outStream, true);
|
|
|
|
|
|
+ bModuleStripped = true;
|
|
} else {
|
|
} else {
|
|
// If no debug info, clear DebugNameDependOnSource
|
|
// If no debug info, clear DebugNameDependOnSource
|
|
// (it's default, and this scenario can happen)
|
|
// (it's default, and this scenario can happen)
|
|
Flags &= ~SerializeDxilFlags::DebugNameDependOnSource;
|
|
Flags &= ~SerializeDxilFlags::DebugNameDependOnSource;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if (Flags & SerializeDxilFlags::StripReflectionFromDxilPart) {
|
|
|
|
+ pModule->StripReflection();
|
|
|
|
+ bModuleStripped = true;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // If debug info or reflection was stripped, re-serialize the module.
|
|
|
|
+ if (bModuleStripped) {
|
|
|
|
+ pProgramStream.Release();
|
|
|
|
+ IFT(CreateMemoryStream(DxcGetThreadMallocNoRef(), &pProgramStream));
|
|
|
|
+ raw_stream_ostream outStream(pProgramStream.p);
|
|
|
|
+ WriteBitcodeToFile(pModule->GetModule(), outStream, true);
|
|
|
|
+ }
|
|
|
|
+
|
|
// Serialize debug name if requested.
|
|
// Serialize debug name if requested.
|
|
CComPtr<AbstractMemoryStream> pHashStream;
|
|
CComPtr<AbstractMemoryStream> pHashStream;
|
|
std::string DebugNameStr; // Used if constructing name based on hash
|
|
std::string DebugNameStr; // Used if constructing name based on hash
|