Skip to content

Commit b37348b

Browse files
committed
Improve rgba and rgbaq structs
1 parent 9ef2892 commit b37348b

File tree

2 files changed

+41
-12
lines changed

2 files changed

+41
-12
lines changed

ee/gs/include/gsInit.h

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -970,58 +970,65 @@ typedef union {
970970
u16 y;
971971
u32 z;
972972
};
973-
} __attribute__((packed,aligned(8))) gs_xyz_t;
973+
} __attribute__((packed)) gs_xyz_t;
974974

975975
typedef union {
976-
u64 rgbaq;
976+
u32 rgba;
977977
struct {
978978
u8 r;
979979
u8 g;
980980
u8 b;
981981
u8 a;
982+
};
983+
} __attribute__((packed)) gs_rgba_t;
984+
985+
typedef union {
986+
u64 rgbaq;
987+
struct {
988+
gs_rgba_t components;
982989
float q;
983990
};
984-
} __attribute__((packed,aligned(8))) gs_rgbaq_t;
991+
} __attribute__((packed)) gs_rgbaq_t;
985992

986993
typedef union {
987994
u64 st;
988995
struct {
989996
float s;
990997
float t;
991998
};
992-
} __attribute__((packed, aligned(8))) gs_stq_t;
999+
} __attribute__((packed)) gs_stq_t;
9931000

9941001
typedef union {
9951002
u128 xyz2;
9961003
struct {
9971004
gs_xyz_t xyz;
9981005
u64 tag;
9991006
};
1000-
} __attribute__((packed,aligned(8))) gs_xyz2;
1007+
} __attribute__((packed)) gs_xyz2;
10011008

10021009
typedef union {
10031010
u128 rgbaq;
10041011
struct {
10051012
gs_rgbaq_t color;
10061013
u64 tag;
10071014
};
1008-
} __attribute__((packed,aligned(8))) gs_rgbaq;
1015+
} __attribute__((packed)) gs_rgbaq;
10091016

10101017
typedef union {
10111018
u128 uv;
10121019
struct {
10131020
u64 coord;
10141021
u64 tag;
10151022
};
1016-
} __attribute__((packed,aligned(8))) gs_uv;
1023+
} __attribute__((packed)) gs_uv;
10171024

10181025
typedef union {
10191026
u128 stq;
10201027
struct {
10211028
gs_stq_t st;
10221029
u64 tag;
10231030
};
1024-
} __attribute__((packed, aligned(8))) gs_stq;
1031+
} __attribute__((packed)) gs_stq;
10251032

10261033
/// gsKit Point Primitive Structure
10271034
/// This structure holds all relevant data for any

ee/gs/include/gsInline.h

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -173,16 +173,38 @@ static inline gs_rgbaq color_to_RGBAQ(uint8_t r, uint8_t g, uint8_t b, uint8_t a
173173
{
174174
gs_rgbaq res;
175175

176-
res.color.r = r;
177-
res.color.g = g;
178-
res.color.b = b;
179-
res.color.a = a;
176+
res.color.components.r = r;
177+
res.color.components.g = g;
178+
res.color.components.b = b;
179+
res.color.components.a = a;
180180
res.color.q = q;
181181
res.tag = GS_RGBAQ;
182182

183183
return res;
184184
}
185185

186+
// If STQ coordinates are used set q to 1.0f otherwise keep it as 0.0f
187+
static inline gs_rgbaq rgba_to_RGBAQ(uint32_t rgba, float q)
188+
{
189+
gs_rgbaq res;
190+
191+
res.color.components.rgba = rgba;
192+
res.color.q = q;
193+
res.tag = GS_RGBAQ;
194+
195+
return res;
196+
}
197+
198+
static inline gs_rgbaq rgbaq_to_RGBAQ(uint64_t rgbaq)
199+
{
200+
gs_rgbaq res;
201+
202+
res.color.rgbaq = rgbaq;
203+
res.tag = GS_RGBAQ;
204+
205+
return res;
206+
}
207+
186208
static inline gs_uv vertex_to_UV(const GSTEXTURE *Texture, float u, float v)
187209
{
188210
gs_uv res;

0 commit comments

Comments
 (0)