Fix union order to simplify empty initializers

This is a followup to PR #101344 (commit
0e06eb80bc).

Some of them were not an issue because Godot was initializing all
members, but they were "fixed" just in case since it could become a
problem in the future.

Valgrind was specifically complaining about HashMapData &
GlobalPipelineData.
This commit is contained in:
Matias N. Goldberg 2025-01-14 19:01:30 -03:00
parent 4ce466d7fa
commit 7b2f1e1d09
6 changed files with 19 additions and 19 deletions

View file

@ -35,12 +35,12 @@
struct HashMapData {
union {
uint64_t data;
struct
{
uint32_t hash;
uint32_t hash_to_key;
};
uint64_t data;
};
};

View file

@ -250,6 +250,10 @@ private:
};
union {
struct {
uint64_t sort_key1;
uint64_t sort_key2;
};
struct {
uint64_t lod_index : 8;
uint64_t surface_index : 8;
@ -265,10 +269,6 @@ private:
uint64_t depth_layer : 4;
uint64_t priority : 8;
};
struct {
uint64_t sort_key1;
uint64_t sort_key2;
};
} sort;
RS::PrimitiveType primitive = RS::PRIMITIVE_MAX;

View file

@ -72,13 +72,13 @@ private:
struct CellSort {
union {
uint64_t key = 0;
struct {
uint64_t z : 16;
uint64_t y : 16;
uint64_t x : 16;
uint64_t level : 16;
};
uint64_t key = 0;
};
int32_t index = 0;

View file

@ -150,11 +150,11 @@ public:
private:
struct ConnectionType {
union {
uint64_t key = 0;
struct {
uint32_t type_a;
uint32_t type_b;
};
uint64_t key = 0;
};
static uint32_t hash(const ConnectionType &p_conn) {

View file

@ -428,6 +428,10 @@ private:
};
union {
struct {
uint64_t sort_key1;
uint64_t sort_key2;
};
struct {
uint64_t lod_index : 8;
uint64_t surface_index : 8;
@ -443,10 +447,6 @@ private:
uint64_t depth_layer : 4;
uint64_t priority : 8;
};
struct {
uint64_t sort_key1;
uint64_t sort_key2;
};
} sort;
RS::PrimitiveType primitive = RS::PRIMITIVE_MAX;
@ -541,6 +541,8 @@ private:
struct GlobalPipelineData {
union {
uint32_t key;
struct {
uint32_t texture_samples : 3;
uint32_t use_reflection_probes : 1;
@ -556,8 +558,6 @@ private:
uint32_t use_shadow_cubemaps : 1;
uint32_t use_shadow_dual_paraboloid : 1;
};
uint32_t key;
};
};

View file

@ -397,6 +397,10 @@ protected:
};
union {
struct {
uint64_t sort_key1;
uint64_t sort_key2;
};
struct {
// !BAS! CHECK BITS!!!
@ -413,10 +417,6 @@ protected:
// uint64_t lod_index : 8; // no need to sort on LOD
// uint64_t uses_forward_gi : 1; // no GI here, remove
};
struct {
uint64_t sort_key1;
uint64_t sort_key2;
};
} sort;
RS::PrimitiveType primitive = RS::PRIMITIVE_MAX;
@ -575,6 +575,8 @@ public:
struct GlobalPipelineData {
union {
uint32_t key;
struct {
uint32_t texture_samples : 3;
uint32_t target_samples : 3;
@ -586,8 +588,6 @@ public:
uint32_t use_shadow_cubemaps : 1;
uint32_t use_shadow_dual_paraboloid : 1;
};
uint32_t key;
};
};