Skip to content

Commit

Permalink
fix: SymOverrideInfo bitfields should be the same type (#1745)
Browse files Browse the repository at this point in the history
Stephen Friedman alerted me to the fact that on Windows, bit fields
within a struct will only be combined if they are the same type.  We
were a bit sloppy in the defintion of SymOverrideInfo, and that was
causing the struct to end up a different size in Windows.  I think the
solution is that all those bit fields should be `unsigned int`.

---------

Signed-off-by: Larry Gritz <[email protected]>
  • Loading branch information
lgritz authored Oct 26, 2023
1 parent 0e55efb commit 7710b1b
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/liboslexec/oslexec_pvt.h
Original file line number Diff line number Diff line change
Expand Up @@ -1468,11 +1468,13 @@ class ShaderInstance {
/// instance overrides from the master copy.
struct SymOverrideInfo {
// Using bit fields to keep the data in 8 bytes in total.
unsigned char m_valuesource : 3;
bool m_connected_down : 1;
bool m_interpolated : 1;
bool m_interactive : 1;
int m_arraylen : 26;
// Note: it's important that all the bitfields are the same type
// (unsigned int), or MSVS won't merge them properly into one int.
unsigned int m_valuesource : 3;
unsigned int m_connected_down : 1;
unsigned int m_interpolated : 1;
unsigned int m_interactive : 1;
unsigned int m_arraylen : 26;
int m_data_offset;

SymOverrideInfo()
Expand Down

0 comments on commit 7710b1b

Please sign in to comment.