misc: chore: Use explicit types in GPU, Device, and Host1x projects

This commit is contained in:
Evan Husted 2025-01-25 14:05:44 -06:00
parent 5099548856
commit 1ae349efb1
55 changed files with 350 additions and 339 deletions

View file

@ -2,6 +2,7 @@ using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
@ -32,15 +33,15 @@ namespace Ryujinx.Graphics.Device
_debugLogCallback = debugLogCallback;
}
var fields = typeof(TState).GetFields();
FieldInfo[] fields = typeof(TState).GetFields();
int offset = 0;
for (int fieldIndex = 0; fieldIndex < fields.Length; fieldIndex++)
{
var field = fields[fieldIndex];
FieldInfo field = fields[fieldIndex];
var currentFieldOffset = (int)Marshal.OffsetOf<TState>(field.Name);
var nextFieldOffset = fieldIndex + 1 == fields.Length ? Unsafe.SizeOf<TState>() : (int)Marshal.OffsetOf<TState>(fields[fieldIndex + 1].Name);
int currentFieldOffset = (int)Marshal.OffsetOf<TState>(field.Name);
int nextFieldOffset = fieldIndex + 1 == fields.Length ? Unsafe.SizeOf<TState>() : (int)Marshal.OffsetOf<TState>(fields[fieldIndex + 1].Name);
int sizeOfField = nextFieldOffset - currentFieldOffset;
@ -48,7 +49,7 @@ namespace Ryujinx.Graphics.Device
{
int index = (offset + i) / RegisterSize;
if (callbacks != null && callbacks.TryGetValue(field.Name, out var cb))
if (callbacks != null && callbacks.TryGetValue(field.Name, out RwCallback cb))
{
if (cb.Read != null)
{
@ -81,7 +82,7 @@ namespace Ryujinx.Graphics.Device
{
uint alignedOffset = index * RegisterSize;
var readCallback = Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(_readCallbacks), (nint)index);
Func<int> readCallback = Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(_readCallbacks), (nint)index);
if (readCallback != null)
{
return readCallback();
@ -119,7 +120,7 @@ namespace Ryujinx.Graphics.Device
uint alignedOffset = index * RegisterSize;
DebugWrite(alignedOffset, data);
ref var storage = ref GetRefIntAlignedUncheck(index);
ref int storage = ref GetRefIntAlignedUncheck(index);
changed = storage != data;
storage = data;