drop game stats class. directly call stats methods

This commit is contained in:
Emmanuel Hansen 2023-07-08 20:02:18 +00:00
parent 953559c71c
commit 976514fdcc
4 changed files with 20 additions and 40 deletions

View File

@ -116,41 +116,28 @@ namespace LibRyujinx
ignoreMissingServices); ignoreMissingServices);
} }
[UnmanagedCallersOnly(EntryPoint = "Java_org_ryujinx_android_RyujinxNative_deviceGetGameStats")] [UnmanagedCallersOnly(EntryPoint = "Java_org_ryujinx_android_RyujinxNative_deviceGetGameFifo")]
public static JObjectLocalRef JniGetGameStats(JEnvRef jEnv, JObjectLocalRef jObj) public static JDouble JniGetGameFifo(JEnvRef jEnv, JObjectLocalRef jObj)
{ {
var stats = GetGameStats(); var stats = SwitchDevice.EmulationContext?.Statistics.GetFifoPercent() ?? 0;
var javaClassName = GetCCharSequence("org/ryujinx/android/viewmodels/GameStats"); return stats;
}
JEnvValue value = jEnv.Environment; [UnmanagedCallersOnly(EntryPoint = "Java_org_ryujinx_android_RyujinxNative_deviceGetGameFrameTime")]
ref JNativeInterface jInterface = ref value.Functions; public static JDouble JniGetGameFrameTime(JEnvRef jEnv, JObjectLocalRef jObj)
IntPtr findClassPtr = jInterface.FindClassPointer; {
IntPtr newGlobalRefPtr = jInterface.NewGlobalRefPointer; var stats = SwitchDevice.EmulationContext?.Statistics.GetGameFrameTime() ?? 0;
IntPtr getFieldIdPtr = jInterface.GetFieldIdPointer;
IntPtr getMethodPtr = jInterface.GetMethodIdPointer;
IntPtr newObjectPtr = jInterface.NewObjectPointer;
IntPtr setDoubleFieldPtr = jInterface.SetDoubleFieldPointer;
return stats;
}
var findClass = findClassPtr.GetUnsafeDelegate<FindClassDelegate>(); [UnmanagedCallersOnly(EntryPoint = "Java_org_ryujinx_android_RyujinxNative_deviceGetGameFrameRate")]
var newGlobalRef = newGlobalRefPtr.GetUnsafeDelegate<NewGlobalRefDelegate>(); public static JDouble JniGetGameFrameRate(JEnvRef jEnv, JObjectLocalRef jObj)
var getFieldId = getFieldIdPtr.GetUnsafeDelegate<GetFieldIdDelegate>(); {
var getMethod = getMethodPtr.GetUnsafeDelegate<GetMethodIdDelegate>(); var stats = SwitchDevice.EmulationContext?.Statistics.GetGameFrameRate() ?? 0;
var newObject = newObjectPtr.GetUnsafeDelegate<NewObjectDelegate>();
var setDoubleField = setDoubleFieldPtr.GetUnsafeDelegate<SetDoubleFieldDelegate>();
var javaClass = findClass(jEnv, javaClassName); return stats;
var newGlobal = newGlobalRef(jEnv, javaClass._value);
var constructor = getMethod(jEnv, javaClass, GetCCharSequence("<init>"), GetCCharSequence("()V"));
var newObj = newObject(jEnv, javaClass, constructor, 0);
setDoubleField(jEnv, newObj, getFieldId(jEnv, javaClass, GetCCharSequence("Fifo"), GetCCharSequence("D")), stats.Fifo);
setDoubleField(jEnv, newObj, getFieldId(jEnv, javaClass, GetCCharSequence("GameFps"), GetCCharSequence("D")), stats.GameFps);
setDoubleField(jEnv, newObj, getFieldId(jEnv, javaClass, GetCCharSequence("GameTime"), GetCCharSequence("D")), stats.GameTime);
return newObj;
} }
[UnmanagedCallersOnly(EntryPoint = "Java_org_ryujinx_android_RyujinxNative_deviceLoad")] [UnmanagedCallersOnly(EntryPoint = "Java_org_ryujinx_android_RyujinxNative_deviceLoad")]

View File

@ -152,8 +152,7 @@ class GameHost(context: Context?, val controller: GameController, val mainViewMo
c++ c++
if (c >= 1000) { if (c >= 1000) {
c = 0 c = 0
var stats = _nativeRyujinx.deviceGetGameStats() mainViewModel.updateStats(_nativeRyujinx.deviceGetGameFifo(), _nativeRyujinx.deviceGetGameFrameRate(), _nativeRyujinx.deviceGetGameFrameTime())
mainViewModel.updateStats(stats.Fifo, stats.GameFps, stats.GameTime)
} }
} }
} }

View File

@ -2,7 +2,6 @@ package org.ryujinx.android
import android.view.Surface import android.view.Surface
import org.ryujinx.android.viewmodels.GameInfo import org.ryujinx.android.viewmodels.GameInfo
import org.ryujinx.android.viewmodels.GameStats
import java.io.FileDescriptor import java.io.FileDescriptor
class RyujinxNative { class RyujinxNative {
@ -31,7 +30,9 @@ class RyujinxNative {
): Boolean ): Boolean
external fun deviceLoad(game: String): Boolean external fun deviceLoad(game: String): Boolean
external fun deviceGetGameStats(): GameStats external fun deviceGetGameFrameRate(): Double
external fun deviceGetGameFrameTime(): Double
external fun deviceGetGameFifo(): Double
external fun deviceGetGameInfo(fileDescriptor: Int, isXci:Boolean): GameInfo external fun deviceGetGameInfo(fileDescriptor: Int, isXci:Boolean): GameInfo
external fun deviceGetGameInfoFromPath(path: String): GameInfo external fun deviceGetGameInfoFromPath(path: String): GameInfo
external fun deviceLoadDescriptor(fileDescriptor: Int, isXci:Boolean): Boolean external fun deviceLoadDescriptor(fileDescriptor: Int, isXci:Boolean): Boolean

View File

@ -1,7 +0,0 @@
package org.ryujinx.android.viewmodels
class GameStats {
var Fifo = 0.0
var GameFps = 0.0
var GameTime = 0.0
}