diff options
| author | gdkchan <gab.dark.100@gmail.com> | 2020-05-05 22:02:28 -0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-05-06 11:02:28 +1000 |
| commit | b8eb6abeccbd4a468214a4d2ad3a9b6e5e06973c (patch) | |
| tree | cd3d71ebde0f4f32eb674778adae89c0efcb75df /Ryujinx.Graphics.Nvdec/VDec/VideoDecoder.cs | |
| parent | 7f500e7cae940958289abe1a3461e52684742053 (diff) | |
Refactor shader GPU state and memory access (#1203)
* Refactor shader GPU state and memory access
* Fix NVDEC project build
* Address PR feedback and add missing XML comments
Diffstat (limited to 'Ryujinx.Graphics.Nvdec/VDec/VideoDecoder.cs')
| -rw-r--r-- | Ryujinx.Graphics.Nvdec/VDec/VideoDecoder.cs | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/Ryujinx.Graphics.Nvdec/VDec/VideoDecoder.cs b/Ryujinx.Graphics.Nvdec/VDec/VideoDecoder.cs index b4a89d8f..9afc9485 100644 --- a/Ryujinx.Graphics.Nvdec/VDec/VideoDecoder.cs +++ b/Ryujinx.Graphics.Nvdec/VDec/VideoDecoder.cs @@ -1,6 +1,8 @@ using Ryujinx.Graphics.Gpu; +using Ryujinx.Graphics.Gpu.Memory; using Ryujinx.Graphics.Vic; using System; +using System.Runtime.InteropServices; namespace Ryujinx.Graphics.VDec { @@ -70,7 +72,7 @@ namespace Ryujinx.Graphics.VDec ScalingMatrix8 = gpu.MemoryAccessor.ReadBytes(_decoderContextAddress + 0x220, 2 * 64) }; - byte[] frameData = gpu.MemoryAccessor.ReadBytes(_frameDataAddress, (ulong)frameDataSize); + byte[] frameData = gpu.MemoryAccessor.ReadBytes(_frameDataAddress, frameDataSize); _h264Decoder.Decode(Params, matrices, frameData); } @@ -86,7 +88,7 @@ namespace Ryujinx.Graphics.VDec Ref2Key = (long)gpu.MemoryManager.Translate(_vpxRef2LumaAddress) }; - Vp9FrameHeader header = gpu.MemoryAccessor.Read<Vp9FrameHeader>(_decoderContextAddress + 0x48); + Vp9FrameHeader header = ReadStruct<Vp9FrameHeader>(gpu.MemoryAccessor, _decoderContextAddress + 0x48); Vp9ProbabilityTables probs = new Vp9ProbabilityTables() { @@ -117,7 +119,7 @@ namespace Ryujinx.Graphics.VDec MvHpProbs = gpu.MemoryAccessor.ReadBytes(_vpxProbTablesAddress + 0x54a, 0x2) }; - byte[] frameData = gpu.MemoryAccessor.ReadBytes(_frameDataAddress, (ulong)frameDataSize); + byte[] frameData = gpu.MemoryAccessor.ReadBytes(_frameDataAddress, frameDataSize); _vp9Decoder.Decode(keys, header, probs, frameData); } @@ -127,6 +129,19 @@ namespace Ryujinx.Graphics.VDec } } + private T ReadStruct<T>(MemoryAccessor accessor, ulong address) where T : struct + { + byte[] data = accessor.ReadBytes(address, Marshal.SizeOf<T>()); + + unsafe + { + fixed (byte* ptr = data) + { + return Marshal.PtrToStructure<T>((IntPtr)ptr); + } + } + } + private void SetDecoderCtxAddr(int[] arguments) { _decoderContextAddress = GetAddress(arguments); |
