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
This commit is contained in:
parent
7f500e7cae
commit
b8eb6abecc
35 changed files with 633 additions and 684 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue