Skip to content

Commit 4023e77

Browse files
committed
Make all DMA transferred data packed,aligned(16)
1 parent f526f58 commit 4023e77

File tree

7 files changed

+77
-65
lines changed

7 files changed

+77
-65
lines changed

include/ps2s/dmac.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ typedef struct tSourceChainTag_t {
3737
tU64 SPR : 1;
3838
tU32 opt1;
3939
tU32 opt2;
40-
} tSourceChainTag __attribute__((aligned(16)));
40+
} __attribute__((packed,aligned(16))) tSourceChainTag;
4141

4242
typedef tSourceChainTag tDmaTag;
4343

include/ps2s/drawenv.h

Lines changed: 32 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -193,34 +193,37 @@ class CDrawEnv {
193193
inline void operator delete(void* p) { Core::Delete16(p); }
194194

195195
protected:
196-
tSourceChainTag SettingsDmaTag;
197-
tGifTag SettingsGifTag;
198-
GS::tFrame gsrFrame;
199-
tU64 FrameAddr;
200-
GS::tZbuf gsrZBuf;
201-
tU64 ZBufAddr;
202-
GS::tXyoffset gsrXYOffset;
203-
tU64 XYOffsetAddr;
204-
GS::tPrmodecont gsrPrModeCont;
205-
tU64 PrModeContAddr;
206-
GS::tColclamp gsrColClamp;
207-
tU64 ColClampAddr;
208-
GS::tTest gsrTest;
209-
tU64 TestAddr;
210-
GS::tAlpha gsrAlpha;
211-
tU64 AlphaAddr;
212-
GS::tPabe gsrPABE;
213-
tU64 PABEAddr;
214-
GS::tFba gsrFBA;
215-
tU64 FBAAddr;
216-
GS::tDthe gsrDTHE;
217-
tU64 DTHEAddr;
218-
GS::tDimx gsrDIMX;
219-
tU64 DIMXAddr;
220-
GS::tScissor gsrScissor;
221-
tU64 ScissorAddr;
222-
GS::tFogcol gsrFogCol;
223-
tU64 FogColAddr;
196+
struct {
197+
// DMA tag + GIF tag + 13 register settings
198+
tSourceChainTag SettingsDmaTag;
199+
tGifTag SettingsGifTag;
200+
GS::tFrame gsrFrame;
201+
tU64 FrameAddr;
202+
GS::tZbuf gsrZBuf;
203+
tU64 ZBufAddr;
204+
GS::tXyoffset gsrXYOffset;
205+
tU64 XYOffsetAddr;
206+
GS::tPrmodecont gsrPrModeCont;
207+
tU64 PrModeContAddr;
208+
GS::tColclamp gsrColClamp;
209+
tU64 ColClampAddr;
210+
GS::tTest gsrTest;
211+
tU64 TestAddr;
212+
GS::tAlpha gsrAlpha;
213+
tU64 AlphaAddr;
214+
GS::tPabe gsrPABE;
215+
tU64 PABEAddr;
216+
GS::tFba gsrFBA;
217+
tU64 FBAAddr;
218+
GS::tDthe gsrDTHE;
219+
tU64 DTHEAddr;
220+
GS::tDimx gsrDIMX;
221+
tU64 DIMXAddr;
222+
GS::tScissor gsrScissor;
223+
tU64 ScissorAddr;
224+
GS::tFogcol gsrFogCol;
225+
tU64 FogColAddr;
226+
} __attribute__((packed,aligned(16)));
224227
tU32 uiNumGSRegs;
225228

226229
CSCDmaPacket GifPacket;
@@ -232,7 +235,7 @@ class CDrawEnv {
232235
private:
233236
void InitCommon(GS::tContext context);
234237

235-
} __attribute__((aligned(16)));
238+
};
236239

