GIF: remove 'done' of the GS_Packet struct

The struct is copied in various ring buffer (hot path)
We only need the return status of the function so use a reference instead of
a state variable

Side note: if we align the struct to 16B maybe the compiler can use SSE to copy it.

Warning: it breaks save state compatibility
This commit is contained in:
Gregory Hainaut 2017-01-05 09:55:59 +01:00
parent 7b3984059a
commit d589be9415
2 changed files with 11 additions and 9 deletions

View File

@ -123,11 +123,13 @@ struct Gif_Tag {
};
struct GS_Packet {
// PERF note: this struct is copied various time in hot path. Don't add
// new field
u32 offset; // Path buffer offset for start of packet
u32 size; // Full size of GS-Packet
s32 cycles; // EE Cycles taken to process this GS packet
s32 readAmount; // Dummy read-amount data needed for proper buffer calculations
bool done; // 0 = Incomplete, 1 = Complete
GS_Packet() { Reset(); }
void Reset() { memzero(*this); }
};
@ -160,7 +162,6 @@ struct Gif_Path_MTVU {
void Reset() { fakePackets = 0;
gsPackQueue.reset();
fakePacket.Reset();
fakePacket.done = 1; // Fake packets don't get processed by pcsx2
fakePacket.size =~0u; // Used to indicate that its a fake packet
}
};
@ -264,11 +265,12 @@ struct Gif_Path {
curSize += size;
}
// If completed a GS packet (with EOP) then returned GS_Packet.done = 1
// If completed a GS packet (with EOP) then set done to true
// MTVU: This function only should be called called on EE thread
GS_Packet ExecuteGSPacket() {
GS_Packet ExecuteGSPacket(bool &done) {
if (mtvu.fakePackets) { // For MTVU mode...
mtvu.fakePackets--;
done = true;
return mtvu.fakePacket;
}
pxAssert(!isMTVU());
@ -317,9 +319,8 @@ struct Gif_Path {
if (gifTag.tag.EOP) {
GS_Packet t = gsPack;
t.done = 1;
done = true;
dmaRewind = 0;
gsPack.Reset();
@ -568,8 +569,9 @@ struct Gif_Unit {
for(;;) {
if (stat.APATH) { // Some Transfer is happening
Gif_Path& path = gifPath[stat.APATH-1];
GS_Packet gsPack = path.ExecuteGSPacket();
if(!gsPack.done) {
bool done = false;
GS_Packet gsPack = path.ExecuteGSPacket(done);
if(!done) {
if (stat.APATH == 3 && CanDoP3Slice() && !gsSIGNAL.queued) {
if(!didPath3 && /*!Path3Masked() &&*/ checkPaths(1,1,0)) { // Path3 slicing
didPath3 = true;

View File

@ -24,7 +24,7 @@
// the lower 16 bit value. IF the change is breaking of all compatibility with old
// states, increment the upper 16 bit value, and clear the lower 16 bits to 0.
static const u32 g_SaveVersion = (0x9A0C << 16) | 0x0000;
static const u32 g_SaveVersion = (0x9A0D << 16) | 0x0000;
// this function is meant to be used in the place of GSfreeze, and provides a safe layer
// between the GS saving function and the MTGS's needs. :)