Skip to content

Commit d4d97ae

Browse files
committed
xPtankPool: Match weak funcs from xParSys
1 parent 8578a0a commit d4d97ae

File tree

1 file changed

+79
-6
lines changed

1 file changed

+79
-6
lines changed

src/SB/Core/x/xPtankPool.h

Lines changed: 79 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,32 @@ struct ptank_pool
4848
U32 size;
4949
} hide;
5050

51-
bool valid() const;
52-
void reset();
51+
bool valid() const
52+
{
53+
return ptank != NULL;
54+
}
55+
56+
bool at_block_end() const
57+
{
58+
return (used & 0x3F) == 0;
59+
}
60+
61+
void unlock_block()
62+
{
63+
RpPTankAtomicUnlock(ptank);
64+
RPATOMICPTANKPLUGINDATA(ptank)->instFlags |= 0x800000;
65+
RPATOMICPTANKPLUGINDATA(ptank)->actPCount = used;
66+
used = 0;
67+
}
68+
69+
void reset()
70+
{
71+
ptank = NULL;
72+
used = 0;
73+
}
74+
5375
void flush();
5476
void grab_block(ptank_group_type type);
55-
bool at_block_end() const;
56-
void unlock_block();
5777
void lock_block();
5878
};
5979

@@ -125,8 +145,61 @@ struct ptank_pool__pos_color_size_uv2 : ptank_pool
125145
xVec2* uv;
126146
S32 stride;
127147

128-
void next();
129-
void flush();
148+
void next()
149+
{
150+
if (at_block_end())
151+
{
152+
if (valid())
153+
{
154+
unlock_block();
155+
}
156+
157+
grab_block(PGT_POS_COLOR_SIZE_UV2);
158+
159+
if (!valid())
160+
{
161+
return;
162+
}
163+
164+
lock_block();
165+
}
166+
else
167+
{
168+
pos = (xVec3*)((char*)pos + stride);
169+
color = (iColor_tag*)((char*)color + stride);
170+
size = (xVec2*)((char*)size + stride);
171+
uv = (xVec2*)((char*)uv + stride);
172+
}
173+
174+
used += 1;
175+
}
176+
177+
void lock_block()
178+
{
179+
RpPTankLockStruct ls_color;
180+
RpPTankLockStruct ls_pos;
181+
RpPTankLockStruct ls_size;
182+
RpPTankLockStruct ls_uv;
183+
184+
RpPTankAtomicLock(ptank, &ls_pos, rpPTANKLFLAGPOSITION, rpPTANKLOCKWRITE);
185+
RpPTankAtomicLock(ptank, &ls_color, rpPTANKLFLAGCOLOR, rpPTANKLOCKWRITE);
186+
RpPTankAtomicLock(ptank, &ls_size, rpPTANKLFLAGSIZE, rpPTANKLOCKWRITE);
187+
RpPTankAtomicLock(ptank, &ls_uv, rpPTANKLFLAGVTX2TEXCOORDS, rpPTANKLOCKWRITE);
188+
189+
pos = (xVec3*)ls_pos.data;
190+
color = (iColor_tag*)ls_color.data;
191+
size = (xVec2*)ls_size.data;
192+
uv = (xVec2*)ls_uv.data;
193+
stride = ls_pos.stride;
194+
}
195+
196+
void flush()
197+
{
198+
hide.data = (U8*)size + stride;
199+
hide.stride = stride;
200+
hide.size = 4;
201+
ptank_pool::flush();
202+
}
130203
};
131204

132205
void xPTankPoolSceneEnter();

0 commit comments

Comments
 (0)