Revert "gx2: Use atomic pointers for GX2WriteGatherPipeState"

This reverts commit e6e65aff9a.
Superseded
This commit is contained in:
Exverge 2025-05-26 00:34:09 -04:00
parent 3a3710d2e2
commit cee2195126
2 changed files with 16 additions and 16 deletions

View file

@ -17,28 +17,28 @@ GX2WriteGatherPipeState gx2WriteGatherPipe = { 0 };
void gx2WriteGather_submitU32AsBE(uint32 v) void gx2WriteGather_submitU32AsBE(uint32 v)
{ {
uint32 coreIndex = PPCInterpreter_getCoreIndex(PPCInterpreter_getCurrentInstance()); uint32 coreIndex = PPCInterpreter_getCoreIndex(PPCInterpreter_getCurrentInstance());
if (*gx2WriteGatherPipe.writeGatherPtrWrite[coreIndex] == NULL) if (gx2WriteGatherPipe.writeGatherPtrWrite[coreIndex] == NULL)
return; return;
*(uint32*)(gx2WriteGatherPipe.writeGatherPtrWrite[coreIndex]->load()) = _swapEndianU32(v); *(uint32*)(*gx2WriteGatherPipe.writeGatherPtrWrite[coreIndex]) = _swapEndianU32(v);
*gx2WriteGatherPipe.writeGatherPtrWrite[coreIndex] += 4; (*gx2WriteGatherPipe.writeGatherPtrWrite[coreIndex]) += 4;
} }
void gx2WriteGather_submitU32AsLE(uint32 v) void gx2WriteGather_submitU32AsLE(uint32 v)
{ {
uint32 coreIndex = PPCInterpreter_getCoreIndex(PPCInterpreter_getCurrentInstance()); uint32 coreIndex = PPCInterpreter_getCoreIndex(PPCInterpreter_getCurrentInstance());
if (*gx2WriteGatherPipe.writeGatherPtrWrite[coreIndex] == NULL) if (gx2WriteGatherPipe.writeGatherPtrWrite[coreIndex] == NULL)
return; return;
*(uint32*)(gx2WriteGatherPipe.writeGatherPtrWrite[coreIndex]->load()) = v; *(uint32*)(*gx2WriteGatherPipe.writeGatherPtrWrite[coreIndex]) = v;
*gx2WriteGatherPipe.writeGatherPtrWrite[coreIndex] += 4; (*gx2WriteGatherPipe.writeGatherPtrWrite[coreIndex]) += 4;
} }
void gx2WriteGather_submitU32AsLEArray(uint32* v, uint32 numValues) void gx2WriteGather_submitU32AsLEArray(uint32* v, uint32 numValues)
{ {
uint32 coreIndex = PPCInterpreter_getCoreIndex(PPCInterpreter_getCurrentInstance()); uint32 coreIndex = PPCInterpreter_getCoreIndex(PPCInterpreter_getCurrentInstance());
if (*gx2WriteGatherPipe.writeGatherPtrWrite[coreIndex] == NULL) if (gx2WriteGatherPipe.writeGatherPtrWrite[coreIndex] == NULL)
return; return;
memcpy_dwords(gx2WriteGatherPipe.writeGatherPtrWrite[coreIndex]->load(), v, numValues); memcpy_dwords((*gx2WriteGatherPipe.writeGatherPtrWrite[coreIndex]), v, numValues);
*gx2WriteGatherPipe.writeGatherPtrWrite[coreIndex] += 4 * numValues; (*gx2WriteGatherPipe.writeGatherPtrWrite[coreIndex]) += 4 * numValues;
} }
namespace GX2 namespace GX2
@ -121,7 +121,7 @@ namespace GX2
if (sGX2MainCoreIndex == coreIndex) if (sGX2MainCoreIndex == coreIndex)
gx2WriteGatherPipe.writeGatherPtrWrite[coreIndex] = &gx2WriteGatherPipe.writeGatherPtrGxBuffer[coreIndex]; gx2WriteGatherPipe.writeGatherPtrWrite[coreIndex] = &gx2WriteGatherPipe.writeGatherPtrGxBuffer[coreIndex];
else else
*gx2WriteGatherPipe.writeGatherPtrWrite[coreIndex] = NULL; gx2WriteGatherPipe.writeGatherPtrWrite[coreIndex] = NULL;
// return size of (written) display list // return size of (written) display list
return currentWriteSize; return currentWriteSize;
} }
@ -217,7 +217,7 @@ namespace GX2
cemu_assert_debug(coreIndex == sGX2MainCoreIndex); cemu_assert_debug(coreIndex == sGX2MainCoreIndex);
coreIndex = sGX2MainCoreIndex; // always submit to main queue which is owned by GX2 main core (TCLSubmitToRing does not need this workaround) coreIndex = sGX2MainCoreIndex; // always submit to main queue which is owned by GX2 main core (TCLSubmitToRing does not need this workaround)
uint32be* cmdStream = (uint32be*)(gx2WriteGatherPipe.writeGatherPtrGxBuffer[coreIndex].load()); uint32be* cmdStream = (uint32be*)(gx2WriteGatherPipe.writeGatherPtrGxBuffer[coreIndex]);
cmdStream[0] = pm4HeaderType3(IT_INDIRECT_BUFFER_PRIV, 3); cmdStream[0] = pm4HeaderType3(IT_INDIRECT_BUFFER_PRIV, 3);
cmdStream[1] = memory_virtualToPhysical(MEMPTR<void>(addr).GetMPTR()); cmdStream[1] = memory_virtualToPhysical(MEMPTR<void>(addr).GetMPTR());
cmdStream[2] = 0; cmdStream[2] = 0;

