From cd51a9ea2ef1e7157b593c1a29e42d2bc7f0b3f8 Mon Sep 17 00:00:00 2001 From: ParantezTech <12572227+par274@users.noreply.github.com> Date: Sun, 11 Oct 2026 01:42:12 +0300 Subject: [PATCH] [AGC] Emit event and flip packets with one write --- src/SharpEmu.Libs/Agc/AgcExports.Events.cs | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/src/SharpEmu.Libs/Agc/AgcExports.Events.cs b/src/SharpEmu.Libs/Agc/AgcExports.Events.cs index d21a8b6..432a2ec 100644 --- a/src/SharpEmu.Libs/Agc/AgcExports.Events.cs +++ b/src/SharpEmu.Libs/Agc/AgcExports.Events.cs @@ -69,9 +69,7 @@ public static partial class AgcExports return ReturnPointer(ctx, 0); } - if (!TryAllocateCommandDwords(ctx, commandBufferAddress, 2, out var commandAddress) || - !TryWriteUInt32(ctx, commandAddress, Pm4(2, ItEventWrite, 0)) || - !TryWriteUInt32(ctx, commandAddress + 4, eventType)) + if (!TryEmitCommandDwords(ctx, commandBufferAddress, out var commandAddress, Pm4(2, ItEventWrite, 0), eventType)) { return ReturnPointer(ctx, 0); } @@ -95,14 +93,7 @@ public static partial class AgcExports return ReturnPointer(ctx, 0); } - if (!TryAllocateCommandDwords(ctx, commandBufferAddress, 7, out var commandAddress) || - !TryWriteUInt32(ctx, commandAddress, Pm4(7, ItNop, RWaitFlipDone)) || - !TryWriteUInt32(ctx, commandAddress + 4, videoOutHandle) || - !TryWriteUInt32(ctx, commandAddress + 8, displayBufferIndex) || - !TryWriteUInt32(ctx, commandAddress + 12, 0) || - !TryWriteUInt32(ctx, commandAddress + 16, 0) || - !TryWriteUInt32(ctx, commandAddress + 20, 0) || - !TryWriteUInt32(ctx, commandAddress + 24, 0)) + if (!TryEmitCommandDwords(ctx, commandBufferAddress, out var commandAddress, Pm4(7, ItNop, RWaitFlipDone), videoOutHandle, displayBufferIndex, 0, 0, 0, 0)) { return ReturnPointer(ctx, 0); } @@ -128,13 +119,7 @@ public static partial class AgcExports return ReturnPointer(ctx, 0); } - if (!TryAllocateCommandDwords(ctx, commandBufferAddress, 6, out var commandAddress) || - !TryWriteUInt32(ctx, commandAddress, Pm4(6, ItNop, RFlip)) || - !TryWriteUInt32(ctx, commandAddress + 4, videoOutHandle) || - !TryWriteUInt32(ctx, commandAddress + 8, unchecked((uint)displayBufferIndex)) || - !TryWriteUInt32(ctx, commandAddress + 12, flipMode) || - !TryWriteUInt32(ctx, commandAddress + 16, (uint)(flipArg & 0xFFFF_FFFFUL)) || - !TryWriteUInt32(ctx, commandAddress + 20, (uint)(flipArg >> 32))) + if (!TryEmitCommandDwords(ctx, commandBufferAddress, out var commandAddress, Pm4(6, ItNop, RFlip), videoOutHandle, unchecked((uint)displayBufferIndex), flipMode, (uint)(flipArg & 0xFFFF_FFFFUL), (uint)(flipArg >> 32))) { return ReturnPointer(ctx, 0); }