Compare commits

...

4 Commits

Author SHA1 Message Date
MNCHL
f89767cf8f Update build.gradle.kts 2023-12-05 22:23:24 +08:00
MNCHL
4f60f05ca7 Update DiskShaderCacheProgress.kt 2023-12-05 22:17:49 +08:00
yuzubot
7297cc1ad5 Android #151 2023-12-05 00:57:39 +00:00
yuzubot
7827ea76a3 Merge PR 12271 2023-12-05 00:57:39 +00:00
4 changed files with 52 additions and 21 deletions

View File

@@ -1,3 +1,12 @@
| Pull Request | Commit | Title | Author | Merged? |
|----|----|----|----|----|
| [12271](https://github.com/yuzu-emu/yuzu//pull/12271) | [`9de99839b`](https://github.com/yuzu-emu/yuzu//pull/12271/files) | nce: fix pre-text patch for single modules | [liamwhite](https://github.com/liamwhite/) | Yes |
End of merge log. You can find the original README.md below the break.
-----
<!--
SPDX-FileCopyrightText: 2018 yuzu Emulator Project
SPDX-License-Identifier: GPL-2.0-or-later

View File

@@ -207,6 +207,9 @@ ktlint {
}
dependencies {
implementation("androidx.annotation:annotation:1.3.0")
implementation("androidx.lifecycle:lifecycle-viewmodel:2.3.1")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.2")
implementation("androidx.core:core-ktx:1.12.0")
implementation("androidx.appcompat:appcompat:1.6.1")
implementation("androidx.recyclerview:recyclerview:1.3.1")

View File

@@ -5,46 +5,63 @@ package org.yuzu.yuzu_emu.disk_shader_cache
import androidx.annotation.Keep
import androidx.lifecycle.ViewModelProvider
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import org.yuzu.yuzu_emu.NativeLibrary
import org.yuzu.yuzu_emu.R
import org.yuzu.yuzu_emu.activities.EmulationActivity
import org.yuzu.yuzu_emu.model.EmulationViewModel
import org.yuzu.yuzu_emu.utils.Log
@Keep
object DiskShaderCacheProgress {
private lateinit var emulationViewModel: EmulationViewModel
private lateinit var emulationActivity: EmulationActivity
private fun prepareViewModel() {
emulationViewModel =
ViewModelProvider(
NativeLibrary.sEmulationActivity.get() as EmulationActivity
)[EmulationViewModel::class.java]
val activity = NativeLibrary.sEmulationActivity.get() as? EmulationActivity
?: throw IllegalStateException("EmulationActivity 不存在")
emulationActivity = activity
emulationViewModel = ViewModelProvider(emulationActivity)[EmulationViewModel::class.java]
}
@JvmStatic
fun loadProgress(stage: Int, progress: Int, max: Int) {
val emulationActivity = NativeLibrary.sEmulationActivity.get()
if (emulationActivity == null) {
Log.error("[DiskShaderCacheProgress] EmulationActivity not present")
return
}
val activity = NativeLibrary.sEmulationActivity.get() as? EmulationActivity
?: return
emulationActivity.runOnUiThread {
when (LoadCallbackStage.values()[stage]) {
LoadCallbackStage.Prepare -> prepareViewModel()
LoadCallbackStage.Build -> emulationViewModel.updateProgress(
emulationActivity.getString(R.string.building_shaders),
progress,
max
)
LoadCallbackStage.Complete -> {}
when (LoadCallbackStage.values()[stage]) {
LoadCallbackStage.Prepare -> {
prepareViewModel()
showMessage(activity.getString(R.string.prepare_loading_message))
}
LoadCallbackStage.Build -> {
GlobalScope.launch(Dispatchers.Main) {
updateProgressAsync(activity.getString(R.string.building_shaders), progress, max)
}
}
LoadCallbackStage.Complete -> {}
}
}
// Equivalent to VideoCore::LoadCallbackStage
private suspend fun updateProgressAsync(title: String, progress: Int, max: Int) {
withContext(Dispatchers.Main) {
showMessage("$title:异步进度执行中")
}
// 模拟一些处理时间
kotlinx.coroutines.delay(1000)
withContext(Dispatchers.Main) {
emulationViewModel.updateProgress(title, progress, max)
}
}
private fun showMessage(message: String) {
emulationActivity.showToast(message)
}
enum class LoadCallbackStage {
Prepare, Build, Complete
}

View File

@@ -28,6 +28,8 @@ Patcher::~Patcher() = default;
void Patcher::PatchText(const Kernel::PhysicalMemory& program_image,
const Kernel::CodeSet::Segment& code) {
// Branch to the first instruction of the module.
this->BranchToModule(0);
// Write save context helper function.
c.l(m_save_context);