View file

@ -6,9 +6,9 @@ struct GX2WriteGatherPipeState
{ {
uint8* gxRingBuffer; uint8* gxRingBuffer;
// each core has it's own write gatherer and display list state (writing) // each core has it's own write gatherer and display list state (writing)
std::atomic<uint8*> writeGatherPtrGxBuffer[Espresso::CORE_COUNT]; uint8* writeGatherPtrGxBuffer[Espresso::CORE_COUNT];
std::atomic<uint8*>* writeGatherPtrWrite[Espresso::CORE_COUNT]; uint8** writeGatherPtrWrite[Espresso::CORE_COUNT];
std::atomic<uint8*> writeGatherPtrDisplayList[Espresso::CORE_COUNT]; uint8* writeGatherPtrDisplayList[Espresso::CORE_COUNT];
MPTR displayListStart[Espresso::CORE_COUNT]; MPTR displayListStart[Espresso::CORE_COUNT];
uint32 displayListMaxSize[Espresso::CORE_COUNT]; uint32 displayListMaxSize[Espresso::CORE_COUNT];
}; };
@ -75,10 +75,10 @@ template <typename ...Targs>
inline void gx2WriteGather_submit(Targs... args) inline void gx2WriteGather_submit(Targs... args)
{ {
uint32 coreIndex = PPCInterpreter_getCurrentCoreIndex(); uint32 coreIndex = PPCInterpreter_getCurrentCoreIndex();
if (*gx2WriteGatherPipe.writeGatherPtrWrite[coreIndex] == nullptr) if (gx2WriteGatherPipe.writeGatherPtrWrite[coreIndex] == nullptr)
return; return;
uint32be* writePtr = (uint32be*)gx2WriteGatherPipe.writeGatherPtrWrite[coreIndex]->load(); uint32be* writePtr = (uint32be*)(*gx2WriteGatherPipe.writeGatherPtrWrite[coreIndex]);
gx2WriteGather_submit_(coreIndex, writePtr, std::forward<Targs>(args)...); gx2WriteGather_submit_(coreIndex, writePtr, std::forward<Targs>(args)...);
} }