Page MenuHome

DNA: Cleanup endian switching when loading file.
ClosedPublic

Authored by Jacques Lucke (JacquesLucke) on Oct 2 2020, 12:11 PM.

Details

Summary

This patch "modernizes" DNA_struct_switch_endian similar to how I updated DNA_struct_reconstruct recently. Furthermore, some special case handling has been moved/removed.
Unfortunately, I don't have any 64 bit big endian file to test this with. Our tests don't contain such a file, it's probably quite a rare combination in general...

The first special case that I moved somewhere else is the blocktype member. It was used by the old animation system and was not supposed to be endian switched. Now it is endian switched in the generic code and then switched back during direct linking. Something similar is done in other cases as well. For example IDP_DirectLinkProperty.

Secondly, the way pointers were endian switched before was confusing. Sometimes they were switched and sometimes not depending on different factors. Now, they are always switched when the endianness is different, and never switched when the endianness is the same.

Diff Detail

Repository
rB Blender

Event Timeline

Jacques Lucke (JacquesLucke) requested review of this revision.Oct 2 2020, 12:11 PM
Jacques Lucke (JacquesLucke) created this revision.
source/blender/blenloader/intern/readfile.c
779

This is not necessary anymore, because the pointer has been endian switched before.

source/blender/makesdna/intern/dna_genfile.c
1033–1038

Here we were switching 8 byte pointers only, which I found confusing.

1044

This special case has been moved to direct_link_ipo.

  • Merge branch 'master' into dna-endian-switch
  • clang tidy cleanup

@Campbell Barton (campbellbarton) this just became more important, because the master branch does not work on 64 bit big endian systems currently! I got the file below from T81226. It cannot be opened in master, but can be opened with this patch applied.

  • Merge branch 'master' into dna-endian-switch
  • cleanup
NOTE: Committed an alternate fix to T81226, as this is unrelated to this cleanup.

Switching all addresses seems unnecessarily, both because it's extra logic to run and it could cause unforeseen problems.

The old address is just an ID, it's only used for lookups, switching was only needed when reading 64bit files on 32bit system so meaningful bits aren't masked out.

bh4_from_bh8 can be left as is. The STRUCT_MEMBER_CATEGORY_POINTER can be made only to switch when reading 64bit files on 32bit systems (matching current master).

Otherwise this cleanup seems fine.

This revision was not accepted when it landed; it landed in state Needs Review.Oct 8 2020, 6:18 PM
This revision was automatically updated to reflect the committed changes.