[VideoOut] Unregister buffers after pending command streams

Co-authored-by: Sekai <140012992+igettingit@users.noreply.github.com>
This commit is contained in:
ParantezTech 2026-10-06 17:47:34 +03:00
parent 4a72655d17
commit db05345cde
1 changed files with 25 additions and 19 deletions

View File

@ -1249,36 +1249,42 @@ public static partial class VideoOutExports
{
var handle = unchecked((int)ctx[CpuRegister.Rdi]);
var attributeIndex = unchecked((int)ctx[CpuRegister.Rsi]);
if (!TryGetPort(handle, out var port))
{
return OrbisVideoOutErrorInvalidHandle;
}
if (attributeIndex < 0)
{
return OrbisVideoOutErrorInvalidValue;
}
lock (_stateGate)
var result = (int)OrbisGen2Result.ORBIS_GEN2_OK;
GuestGpu.Current.RunAfterPendingCommandStreams(() =>
{
if (attributeIndex >= port.Groups.Length || port.Groups[attributeIndex] is null)
lock (_stateGate)
{
return OrbisVideoOutErrorInvalidValue;
}
port.Groups[attributeIndex] = null;
foreach (var slot in port.BufferSlots)
{
if (slot.GroupIndex == attributeIndex)
if (!_ports.TryGetValue(handle, out var port))
{
slot.GroupIndex = -1;
slot.AddressLeft = 0;
slot.AddressRight = 0;
result = OrbisVideoOutErrorInvalidHandle;
return;
}
if (attributeIndex >= port.Groups.Length || port.Groups[attributeIndex] is null)
{
result = OrbisVideoOutErrorInvalidValue;
return;
}
port.Groups[attributeIndex] = null;
foreach (var slot in port.BufferSlots)
{
if (slot.GroupIndex == attributeIndex)
{
slot.GroupIndex = -1;
slot.AddressLeft = 0;
slot.AddressRight = 0;
}
}
}
});
return (int)OrbisGen2Result.ORBIS_GEN2_OK;
}
return result;
}
[SysAbiExport(