early-access version 3705
This commit is contained in:
parent
6a7cbc0b6e
commit
b6463d97ba
6 changed files with 88 additions and 17 deletions
|
@ -1,7 +1,7 @@
|
||||||
yuzu emulator early access
|
yuzu emulator early access
|
||||||
=============
|
=============
|
||||||
|
|
||||||
This is the source code for early-access 3704.
|
This is the source code for early-access 3705.
|
||||||
|
|
||||||
## Legal Notice
|
## Legal Notice
|
||||||
|
|
||||||
|
|
|
@ -27,13 +27,13 @@ import android.view.MotionEvent
|
||||||
import android.view.Surface
|
import android.view.Surface
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.inputmethod.InputMethodManager
|
import android.view.inputmethod.InputMethodManager
|
||||||
|
import android.widget.Toast
|
||||||
import androidx.activity.viewModels
|
import androidx.activity.viewModels
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.core.view.WindowCompat
|
import androidx.core.view.WindowCompat
|
||||||
import androidx.core.view.WindowInsetsCompat
|
import androidx.core.view.WindowInsetsCompat
|
||||||
import androidx.core.view.WindowInsetsControllerCompat
|
import androidx.core.view.WindowInsetsControllerCompat
|
||||||
import androidx.navigation.fragment.NavHostFragment
|
import androidx.navigation.fragment.NavHostFragment
|
||||||
import kotlin.math.roundToInt
|
|
||||||
import org.yuzu.yuzu_emu.NativeLibrary
|
import org.yuzu.yuzu_emu.NativeLibrary
|
||||||
import org.yuzu.yuzu_emu.R
|
import org.yuzu.yuzu_emu.R
|
||||||
import org.yuzu.yuzu_emu.databinding.ActivityEmulationBinding
|
import org.yuzu.yuzu_emu.databinding.ActivityEmulationBinding
|
||||||
|
@ -44,8 +44,10 @@ import org.yuzu.yuzu_emu.model.Game
|
||||||
import org.yuzu.yuzu_emu.utils.ControllerMappingHelper
|
import org.yuzu.yuzu_emu.utils.ControllerMappingHelper
|
||||||
import org.yuzu.yuzu_emu.utils.ForegroundService
|
import org.yuzu.yuzu_emu.utils.ForegroundService
|
||||||
import org.yuzu.yuzu_emu.utils.InputHandler
|
import org.yuzu.yuzu_emu.utils.InputHandler
|
||||||
|
import org.yuzu.yuzu_emu.utils.MemoryUtil
|
||||||
import org.yuzu.yuzu_emu.utils.NfcReader
|
import org.yuzu.yuzu_emu.utils.NfcReader
|
||||||
import org.yuzu.yuzu_emu.utils.ThemeHelper
|
import org.yuzu.yuzu_emu.utils.ThemeHelper
|
||||||
|
import kotlin.math.roundToInt
|
||||||
|
|
||||||
class EmulationActivity : AppCompatActivity(), SensorEventListener {
|
class EmulationActivity : AppCompatActivity(), SensorEventListener {
|
||||||
private lateinit var binding: ActivityEmulationBinding
|
private lateinit var binding: ActivityEmulationBinding
|
||||||
|
@ -102,6 +104,19 @@ class EmulationActivity : AppCompatActivity(), SensorEventListener {
|
||||||
inputHandler = InputHandler()
|
inputHandler = InputHandler()
|
||||||
inputHandler.initialize()
|
inputHandler.initialize()
|
||||||
|
|
||||||
|
val memoryUtil = MemoryUtil(this)
|
||||||
|
if (memoryUtil.isLessThan(8, MemoryUtil.Gb)) {
|
||||||
|
Toast.makeText(
|
||||||
|
this,
|
||||||
|
getString(
|
||||||
|
R.string.device_memory_inadequate,
|
||||||
|
memoryUtil.getDeviceRAM(),
|
||||||
|
"8 ${getString(R.string.memory_gigabyte)}"
|
||||||
|
),
|
||||||
|
Toast.LENGTH_LONG
|
||||||
|
).show()
|
||||||
|
}
|
||||||
|
|
||||||
// Start a foreground service to prevent the app from getting killed in the background
|
// Start a foreground service to prevent the app from getting killed in the background
|
||||||
val startIntent = Intent(this, ForegroundService::class.java)
|
val startIntent = Intent(this, ForegroundService::class.java)
|
||||||
startForegroundService(startIntent)
|
startForegroundService(startIntent)
|
||||||
|
|
59
src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/MemoryUtil.kt
Executable file
59
src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/MemoryUtil.kt
Executable file
|
@ -0,0 +1,59 @@
|
||||||
|
// SPDX-FileCopyrightText: 2023 yuzu Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
package org.yuzu.yuzu_emu.utils
|
||||||
|
|
||||||
|
import android.app.ActivityManager
|
||||||
|
import android.content.Context
|
||||||
|
import org.yuzu.yuzu_emu.R
|
||||||
|
import java.util.Locale
|
||||||
|
|
||||||
|
class MemoryUtil(val context: Context) {
|
||||||
|
|
||||||
|
private val Long.floatForm: String
|
||||||
|
get() = String.format(Locale.ROOT, "%.2f", this.toDouble())
|
||||||
|
|
||||||
|
private fun bytesToSizeUnit(size: Long): String {
|
||||||
|
return when {
|
||||||
|
size < Kb -> "${size.floatForm} ${context.getString(R.string.memory_byte)}"
|
||||||
|
size < Mb -> "${(size / Kb).floatForm} ${context.getString(R.string.memory_kilobyte)}"
|
||||||
|
size < Gb -> "${(size / Mb).floatForm} ${context.getString(R.string.memory_megabyte)}"
|
||||||
|
size < Tb -> "${(size / Gb).floatForm} ${context.getString(R.string.memory_gigabyte)}"
|
||||||
|
size < Pb -> "${(size / Tb).floatForm} ${context.getString(R.string.memory_terabyte)}"
|
||||||
|
size < Eb -> "${(size / Pb).floatForm} ${context.getString(R.string.memory_petabyte)}"
|
||||||
|
else -> "${(size / Eb).floatForm} ${context.getString(R.string.memory_exabyte)}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private val totalMemory =
|
||||||
|
with(context.getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager) {
|
||||||
|
val memInfo = ActivityManager.MemoryInfo()
|
||||||
|
getMemoryInfo(memInfo)
|
||||||
|
memInfo.totalMem
|
||||||
|
}
|
||||||
|
|
||||||
|
fun isLessThan(minimum: Int, size: Long): Boolean {
|
||||||
|
return when (size) {
|
||||||
|
Kb -> totalMemory < Mb && totalMemory < minimum
|
||||||
|
Mb -> totalMemory < Gb && (totalMemory / Mb) < minimum
|
||||||
|
Gb -> totalMemory < Tb && (totalMemory / Gb) < minimum
|
||||||
|
Tb -> totalMemory < Pb && (totalMemory / Tb) < minimum
|
||||||
|
Pb -> totalMemory < Eb && (totalMemory / Pb) < minimum
|
||||||
|
Eb -> totalMemory / Eb < minimum
|
||||||
|
else -> totalMemory < Kb && totalMemory < minimum
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getDeviceRAM(): String {
|
||||||
|
return bytesToSizeUnit(totalMemory)
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
const val Kb: Long = 1024
|
||||||
|
const val Mb = Kb * 1024
|
||||||
|
const val Gb = Mb * 1024
|
||||||
|
const val Tb = Gb * 1024
|
||||||
|
const val Pb = Tb * 1024
|
||||||
|
const val Eb = Pb * 1024
|
||||||
|
}
|
||||||
|
}
|
|
@ -237,6 +237,7 @@ public:
|
||||||
m_software_keyboard = android_keyboard.get();
|
m_software_keyboard = android_keyboard.get();
|
||||||
m_system.SetShuttingDown(false);
|
m_system.SetShuttingDown(false);
|
||||||
m_system.ApplySettings();
|
m_system.ApplySettings();
|
||||||
|
Settings::LogSettings();
|
||||||
m_system.HIDCore().ReloadInputDevices();
|
m_system.HIDCore().ReloadInputDevices();
|
||||||
m_system.SetAppletFrontendSet({
|
m_system.SetAppletFrontendSet({
|
||||||
nullptr, // Amiibo Settings
|
nullptr, // Amiibo Settings
|
||||||
|
|
|
@ -270,6 +270,7 @@
|
||||||
<string name="fatal_error">Fatal Error</string>
|
<string name="fatal_error">Fatal Error</string>
|
||||||
<string name="fatal_error_message">A fatal error occurred. Check the log for details.\nContinuing emulation may result in crashes and bugs.</string>
|
<string name="fatal_error_message">A fatal error occurred. Check the log for details.\nContinuing emulation may result in crashes and bugs.</string>
|
||||||
<string name="performance_warning">Turning off this setting will significantly reduce emulation performance! For the best experience, it is recommended that you leave this setting enabled.</string>
|
<string name="performance_warning">Turning off this setting will significantly reduce emulation performance! For the best experience, it is recommended that you leave this setting enabled.</string>
|
||||||
|
<string name="device_memory_inadequate">Device RAM: %1$s\nRecommended: %2$s</string>
|
||||||
|
|
||||||
<!-- Region Names -->
|
<!-- Region Names -->
|
||||||
<string name="region_japan">Japan</string>
|
<string name="region_japan">Japan</string>
|
||||||
|
@ -300,6 +301,15 @@
|
||||||
<string name="language_traditional_chinese">Traditional Chinese (正體中文)</string>
|
<string name="language_traditional_chinese">Traditional Chinese (正體中文)</string>
|
||||||
<string name="language_brazilian_portuguese">Brazilian Portuguese (Português do Brasil)</string>
|
<string name="language_brazilian_portuguese">Brazilian Portuguese (Português do Brasil)</string>
|
||||||
|
|
||||||
|
<!-- Memory Sizes -->
|
||||||
|
<string name="memory_byte">Byte</string>
|
||||||
|
<string name="memory_kilobyte">KB</string>
|
||||||
|
<string name="memory_megabyte">MB</string>
|
||||||
|
<string name="memory_gigabyte">GB</string>
|
||||||
|
<string name="memory_terabyte">TB</string>
|
||||||
|
<string name="memory_petabyte">PB</string>
|
||||||
|
<string name="memory_exabyte">EB</string>
|
||||||
|
|
||||||
<!-- Renderer APIs -->
|
<!-- Renderer APIs -->
|
||||||
<string name="renderer_vulkan">Vulkan</string>
|
<string name="renderer_vulkan">Vulkan</string>
|
||||||
<string name="renderer_none">None</string>
|
<string name="renderer_none">None</string>
|
||||||
|
|
|
@ -59,20 +59,6 @@ struct Range {
|
||||||
return VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT;
|
return VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] VkMemoryPropertyFlags MemoryUsageRequiredVmaFlags(MemoryUsage usage) {
|
|
||||||
switch (usage) {
|
|
||||||
case MemoryUsage::DeviceLocal:
|
|
||||||
return VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT;
|
|
||||||
case MemoryUsage::Upload:
|
|
||||||
case MemoryUsage::Stream:
|
|
||||||
return VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT;
|
|
||||||
case MemoryUsage::Download:
|
|
||||||
return VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_CACHED_BIT;
|
|
||||||
}
|
|
||||||
ASSERT_MSG(false, "Invalid memory usage={}", usage);
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
|
|
||||||
[[nodiscard]] VkMemoryPropertyFlags MemoryUsagePreferedVmaFlags(MemoryUsage usage) {
|
[[nodiscard]] VkMemoryPropertyFlags MemoryUsagePreferedVmaFlags(MemoryUsage usage) {
|
||||||
return usage != MemoryUsage::DeviceLocal ? VK_MEMORY_PROPERTY_HOST_COHERENT_BIT
|
return usage != MemoryUsage::DeviceLocal ? VK_MEMORY_PROPERTY_HOST_COHERENT_BIT
|
||||||
: VkMemoryPropertyFlagBits{};
|
: VkMemoryPropertyFlagBits{};
|
||||||
|
@ -259,7 +245,7 @@ vk::Buffer MemoryAllocator::CreateBuffer(const VkBufferCreateInfo& ci, MemoryUsa
|
||||||
.flags = VMA_ALLOCATION_CREATE_WITHIN_BUDGET_BIT | VMA_ALLOCATION_CREATE_MAPPED_BIT |
|
.flags = VMA_ALLOCATION_CREATE_WITHIN_BUDGET_BIT | VMA_ALLOCATION_CREATE_MAPPED_BIT |
|
||||||
MemoryUsageVmaFlags(usage),
|
MemoryUsageVmaFlags(usage),
|
||||||
.usage = MemoryUsageVma(usage),
|
.usage = MemoryUsageVma(usage),
|
||||||
.requiredFlags = MemoryUsageRequiredVmaFlags(usage),
|
.requiredFlags = 0,
|
||||||
.preferredFlags = MemoryUsagePreferedVmaFlags(usage),
|
.preferredFlags = MemoryUsagePreferedVmaFlags(usage),
|
||||||
.memoryTypeBits = 0,
|
.memoryTypeBits = 0,
|
||||||
.pool = VK_NULL_HANDLE,
|
.pool = VK_NULL_HANDLE,
|
||||||
|
|
Loading…
Reference in a new issue