misc: chore: Use explicit types in NVDEC projects (except VP9 because there's an open PR and I don't want to cause conflicts)

This commit is contained in:
Evan Husted 2025-01-25 14:07:20 -06:00
parent 76ec047eb7
commit 68bbb29be6
4 changed files with 14 additions and 12 deletions

View file

@ -41,7 +41,7 @@ namespace Ryujinx.Graphics.Nvdec.FFmpeg.Native
{
handle = nint.Zero;
if (_librariesWhitelist.TryGetValue(libraryName, out var value))
if (_librariesWhitelist.TryGetValue(libraryName, out (int, int) value))
{
(int minVersion, int maxVersion) = value;

View file

@ -2,6 +2,7 @@ using Ryujinx.Common;
using Ryujinx.Graphics.Device;
using Ryujinx.Graphics.Texture;
using Ryujinx.Graphics.Video;
using Ryujinx.Memory;
using System;
using System.Runtime.Intrinsics;
using System.Runtime.Intrinsics.X86;
@ -16,7 +17,7 @@ namespace Ryujinx.Graphics.Nvdec.Image
{
int lumaSize = GetBlockLinearSize(surface.Width, surface.Height, 1);
using var luma = mm.GetWritableRegion(ExtendOffset(lumaOffset), lumaSize);
using WritableRegion luma = mm.GetWritableRegion(ExtendOffset(lumaOffset), lumaSize);
WriteLuma(
luma.Memory.Span,
@ -27,7 +28,7 @@ namespace Ryujinx.Graphics.Nvdec.Image
int chromaSize = GetBlockLinearSize(surface.UvWidth, surface.UvHeight, 2);
using var chroma = mm.GetWritableRegion(ExtendOffset(chromaOffset), chromaSize);
using WritableRegion chroma = mm.GetWritableRegion(ExtendOffset(chromaOffset), chromaSize);
WriteChroma(
chroma.Memory.Span,
@ -48,8 +49,8 @@ namespace Ryujinx.Graphics.Nvdec.Image
{
int lumaSize = GetBlockLinearSize(surface.Width, surface.Height / 2, 1);
using var lumaTop = mm.GetWritableRegion(ExtendOffset(lumaTopOffset), lumaSize);
using var lumaBottom = mm.GetWritableRegion(ExtendOffset(lumaBottomOffset), lumaSize);
using WritableRegion lumaTop = mm.GetWritableRegion(ExtendOffset(lumaTopOffset), lumaSize);
using WritableRegion lumaBottom = mm.GetWritableRegion(ExtendOffset(lumaBottomOffset), lumaSize);
WriteLuma(
lumaTop.Memory.Span,
@ -67,8 +68,8 @@ namespace Ryujinx.Graphics.Nvdec.Image
int chromaSize = GetBlockLinearSize(surface.UvWidth, surface.UvHeight / 2, 2);
using var chromaTop = mm.GetWritableRegion(ExtendOffset(chromaTopOffset), chromaSize);
using var chromaBottom = mm.GetWritableRegion(ExtendOffset(chromaBottomOffset), chromaSize);
using WritableRegion chromaTop = mm.GetWritableRegion(ExtendOffset(chromaTopOffset), chromaSize);
using WritableRegion chromaBottom = mm.GetWritableRegion(ExtendOffset(chromaBottomOffset), chromaSize);
WriteChroma(
chromaTop.Memory.Span,

View file

@ -36,7 +36,7 @@ namespace Ryujinx.Graphics.Nvdec
public void DestroyContext(long id)
{
if (_contexts.TryRemove(id, out var context))
if (_contexts.TryRemove(id, out NvdecDecoderContext context))
{
context.Dispose();
}
@ -46,7 +46,7 @@ namespace Ryujinx.Graphics.Nvdec
public void BindContext(long id)
{
if (_contexts.TryGetValue(id, out var context))
if (_contexts.TryGetValue(id, out NvdecDecoderContext context))
{
_currentContext = context;
}

View file

@ -4,6 +4,7 @@ using Ryujinx.Graphics.Nvdec.Image;
using Ryujinx.Graphics.Nvdec.Types.Vp9;
using Ryujinx.Graphics.Nvdec.Vp9;
using Ryujinx.Graphics.Video;
using Ryujinx.Memory;
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
@ -50,7 +51,7 @@ namespace Ryujinx.Graphics.Nvdec
int miCols = BitUtils.DivRoundUp(pictureInfo.CurrentFrameSize.Width, 8);
int miRows = BitUtils.DivRoundUp(pictureInfo.CurrentFrameSize.Height, 8);
using var mvsRegion = rm.MemoryManager.GetWritableRegion(ExtendOffset(state.Vp9SetColMvWriteBufOffset), miRows * miCols * 16);
using WritableRegion mvsRegion = rm.MemoryManager.GetWritableRegion(ExtendOffset(state.Vp9SetColMvWriteBufOffset), miRows * miCols * 16);
Span<Vp9MvRef> mvsOut = MemoryMarshal.Cast<byte, Vp9MvRef>(mvsRegion.Memory.Span);
@ -80,9 +81,9 @@ namespace Ryujinx.Graphics.Nvdec
private static void WriteBackwardUpdates(DeviceMemoryManager mm, uint offset, ref Vp9BackwardUpdates counts)
{
using var backwardUpdatesRegion = mm.GetWritableRegion(ExtendOffset(offset), Unsafe.SizeOf<BackwardUpdates>());
using WritableRegion backwardUpdatesRegion = mm.GetWritableRegion(ExtendOffset(offset), Unsafe.SizeOf<BackwardUpdates>());
ref var backwardUpdates = ref MemoryMarshal.Cast<byte, BackwardUpdates>(backwardUpdatesRegion.Memory.Span)[0];
ref BackwardUpdates backwardUpdates = ref MemoryMarshal.Cast<byte, BackwardUpdates>(backwardUpdatesRegion.Memory.Span)[0];
backwardUpdates = new BackwardUpdates(ref counts);
}