Skip to content

Commit 6c7ad3e

Browse files
authored
Add RDAT::RecordTraits::MaxRecordSize to default to newest version (microsoft#4680)
Added MaxRecordSize calling DerivedRecordSize that gets specialized for each base in RDAT_STRUCT_TABLE_DERIVED macro to call the derived MaxRecordStride. The most-derived version of DerivedRecordSize will use the default implementation, which is the size of that type.
1 parent 009e7f1 commit 6c7ad3e

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

include/dxc/DxilContainer/DxilRuntimeReflection.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,8 @@ class RecordTraits {
268268
}
269269
// RecordSize() is defined in order to allow for use of forward decl type in RecordRef
270270
static constexpr size_t RecordSize() { /*static_assert(false, "");*/ return sizeof(_T); }
271+
static constexpr size_t MaxRecordSize() { return RecordTraits<_T>::DerivedRecordSize(); }
272+
static constexpr size_t DerivedRecordSize() { return sizeof(_T); }
271273
};
272274

273275
///////////////////////////////////////

include/dxc/DxilContainer/RDAT_Macros.inl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,8 @@
220220
#define RDAT_STRUCT_TABLE_DERIVED(type, base, table) \
221221
RDAT_STRUCT_DERIVED(type, base) \
222222
template<> constexpr RecordTableIndex RecordTraits<type>::TableIndex() { return RecordTableIndex::table; } \
223-
template<> constexpr RuntimeDataPartType RecordTraits<type>::PartType() { return RuntimeDataPartType::table; }
223+
template<> constexpr RuntimeDataPartType RecordTraits<type>::PartType() { return RuntimeDataPartType::table; } \
224+
template<> constexpr size_t RecordTraits<base>::DerivedRecordSize() { return RecordTraits<type>::MaxRecordSize(); }
224225
#endif // DEF_RDAT_TYPES cases
225226

226227
// Define any undefined macros to defaults

include/dxc/DxilRDATBuilder/DxilRDATBuilder.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class DxilRDATBuilder {
4747
if (!*tablePtr) {
4848
m_Parts.emplace_back(llvm::make_unique<RDATTable>());
4949
*tablePtr = reinterpret_cast<RDATTable *>(m_Parts.back().get());
50-
(*tablePtr)->SetRecordStride(sizeof(T));
50+
(*tablePtr)->SetRecordStride(RDAT::RecordTraits<T>::MaxRecordSize());
5151
(*tablePtr)->SetType(RDAT::RecordTraits<T>::PartType());
5252
(*tablePtr)->SetDeduplication(m_bRecordDeduplicationEnabled);
5353
}

0 commit comments

Comments
 (0)