Skip to content

microsoft/compiler: Use memcpy instead of a union to write dxil_features

Michael Tang requested to merge tangm/mesa:dxil_features-padding into main

While compiling spirv_to_dxil with clang, during writing struct dxil_features out only results in the low bits being written correctly. This is because struct dxil_features is only 4 bytes, while it gets unioned with a uint64_t (8 bytes). The extra bytes are either uninitialized or initialized with a pattern (0xAA), depending on -ftrivial-auto-var-init's setting.

This change uses a memcpy to pack struct dxil_features into a uint64_t, rather than a union. This shouldn't have the same uninitialized bits issue.

Edited by Michael Tang

Merge request reports