浏览代码

Merge pull request #101560 from darksylinc/matias-union-order

Fix union order to simplify empty initializers
Thaddeus Crews 7 月之前
父节点
当前提交
9bcf5ac9f7

+ 1 - 1
core/templates/a_hash_map.h

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

+ 4 - 4
drivers/gles3/rasterizer_scene_gles3.h

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

+ 1 - 1
scene/3d/voxelizer.h

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

+ 1 - 1
scene/gui/graph_edit.h

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

+ 6 - 6
servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.h

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

+ 6 - 6
servers/rendering/renderer_rd/forward_mobile/render_forward_mobile.h

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