237240
/********************************************
238241
* inline methods

include/ps2s/gs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ typedef struct tGifTag_t {
202202
unsigned long long REGS13 : 4;
203203
unsigned long long REGS14 : 4;
204204
unsigned long long REGS15 : 4;
205-
} tGifTag __attribute__((aligned(16)));
205+
} __attribute__((packed,aligned(16))) tGifTag;
206206

207207
inline unsigned int
208208
GS::GetBitsPerPixel(tPSM psm)

include/ps2s/imagepackets.h

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -76,24 +76,27 @@ class CImageUploadPkt : protected CVifSCDmaPacket {
7676
protected:
7777
private:
7878
// gs packet to setup the texture image transfer
79-
tU128 FirstDmaTag;
80-
tGifTag ImageXferSettingsGifTag;
81-
GS::tBitbltbuf gsrBitBltBuf;
82-
tU64 BitBltBufAddr;
83-
GS::tTrxpos gsrTrxPos;
84-
tU64 TrxPosAddr;
85-
GS::tTrxreg gsrTrxReg;
86-
tU64 TrxRegAddr;
87-
GS::tTrxdir gsrTrxDir;
88-
tU64 TrxDirAddr;
89-
tU128 RestOfPacket[15];
79+
struct {
80+
// DMA tag + GIF tag + 4 register settings (+ 15 rest ?)
81+
tU128 FirstDmaTag;
82+
tGifTag ImageXferSettingsGifTag;
83+
GS::tBitbltbuf gsrBitBltBuf;
84+
tU64 BitBltBufAddr;
85+
GS::tTrxpos gsrTrxPos;
86+
tU64 TrxPosAddr;
87+
GS::tTrxreg gsrTrxReg;
88+
tU64 TrxRegAddr;
89+
GS::tTrxdir gsrTrxDir;
90+
tU64 TrxDirAddr;
91+
tU128 RestOfPacket[15];
92+
} __attribute__((packed,aligned(16)));
9093

9194
tU32 uiNumXferGSRegs;
9295
tU128* pImage;
9396

9497
void InitCommon(void);
9598
void BuildXferTags(void);
96-
} __attribute__((aligned(16)));
99+
};
97100

98101
/********************************************
99102
* CClutUploadPkt

include/ps2s/sprite.h

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -87,16 +87,19 @@ class CSprite {
8787

8888
protected:
8989
private:
90-
tGifTag DrawGifTag;
91-
tU32 Color[4];
92-
tTexCoords TexCoords1;
93-
tU32 Vertex1[4];
94-
tTexCoords TexCoords2;
95-
tU32 Vertex2[4];
90+
struct {
91+
// GIF tag + 5 qwords data
92+
tGifTag DrawGifTag;
93+
tU32 Color[4];
94+
tTexCoords TexCoords1;
95+
tU32 Vertex1[4];
96+
tTexCoords TexCoords2;
97+
tU32 Vertex2[4];
98+
} __attribute__((packed,aligned(16)));
9699

97100
CDmaPacket GifPacket;
98101

99-
} __attribute__((aligned(16)));
102+
};
100103

101104
/********************************************
102105
* inline methods

include/ps2s/texture.h

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -125,18 +125,21 @@ class CTexEnv {
125125

126126
protected:
127127
// gs packet to setup texture environment
128-
tSourceChainTag SettingsDmaTag;
129-
tGifTag SettingsGifTag;
130-
GS::tTexflush gsrTexflush;
131-
tU64 TexflushAddr;
132-
GS::tClamp gsrClamp;
133-
tU64 ClampAddr;
134-
GS::tTex1 gsrTex1;
135-
tU64 Tex1Addr;
136-
GS::tTex0 gsrTex0;
137-
tU64 Tex0Addr;
138-
GS::tTexa gsrTexA;
139-
tU64 TexAAddr;
128+
struct {
129+
// DMA tag + GIF tag + 5 register settings
130+
tSourceChainTag SettingsDmaTag;
131+
tGifTag SettingsGifTag;
132+
GS::tTexflush gsrTexflush;
133+
tU64 TexflushAddr;
134+
GS::tClamp gsrClamp;
135+
tU64 ClampAddr;
136+
GS::tTex1 gsrTex1;
137+
tU64 Tex1Addr;
138+
GS::tTex0 gsrTex0;
139+
tU64 Tex0Addr;
140+
GS::tTexa gsrTexA;
141+
tU64 TexAAddr;
142+
} __attribute__((packed,aligned(16)));
140143

141144
tU32 uiNumSettingsGSRegs;
142145
tU32 uiTexPixelWidth, uiTexPixelHeight;
@@ -146,7 +149,7 @@ class CTexEnv {
146149
private:
147150
void InitCommon(GS::tContext context);
148151

149-
} __attribute__((aligned(16)));
152+
};
150153

151154
/********************************************
152155
* CTexture

src/gs.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ typedef struct {
1717
tGifTag gt;
1818
tU64 texFlush;
1919
tU64 texFlushAddr;
20-
} tFlushPkt;
21-
static tFlushPkt FlushPkt __attribute__((aligned(16)));
20+
} __attribute__((packed,aligned(16))) tFlushPkt;
21+
static tFlushPkt FlushPkt;
2222

2323
/********************************************
2424
* functions

0 commit comments

Comments
 (0)