mirror of https://github.com/PCSX2/pcsx2.git
Gif: port code to std::atomic
This commit is contained in:
parent
92078b1c58
commit
3a9bd90a3b
|
@ -118,14 +118,14 @@ void Gif_AddCompletedGSPacket(GS_Packet& gsPack, GIF_PATH path) {
|
|||
}
|
||||
else {
|
||||
pxAssertDev(!gsPack.readAmount, "Gif Unit - gsPack.readAmount only valid for MTVU path 1!");
|
||||
AtomicExchangeAdd(gifUnit.gifPath[path].readAmount, gsPack.size);
|
||||
gifUnit.gifPath[path].readAmount.fetch_add(gsPack.size);
|
||||
GetMTGS().SendSimpleGSPacket(GS_RINGTYPE_GSPACKET, gsPack.offset, gsPack.size, path);
|
||||
}
|
||||
}
|
||||
|
||||
void Gif_AddBlankGSPacket(u32 size, GIF_PATH path) {
|
||||
//DevCon.WriteLn("Adding Blank Gif Packet [size=%x]", size);
|
||||
AtomicExchangeAdd(gifUnit.gifPath[path].readAmount, size);
|
||||
gifUnit.gifPath[path].readAmount.fetch_add(size);
|
||||
GetMTGS().SendSimpleGSPacket(GS_RINGTYPE_GSPACKET, ~0u, size, path);
|
||||
}
|
||||
|
||||
|
|
|
@ -153,7 +153,7 @@ struct Gif_Path_MTVU {
|
|||
};
|
||||
|
||||
struct Gif_Path {
|
||||
__aligned(4) volatile s32 readAmount; // Amount of data MTGS still needs to read
|
||||
std::atomic<int> readAmount; // Amount of data MTGS still needs to read
|
||||
u8* buffer; // Path packet buffer
|
||||
u32 buffSize; // Full size of buffer
|
||||
u32 buffLimit; // Cut off limit to wrap around
|
||||
|
@ -195,7 +195,7 @@ struct Gif_Path {
|
|||
}
|
||||
|
||||
bool isMTVU() const { return !idx && THREAD_VU1; }
|
||||
s32 getReadAmount() { return AtomicRead(readAmount) + gsPack.readAmount; }
|
||||
s32 getReadAmount() { return readAmount.load() + gsPack.readAmount; }
|
||||
bool hasDataRemaining() const { return curOffset < curSize; }
|
||||
bool isDone() const { return isMTVU() ? !mtvu.fakePackets : (!hasDataRemaining() && (state == GIF_PATH_IDLE || state == GIF_PATH_WAIT)); }
|
||||
|
||||
|
@ -380,7 +380,7 @@ struct Gif_Path {
|
|||
void FinishGSPacketMTVU() {
|
||||
if (1) {
|
||||
ScopedLock lock(mtvu.gsPackMutex);
|
||||
AtomicExchangeAdd(readAmount, gsPack.size + gsPack.readAmount);
|
||||
readAmount.fetch_add(gsPack.size + gsPack.readAmount);
|
||||
mtvu.gsPackQueue.push_back(gsPack);
|
||||
}
|
||||
gsPack.Reset();
|
||||
|
|
|
@ -395,7 +395,7 @@ void SysMtgsThread::ExecuteTaskInThread()
|
|||
u32 offset = tag.data[0];
|
||||
u32 size = tag.data[1];
|
||||
if (offset != ~0u) GSgifTransfer((u32*)&path.buffer[offset], size/16);
|
||||
AtomicExchangeSub(path.readAmount, size);
|
||||
path.readAmount.fetch_sub(size);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -409,7 +409,7 @@ void SysMtgsThread::ExecuteTaskInThread()
|
|||
Gif_Path& path = gifUnit.gifPath[GIF_PATH_1];
|
||||
GS_Packet gsPack = path.GetGSPacketMTVU(); // Get vu1 program's xgkick packet(s)
|
||||
if (gsPack.size) GSgifTransfer((u32*)&path.buffer[gsPack.offset], gsPack.size/16);
|
||||
AtomicExchangeSub(path.readAmount, gsPack.size + gsPack.readAmount);
|
||||
path.readAmount.fetch_sub(gsPack.size + gsPack.readAmount);
|
||||
path.PopGSPacketMTVU(); // Should be done last, for proper Gif_MTGS_Wait()
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue