Only keep legacy struct types from resources (#3624)
When compiling a library without 16-bit support, certain struct types containing either min precision types or matrices must be saved in reflection data for conversion after linking. However, this is only necessary when the types are used by a resource. Instead of evaluating all matrix types and saving those that meet this criteria, only the types used by resources are evaluated and possibly preserved. This significantly shrinks the reflection size in this case.
This commit is contained in:
Родитель
6244ab8337
Коммит
82422d7761
|
@ -1765,20 +1765,29 @@ bool DxilModule::StripReflection() {
|
|||
// since they have not yet been converted for legacy layout.
|
||||
// Keep all structs contained in any we must keep.
|
||||
SmallStructSetVector structsToKeep;
|
||||
SmallStructSetVector structsToRemove;
|
||||
for (auto &item : m_pTypeSystem->GetStructAnnotationMap()) {
|
||||
SmallStructSetVector containedStructs;
|
||||
if (!ResourceTypeRequiresTranslation(item.first, containedStructs))
|
||||
structsToRemove.insert(item.first);
|
||||
else
|
||||
structsToKeep.insert(containedStructs.begin(), containedStructs.end());
|
||||
for (auto &CBuf : GetCBuffers())
|
||||
if (StructType *ST = dyn_cast<StructType>(CBuf->GetHLSLType()))
|
||||
if (ResourceTypeRequiresTranslation(ST, containedStructs))
|
||||
structsToKeep.insert(containedStructs.begin(), containedStructs.end());
|
||||
|
||||
for (auto &UAV : GetUAVs()) {
|
||||
if (DXIL::IsStructuredBuffer(UAV->GetKind()))
|
||||
if (StructType *ST = dyn_cast<StructType>(UAV->GetHLSLType()))
|
||||
if (ResourceTypeRequiresTranslation(ST, containedStructs))
|
||||
structsToKeep.insert(containedStructs.begin(), containedStructs.end());
|
||||
}
|
||||
|
||||
for (auto Ty : structsToKeep)
|
||||
structsToRemove.remove(Ty);
|
||||
for (auto Ty : structsToRemove) {
|
||||
m_pTypeSystem->GetStructAnnotationMap().erase(Ty);
|
||||
for (auto &SRV : GetSRVs()) {
|
||||
if (SRV->IsStructuredBuffer() || SRV->IsTBuffer())
|
||||
if (StructType *ST = dyn_cast<StructType>(SRV->GetHLSLType()))
|
||||
if (ResourceTypeRequiresTranslation(ST, containedStructs))
|
||||
structsToKeep.insert(containedStructs.begin(), containedStructs.end());
|
||||
}
|
||||
|
||||
m_pTypeSystem->GetStructAnnotationMap().remove_if([structsToKeep](
|
||||
const std::pair<const StructType *, std::unique_ptr<DxilStructAnnotation>>
|
||||
&I) { return !structsToKeep.count(I.first); });
|
||||
} else {
|
||||
// Remove struct annotations.
|
||||
if (!m_pTypeSystem->GetStructAnnotationMap().empty()) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче