NVDEC (H264): Use separate contexts per channel and decode frames in DTS order (#2671)

* Use separate NVDEC contexts per channel (for FFMPEG)

* Remove NVDEC -> VIC frame override hack

* Add missing bottom_field_pic_order_in_frame_present_flag

* Make FFMPEG logging static

* nit: Remove empty lines

* New FFMPEG decoding approach -- call h264_decode_frame directly, trim surface cache to reduce memory usage

* Fix case

* Silence warnings

* PR feedback

* Per-decoder rather than per-codec ownership of surfaces on the cache
This commit is contained in:
gdkchan 2021-09-28 19:43:40 -03:00 committed by GitHub
parent 0d23504e30
commit f4f496cb48
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 358 additions and 200 deletions

View file

@ -1,9 +1,7 @@
using Ryujinx.Common.Logging;
using Ryujinx.Graphics.Device;
using Ryujinx.Graphics.Device;
using Ryujinx.Graphics.Gpu.Memory;
using Ryujinx.Graphics.Vic.Image;
using Ryujinx.Graphics.Vic.Types;
using System;
using System.Collections.Generic;
namespace Ryujinx.Graphics.Vic
@ -14,9 +12,6 @@ namespace Ryujinx.Graphics.Vic
private readonly ResourceManager _rm;
private readonly DeviceState<VicRegisters> _state;
private PlaneOffsets _overrideOffsets;
private bool _hasOverride;
public VicDevice(MemoryManager gmm)
{
_gmm = gmm;
@ -27,32 +22,6 @@ namespace Ryujinx.Graphics.Vic
});
}
/// <summary>
/// Overrides all input surfaces with a custom surface.
/// </summary>
/// <param name="lumaOffset">Offset of the luma plane or packed data for this surface</param>
/// <param name="chromaUOffset">Offset of the U chroma plane (for planar formats) or both chroma planes (for semiplanar formats)</param>
/// <param name="chromaVOffset">Offset of the V chroma plane for planar formats</param>
public void SetSurfaceOverride(uint lumaOffset, uint chromaUOffset, uint chromaVOffset)
{
_overrideOffsets.LumaOffset = lumaOffset;
_overrideOffsets.ChromaUOffset = chromaUOffset;
_overrideOffsets.ChromaVOffset = chromaVOffset;
_hasOverride = true;
}
/// <summary>
/// Disables overriding input surfaces.
/// </summary>
/// <remarks>
/// Surface overrides are disabled by default.
/// Call this if you previously called <see cref="SetSurfaceOverride(uint, uint, uint)"/> and which to disable it.
/// </remarks>
public void DisableSurfaceOverride()
{
_hasOverride = false;
}
public int Read(int offset) => _state.Read(offset);
public void Write(int offset, int data) => _state.Write(offset, data);
@ -76,11 +45,6 @@ namespace Ryujinx.Graphics.Vic
var offsets = _state.State.SetSurfacexSlotx[i][0];
if (_hasOverride)
{
offsets = _overrideOffsets;
}
using Surface src = SurfaceReader.Read(_rm, ref slot.SlotSurfaceConfig, ref offsets);
Blender.BlendOne(output, src, ref slot);