Place nvnet in its own thread

This commit is contained in:
ergo720 2023-03-12 16:51:38 +01:00
parent 7dc2ac080f
commit 9e3873d1df
3 changed files with 12 additions and 9 deletions

View File

@ -115,9 +115,6 @@ static void update_non_periodic_events()
// update dsound
dsound_worker();
// check nvnet
NVNetRecv();
// check for hw interrupts, but skip the gpu interrupt since that is serviced in vblank_next
for (int i = 0; i < 3; i++) {
// If the interrupt is pending and connected, process it

View File

@ -475,12 +475,19 @@ void EmuNVNet_Write(xbox::addr_xt addr, uint32_t value, int size)
EmuLog(LOG_LEVEL::DEBUG, "Write%d: %s (0x%.8X) = 0x%.8X", size * 8, EmuNVNet_GetRegisterName(addr), addr, value);
}
void NVNetRecv()
std::thread NVNetRecvThread;
void NVNetRecvThreadProc()
{
// NOTE: profiling shows that the winpcap function can take up to 1/6th of the total cpu time of the loader process, so avoid placing
// this function in system_events
g_AffinityPolicy->SetAffinityOther();
static std::unique_ptr<uint8_t[]> packet(new uint8_t[65536]);
int size = g_NVNet->PCAPReceive(packet.get(), 65536);
if (size > 0) {
EmuNVNet_DMAPacketToGuest(packet.get(), size);
while (true) {
int size = g_NVNet->PCAPReceive(packet.get(), 65536);
if (size > 0) {
EmuNVNet_DMAPacketToGuest(packet.get(), size);
}
_mm_pause();
}
}
@ -523,6 +530,7 @@ void NVNetDevice::Init()
};
PCAPInit();
NVNetRecvThread = std::thread(NVNetRecvThreadProc);
}
void NVNetDevice::Reset()

View File

@ -229,5 +229,3 @@ private:
mac_address m_GuestMacAddress = { 0x00, 0x50, 0xF2, 0x00, 0x00, 0x34 };
mac_address m_BroadcastMacAddress = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
};
void NVNetRecv();