mirror of
https://git.eden-emu.dev/eden-emu/eden.git
synced 2026-09-27 19:26:52 +00:00
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e7e8bd7b1a | |||
| 07c6eeaabd | |||
| 29293295d4 | |||
| 2a37ed8e15 | |||
| 9ba0d4a541 | |||
| 150c2a53a8 | |||
| 85eb750d2e |
@@ -333,11 +333,6 @@
|
|||||||
"repo": "herumi/xbyak",
|
"repo": "herumi/xbyak",
|
||||||
"version": "v7.40.1"
|
"version": "v7.40.1"
|
||||||
},
|
},
|
||||||
"zbic": {
|
|
||||||
"hash": "fbe2f37986377d7f0d96ae3224c80b5971df6e8b6961f68061f1975ebb2e8cb78f07b90f014b007be4023dbf5513581504e7f7d61a5237cb2a8a7a61ae11e482",
|
|
||||||
"repo": "kinnay/zbic",
|
|
||||||
"version": "11b08f2712264bbed731545085cbd9702096ceb7"
|
|
||||||
},
|
|
||||||
"zlib": {
|
"zlib": {
|
||||||
"hash": "16fea4df307a68cf0035858abe2fd550250618a97590e202037acd18a666f57afc10f8836cbbd472d54a0e76539d0e558cb26f059d53de52ff90634bbf4f47d4",
|
"hash": "16fea4df307a68cf0035858abe2fd550250618a97590e202037acd18a666f57afc10f8836cbbd472d54a0e76539d0e558cb26f059d53de52ff90634bbf4f47d4",
|
||||||
"min_version": "1.2",
|
"min_version": "1.2",
|
||||||
|
|||||||
Vendored
-5
@@ -48,11 +48,6 @@ if (NOT TARGET stb::headers)
|
|||||||
add_library(stb::headers ALIAS stb)
|
add_library(stb::headers ALIAS stb)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
AddJsonPackage(NAME zbic DOWNLOAD_ONLY)
|
|
||||||
set(ZBIC_INCLUDE_DIR
|
|
||||||
"${zbic_SOURCE_DIR}/src"
|
|
||||||
PARENT_SCOPE)
|
|
||||||
|
|
||||||
# ItaniumDemangle (Windows only)
|
# ItaniumDemangle (Windows only)
|
||||||
if (WIN32 AND NOT TARGET LLVM::Demangle)
|
if (WIN32 AND NOT TARGET LLVM::Demangle)
|
||||||
add_library(demangle demangle/ItaniumDemangle.cpp)
|
add_library(demangle demangle/ItaniumDemangle.cpp)
|
||||||
|
|||||||
+1
@@ -30,6 +30,7 @@ enum class BooleanSetting(override val key: String) : AbstractBooleanSetting {
|
|||||||
RENDERER_REACTIVE_FLUSHING("use_reactive_flushing"),
|
RENDERER_REACTIVE_FLUSHING("use_reactive_flushing"),
|
||||||
ENABLE_BUFFER_HISTORY("enable_buffer_history"),
|
ENABLE_BUFFER_HISTORY("enable_buffer_history"),
|
||||||
USE_OPTIMIZED_VERTEX_BUFFERS("use_optimized_vertex_buffers"),
|
USE_OPTIMIZED_VERTEX_BUFFERS("use_optimized_vertex_buffers"),
|
||||||
|
ENABLE_GPU_BUFFER_READBACK("enable_gpu_buffer_readback"),
|
||||||
SYNC_MEMORY_OPERATIONS("sync_memory_operations"),
|
SYNC_MEMORY_OPERATIONS("sync_memory_operations"),
|
||||||
BUFFER_REORDER_DISABLE("disable_buffer_reorder"),
|
BUFFER_REORDER_DISABLE("disable_buffer_reorder"),
|
||||||
RENDERER_DEBUG("debug"),
|
RENDERER_DEBUG("debug"),
|
||||||
|
|||||||
+7
@@ -908,6 +908,13 @@ abstract class SettingsItem(
|
|||||||
descriptionId = R.string.enable_buffer_history_description
|
descriptionId = R.string.enable_buffer_history_description
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
put(
|
||||||
|
SwitchSetting(
|
||||||
|
BooleanSetting.ENABLE_GPU_BUFFER_READBACK,
|
||||||
|
titleId = R.string.enable_gpu_buffer_readback,
|
||||||
|
descriptionId = R.string.enable_gpu_buffer_readback_description
|
||||||
|
)
|
||||||
|
)
|
||||||
put(
|
put(
|
||||||
SwitchSetting(
|
SwitchSetting(
|
||||||
BooleanSetting.USE_OPTIMIZED_VERTEX_BUFFERS,
|
BooleanSetting.USE_OPTIMIZED_VERTEX_BUFFERS,
|
||||||
|
|||||||
+1
@@ -549,6 +549,7 @@ class SettingsFragmentPresenter(
|
|||||||
add(BooleanSetting.RENDERER_FORCE_MAX_CLOCK.key)
|
add(BooleanSetting.RENDERER_FORCE_MAX_CLOCK.key)
|
||||||
add(BooleanSetting.RENDERER_REACTIVE_FLUSHING.key)
|
add(BooleanSetting.RENDERER_REACTIVE_FLUSHING.key)
|
||||||
add(BooleanSetting.ENABLE_BUFFER_HISTORY.key)
|
add(BooleanSetting.ENABLE_BUFFER_HISTORY.key)
|
||||||
|
add(BooleanSetting.ENABLE_GPU_BUFFER_READBACK.key)
|
||||||
add(BooleanSetting.USE_OPTIMIZED_VERTEX_BUFFERS.key)
|
add(BooleanSetting.USE_OPTIMIZED_VERTEX_BUFFERS.key)
|
||||||
|
|
||||||
add(HeaderSetting(R.string.hacks))
|
add(HeaderSetting(R.string.hacks))
|
||||||
|
|||||||
@@ -580,6 +580,8 @@
|
|||||||
<string name="renderer_reactive_flushing_description">يحسن دقة العرض في بعض الألعاب على حساب الأداء.</string>
|
<string name="renderer_reactive_flushing_description">يحسن دقة العرض في بعض الألعاب على حساب الأداء.</string>
|
||||||
<string name="enable_buffer_history">تمكين سجل التخزين المؤقت</string>
|
<string name="enable_buffer_history">تمكين سجل التخزين المؤقت</string>
|
||||||
<string name="enable_buffer_history_description">يُتيح هذا الخيار الوصول إلى حالات التخزين المؤقت السابقة. وقد يُحسّن جودة العرض وثبات الأداء في بعض الألعاب.</string>
|
<string name="enable_buffer_history_description">يُتيح هذا الخيار الوصول إلى حالات التخزين المؤقت السابقة. وقد يُحسّن جودة العرض وثبات الأداء في بعض الألعاب.</string>
|
||||||
|
<string name="enable_gpu_buffer_readback">تفعيل قراءة مخزن وحدة معالجة الرسومات</string>
|
||||||
|
<string name="enable_gpu_buffer_readback_description">يحافظ هذا النظام على بيانات المخزن المؤقت المُعدّلة بواسطة وحدة معالجة الرسومات عن طريق قراءتها مرة أخرى قبل التحميل. تتطلب بعض الألعاب ذلك لعرض بعض التأثيرات بشكل صحيح. قد يُسبب ذلك مشاكل إذا لم يتمكن الجهاز من التعامل مع عبء العمل الإضافي.</string>
|
||||||
<string name="use_optimized_vertex_buffers">مخازن الرؤوس المُحسّنة</string>
|
<string name="use_optimized_vertex_buffers">مخازن الرؤوس المُحسّنة</string>
|
||||||
<string name="use_optimized_vertex_buffers_description">يُتيح ربطًا مُحسَّنًا لمخازن الرؤوس لتحسين الأداء. يتطلب برامج تشغيل Mesa 26.0+ Turnip/ برامج تشغيل QCOM. قد يتعطل على برامج تشغيل Turnip القديمة (25.3 وما دون).</string>
|
<string name="use_optimized_vertex_buffers_description">يُتيح ربطًا مُحسَّنًا لمخازن الرؤوس لتحسين الأداء. يتطلب برامج تشغيل Mesa 26.0+ Turnip/ برامج تشغيل QCOM. قد يتعطل على برامج تشغيل Turnip القديمة (25.3 وما دون).</string>
|
||||||
|
|
||||||
@@ -1097,6 +1099,7 @@
|
|||||||
<string name="gpu_fence_behavior_immediate">فوري</string>
|
<string name="gpu_fence_behavior_immediate">فوري</string>
|
||||||
<string name="gpu_fence_behavior_balanced">متوازن</string>
|
<string name="gpu_fence_behavior_balanced">متوازن</string>
|
||||||
<string name="gpu_fence_behavior_accurate">دقيق</string>
|
<string name="gpu_fence_behavior_accurate">دقيق</string>
|
||||||
|
<string name="gpu_fence_behavior_strict">صارم</string>
|
||||||
|
|
||||||
<string name="vram_usage_conservative">محافظ</string>
|
<string name="vram_usage_conservative">محافظ</string>
|
||||||
<string name="vram_usage_aggressive">عدواني</string>
|
<string name="vram_usage_aggressive">عدواني</string>
|
||||||
|
|||||||
@@ -967,6 +967,7 @@ Wirklich fortfahren?</string>
|
|||||||
<string name="gpu_fence_behavior_immediate">Direkt</string>
|
<string name="gpu_fence_behavior_immediate">Direkt</string>
|
||||||
<string name="gpu_fence_behavior_balanced">Ausgewogen</string>
|
<string name="gpu_fence_behavior_balanced">Ausgewogen</string>
|
||||||
<string name="gpu_fence_behavior_accurate">Genau</string>
|
<string name="gpu_fence_behavior_accurate">Genau</string>
|
||||||
|
<string name="gpu_fence_behavior_strict">Strikt</string>
|
||||||
|
|
||||||
<string name="vram_usage_conservative">Konservativ</string>
|
<string name="vram_usage_conservative">Konservativ</string>
|
||||||
<string name="vram_usage_aggressive">Aggressiv</string>
|
<string name="vram_usage_aggressive">Aggressiv</string>
|
||||||
|
|||||||
@@ -524,6 +524,8 @@
|
|||||||
<string name="renderer_reactive_flushing_description">Mejora la precisión de renderizado en algunos juegos, pero reduce el rendimiento.</string>
|
<string name="renderer_reactive_flushing_description">Mejora la precisión de renderizado en algunos juegos, pero reduce el rendimiento.</string>
|
||||||
<string name="enable_buffer_history">Activar el historial del búfer</string>
|
<string name="enable_buffer_history">Activar el historial del búfer</string>
|
||||||
<string name="enable_buffer_history_description">Permite el acceso al estado del búfer anterior. Esta opción puede mejorar la calidad de renderizado y la consistencia en el rendimiento de algunos juegos.</string>
|
<string name="enable_buffer_history_description">Permite el acceso al estado del búfer anterior. Esta opción puede mejorar la calidad de renderizado y la consistencia en el rendimiento de algunos juegos.</string>
|
||||||
|
<string name="enable_gpu_buffer_readback">Activar la lectura del buffer de la GPU</string>
|
||||||
|
<string name="enable_gpu_buffer_readback_description">Conserva los datos del búfer modificados por la GPU leyéndolos antes de subirlos.\nAlgunos juegos requieren esto para renderizar correctamente ciertos efectos.\nPuede causar problemas si el hardware no puede soportar la carga de trabajo adicional.</string>
|
||||||
<string name="use_optimized_vertex_buffers">Búferes de vértices optimizados</string>
|
<string name="use_optimized_vertex_buffers">Búferes de vértices optimizados</string>
|
||||||
<string name="use_optimized_vertex_buffers_description">Permite la optimización del enlace del búfer de vértices para un mejor rendimiento. Requiere controladores Mesa 26.0+ Turnip/ controladores QCOM. Fallará con controladores Turnip más antiguos (versión 25.3 o inferior).</string>
|
<string name="use_optimized_vertex_buffers_description">Permite la optimización del enlace del búfer de vértices para un mejor rendimiento. Requiere controladores Mesa 26.0+ Turnip/ controladores QCOM. Fallará con controladores Turnip más antiguos (versión 25.3 o inferior).</string>
|
||||||
|
|
||||||
@@ -1036,6 +1038,7 @@
|
|||||||
<string name="gpu_fence_behavior_immediate">Inmediato</string>
|
<string name="gpu_fence_behavior_immediate">Inmediato</string>
|
||||||
<string name="gpu_fence_behavior_balanced">Equilibrado</string>
|
<string name="gpu_fence_behavior_balanced">Equilibrado</string>
|
||||||
<string name="gpu_fence_behavior_accurate">Preciso</string>
|
<string name="gpu_fence_behavior_accurate">Preciso</string>
|
||||||
|
<string name="gpu_fence_behavior_strict">Estricto</string>
|
||||||
|
|
||||||
<string name="vram_usage_conservative">Conservador</string>
|
<string name="vram_usage_conservative">Conservador</string>
|
||||||
<string name="vram_usage_aggressive">Agresivo</string>
|
<string name="vram_usage_aggressive">Agresivo</string>
|
||||||
|
|||||||
@@ -569,6 +569,8 @@
|
|||||||
<string name="renderer_reactive_flushing_description">Повышение точности рендеринга в некоторых играх за счет снижения производительности.</string>
|
<string name="renderer_reactive_flushing_description">Повышение точности рендеринга в некоторых играх за счет снижения производительности.</string>
|
||||||
<string name="enable_buffer_history">Включить историю буфера</string>
|
<string name="enable_buffer_history">Включить историю буфера</string>
|
||||||
<string name="enable_buffer_history_description">Позволяет обращаться к предыдущим состояниям буфера. Эта опция может повысить качество рендеринга и стабильность производительности в некоторых играх.</string>
|
<string name="enable_buffer_history_description">Позволяет обращаться к предыдущим состояниям буфера. Эта опция может повысить качество рендеринга и стабильность производительности в некоторых играх.</string>
|
||||||
|
<string name="enable_gpu_buffer_readback">Включить обратное чтение буфера ГПУ</string>
|
||||||
|
<string name="enable_gpu_buffer_readback_description">Сохраняет измененные ГПУ данные буфера путем чтения их обратно перед выгрузками. Некоторые игры требуют этого, чтобы рендерить определенные эффекты правильно. Может вызывать проблемы если оборудование не может обработать дополнительную рабочую нагрузку.</string>
|
||||||
<string name="use_optimized_vertex_buffers">Оптимизированные вершинные буферы</string>
|
<string name="use_optimized_vertex_buffers">Оптимизированные вершинные буферы</string>
|
||||||
<string name="use_optimized_vertex_buffers_description">Включает оптимизированную привязку вершинного буфера для повышения производительности. Требует Mesa Turnip 26.0+ / QCOM. Приводит к вылету на старых версиях драйверов Turnip (25.3 и ниже).</string>
|
<string name="use_optimized_vertex_buffers_description">Включает оптимизированную привязку вершинного буфера для повышения производительности. Требует Mesa Turnip 26.0+ / QCOM. Приводит к вылету на старых версиях драйверов Turnip (25.3 и ниже).</string>
|
||||||
|
|
||||||
@@ -1086,6 +1088,7 @@
|
|||||||
<string name="gpu_fence_behavior_immediate">Мгновенный</string>
|
<string name="gpu_fence_behavior_immediate">Мгновенный</string>
|
||||||
<string name="gpu_fence_behavior_balanced">Сбалансированный</string>
|
<string name="gpu_fence_behavior_balanced">Сбалансированный</string>
|
||||||
<string name="gpu_fence_behavior_accurate">Точный</string>
|
<string name="gpu_fence_behavior_accurate">Точный</string>
|
||||||
|
<string name="gpu_fence_behavior_strict">Строгий</string>
|
||||||
|
|
||||||
<string name="vram_usage_conservative">Консервативный</string>
|
<string name="vram_usage_conservative">Консервативный</string>
|
||||||
<string name="vram_usage_aggressive">Агрессивный</string>
|
<string name="vram_usage_aggressive">Агрессивный</string>
|
||||||
|
|||||||
@@ -570,6 +570,8 @@
|
|||||||
<string name="renderer_reactive_flushing_description">通过牺牲性能来提升某些游戏的渲染精度。</string>
|
<string name="renderer_reactive_flushing_description">通过牺牲性能来提升某些游戏的渲染精度。</string>
|
||||||
<string name="enable_buffer_history">启用缓冲区历史</string>
|
<string name="enable_buffer_history">启用缓冲区历史</string>
|
||||||
<string name="enable_buffer_history_description">启用对先前缓冲区状态的访问。此选项可在某些游戏中提升渲染质量并保持性能的一致性。</string>
|
<string name="enable_buffer_history_description">启用对先前缓冲区状态的访问。此选项可在某些游戏中提升渲染质量并保持性能的一致性。</string>
|
||||||
|
<string name="enable_gpu_buffer_readback">启用 GPU 缓冲区回读</string>
|
||||||
|
<string name="enable_gpu_buffer_readback_description">在上传前回读经由 GPU 修改过的缓冲区数据,以将其保留。一些游戏会用到这项设定以正确渲染某些效果。如果硬件无法处理额外的工作负载,则可能会导致问题。</string>
|
||||||
<string name="use_optimized_vertex_buffers">优化顶点缓冲区</string>
|
<string name="use_optimized_vertex_buffers">优化顶点缓冲区</string>
|
||||||
<string name="use_optimized_vertex_buffers_description">启用经过优化的顶点缓冲区绑定以提升性能。需要 Mesa 26.0 及以上版本的 Turnip 或 QCOM 驱动程序。若使用较旧版本的 Turnip 驱动 (25.3 及以下版本) 则会导致崩溃。</string>
|
<string name="use_optimized_vertex_buffers_description">启用经过优化的顶点缓冲区绑定以提升性能。需要 Mesa 26.0 及以上版本的 Turnip 或 QCOM 驱动程序。若使用较旧版本的 Turnip 驱动 (25.3 及以下版本) 则会导致崩溃。</string>
|
||||||
|
|
||||||
@@ -1087,6 +1089,7 @@
|
|||||||
<string name="gpu_fence_behavior_immediate">即时</string>
|
<string name="gpu_fence_behavior_immediate">即时</string>
|
||||||
<string name="gpu_fence_behavior_balanced">均衡</string>
|
<string name="gpu_fence_behavior_balanced">均衡</string>
|
||||||
<string name="gpu_fence_behavior_accurate">精确</string>
|
<string name="gpu_fence_behavior_accurate">精确</string>
|
||||||
|
<string name="gpu_fence_behavior_strict">严格</string>
|
||||||
|
|
||||||
<string name="vram_usage_conservative">保守式</string>
|
<string name="vram_usage_conservative">保守式</string>
|
||||||
<string name="vram_usage_aggressive">主动式</string>
|
<string name="vram_usage_aggressive">主动式</string>
|
||||||
|
|||||||
@@ -561,6 +561,8 @@
|
|||||||
<string name="renderer_reactive_flushing_description">犧牲效能,以改善部分遊戲的轉譯準確度</string>
|
<string name="renderer_reactive_flushing_description">犧牲效能,以改善部分遊戲的轉譯準確度</string>
|
||||||
<string name="enable_buffer_history">啟用緩衝區歷史</string>
|
<string name="enable_buffer_history">啟用緩衝區歷史</string>
|
||||||
<string name="enable_buffer_history_description">允許存取先前的緩衝區狀態。此選項可能會改善部分遊戲的渲染品質與效能穩定性</string>
|
<string name="enable_buffer_history_description">允許存取先前的緩衝區狀態。此選項可能會改善部分遊戲的渲染品質與效能穩定性</string>
|
||||||
|
<string name="enable_gpu_buffer_readback">啟用 GPU 緩衝區讀回</string>
|
||||||
|
<string name="enable_gpu_buffer_readback_description">透過在上傳之前先將 GPU 修改過的緩衝區資料讀回來保存資料,部分遊戲需要啟用此功能才能正常渲染遊戲特效。如果硬體無法負荷可能會導致錯誤</string>
|
||||||
<string name="use_optimized_vertex_buffers">最佳化頂點緩衝區</string>
|
<string name="use_optimized_vertex_buffers">最佳化頂點緩衝區</string>
|
||||||
<string name="use_optimized_vertex_buffers_description">啟用最佳化的頂點緩衝區綁定。需要安裝 Mesa 26.0+ Turnip drivers/Qualcomm drivers。使用舊版 Turnip drivers 會導致當機 (25.3版和更低的版本)</string>
|
<string name="use_optimized_vertex_buffers_description">啟用最佳化的頂點緩衝區綁定。需要安裝 Mesa 26.0+ Turnip drivers/Qualcomm drivers。使用舊版 Turnip drivers 會導致當機 (25.3版和更低的版本)</string>
|
||||||
|
|
||||||
|
|||||||
@@ -558,6 +558,7 @@
|
|||||||
<item>@string/gpu_fence_behavior_immediate</item>
|
<item>@string/gpu_fence_behavior_immediate</item>
|
||||||
<item>@string/gpu_fence_behavior_balanced</item>
|
<item>@string/gpu_fence_behavior_balanced</item>
|
||||||
<item>@string/gpu_fence_behavior_accurate</item>
|
<item>@string/gpu_fence_behavior_accurate</item>
|
||||||
|
<item>@string/gpu_fence_behavior_strict</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
<integer-array name="gpuFenceBehaviorValues">
|
<integer-array name="gpuFenceBehaviorValues">
|
||||||
<item>0</item>
|
<item>0</item>
|
||||||
|
|||||||
@@ -586,6 +586,8 @@
|
|||||||
<string name="renderer_reactive_flushing_description">Improves rendering accuracy in some games at the cost of performance.</string>
|
<string name="renderer_reactive_flushing_description">Improves rendering accuracy in some games at the cost of performance.</string>
|
||||||
<string name="enable_buffer_history">Enable buffer history</string>
|
<string name="enable_buffer_history">Enable buffer history</string>
|
||||||
<string name="enable_buffer_history_description">Enables access to previous buffer states. This option may improve rendering quality and performance consistency in some games.</string>
|
<string name="enable_buffer_history_description">Enables access to previous buffer states. This option may improve rendering quality and performance consistency in some games.</string>
|
||||||
|
<string name="enable_gpu_buffer_readback">Enable GPU Buffer Readback</string>
|
||||||
|
<string name="enable_gpu_buffer_readback_description">Preserves GPU-modified buffer data by reading it back before uploads. Some games require this to render certain effects properly. May cause issues if the hardware cannot handle the additional workload.</string>
|
||||||
<string name="use_optimized_vertex_buffers">Optimized Vertex Buffers</string>
|
<string name="use_optimized_vertex_buffers">Optimized Vertex Buffers</string>
|
||||||
<string name="use_optimized_vertex_buffers_description">Enables optimized vertex buffer binding for improved performance. Requires Mesa 26.0+ Turnip drivers/ QCOM drivers. Will crash on older Turnip drivers (25.3 and below).</string>
|
<string name="use_optimized_vertex_buffers_description">Enables optimized vertex buffer binding for improved performance. Requires Mesa 26.0+ Turnip drivers/ QCOM drivers. Will crash on older Turnip drivers (25.3 and below).</string>
|
||||||
|
|
||||||
@@ -1136,6 +1138,7 @@
|
|||||||
<string name="gpu_fence_behavior_immediate">Immediate</string>
|
<string name="gpu_fence_behavior_immediate">Immediate</string>
|
||||||
<string name="gpu_fence_behavior_balanced">Balanced</string>
|
<string name="gpu_fence_behavior_balanced">Balanced</string>
|
||||||
<string name="gpu_fence_behavior_accurate">Accurate</string>
|
<string name="gpu_fence_behavior_accurate">Accurate</string>
|
||||||
|
<string name="gpu_fence_behavior_strict">Strict</string>
|
||||||
|
|
||||||
<!-- ASTC Decoding Method Choices -->
|
<!-- ASTC Decoding Method Choices -->
|
||||||
<string name="accelerate_astc_cpu" translatable="false">CPU</string>
|
<string name="accelerate_astc_cpu" translatable="false">CPU</string>
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ add_library(
|
|||||||
fs/fs_util.h
|
fs/fs_util.h
|
||||||
fs/path_util.cpp
|
fs/path_util.cpp
|
||||||
fs/path_util.h
|
fs/path_util.h
|
||||||
|
hash.h
|
||||||
heap_tracker.cpp
|
heap_tracker.cpp
|
||||||
heap_tracker.h
|
heap_tracker.h
|
||||||
hex_util.cpp
|
hex_util.cpp
|
||||||
@@ -136,8 +137,6 @@ add_library(
|
|||||||
uuid.cpp
|
uuid.cpp
|
||||||
uuid.h
|
uuid.h
|
||||||
vector_math.h
|
vector_math.h
|
||||||
zbic_compression.cpp
|
|
||||||
zbic_compression.h
|
|
||||||
zstd_compression.cpp
|
zstd_compression.cpp
|
||||||
zstd_compression.h
|
zstd_compression.h
|
||||||
fs/ryujinx_compat.h fs/ryujinx_compat.cpp
|
fs/ryujinx_compat.h fs/ryujinx_compat.cpp
|
||||||
@@ -148,10 +147,6 @@ add_library(
|
|||||||
net/net.h net/net.cpp
|
net/net.h net/net.cpp
|
||||||
container/unordered_map.h container/unordered_set.h)
|
container/unordered_map.h container/unordered_set.h)
|
||||||
|
|
||||||
set_source_files_properties(zbic_compression.cpp PROPERTIES
|
|
||||||
INCLUDE_DIRECTORIES "${ZBIC_INCLUDE_DIR}"
|
|
||||||
COMPILE_OPTIONS "$<$<CXX_COMPILER_ID:Clang,GNU>:-Wno-unused-function;-Wno-missing-declarations;-Wno-shadow>")
|
|
||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
target_sources(common PRIVATE windows/timer_resolution.cpp
|
target_sources(common PRIVATE windows/timer_resolution.cpp
|
||||||
windows/timer_resolution.h)
|
windows/timer_resolution.h)
|
||||||
|
|||||||
+251
-252
@@ -12,94 +12,93 @@
|
|||||||
#include "common/android/multiplayer/multiplayer.h"
|
#include "common/android/multiplayer/multiplayer.h"
|
||||||
#include <network/network.h>
|
#include <network/network.h>
|
||||||
|
|
||||||
static struct {
|
|
||||||
JavaVM *java_vm;
|
|
||||||
jclass native_library_class;
|
|
||||||
jclass disk_cache_progress_class;
|
|
||||||
jclass load_callback_stage_class;
|
|
||||||
jclass game_dir_class;
|
|
||||||
jmethodID game_dir_constructor;
|
|
||||||
jmethodID exit_emulation_activity;
|
|
||||||
jmethodID disk_cache_load_progress;
|
|
||||||
jmethodID on_emulation_started;
|
|
||||||
jmethodID on_emulation_stopped;
|
|
||||||
jmethodID on_program_changed;
|
|
||||||
jmethodID copy_to_storage;
|
|
||||||
jmethodID file_exists;
|
|
||||||
jmethodID file_extension;
|
|
||||||
|
|
||||||
jclass game_class;
|
static JavaVM *s_java_vm;
|
||||||
jmethodID game_constructor;
|
static jclass s_native_library_class;
|
||||||
jfieldID game_title_field;
|
static jclass s_disk_cache_progress_class;
|
||||||
jfieldID game_path_field;
|
static jclass s_load_callback_stage_class;
|
||||||
jfieldID game_program_id_field;
|
static jclass s_game_dir_class;
|
||||||
jfieldID game_developer_field;
|
static jmethodID s_game_dir_constructor;
|
||||||
jfieldID game_version_field;
|
static jmethodID s_exit_emulation_activity;
|
||||||
jfieldID game_is_homebrew_field;
|
static jmethodID s_disk_cache_load_progress;
|
||||||
|
static jmethodID s_on_emulation_started;
|
||||||
|
static jmethodID s_on_emulation_stopped;
|
||||||
|
static jmethodID s_on_program_changed;
|
||||||
|
static jmethodID s_copy_to_storage;
|
||||||
|
static jmethodID s_file_exists;
|
||||||
|
static jmethodID s_file_extension;
|
||||||
|
|
||||||
jclass string_class;
|
static jclass s_game_class;
|
||||||
jclass pair_class;
|
static jmethodID s_game_constructor;
|
||||||
jmethodID pair_constructor;
|
static jfieldID s_game_title_field;
|
||||||
jfieldID pair_first_field;
|
static jfieldID s_game_path_field;
|
||||||
jfieldID pair_second_field;
|
static jfieldID s_game_program_id_field;
|
||||||
|
static jfieldID s_game_developer_field;
|
||||||
|
static jfieldID s_game_version_field;
|
||||||
|
static jfieldID s_game_is_homebrew_field;
|
||||||
|
|
||||||
jclass overlay_control_data_class;
|
static jclass s_string_class;
|
||||||
jmethodID overlay_control_data_constructor;
|
static jclass s_pair_class;
|
||||||
jfieldID overlay_control_data_id_field;
|
static jmethodID s_pair_constructor;
|
||||||
jfieldID overlay_control_data_enabled_field;
|
static jfieldID s_pair_first_field;
|
||||||
jfieldID overlay_control_data_individual_scale_field;
|
static jfieldID s_pair_second_field;
|
||||||
jfieldID overlay_control_data_landscape_position_field;
|
|
||||||
jfieldID overlay_control_data_portrait_position_field;
|
|
||||||
jfieldID overlay_control_data_foldable_position_field;
|
|
||||||
|
|
||||||
jclass patch_class;
|
static jclass s_overlay_control_data_class;
|
||||||
jmethodID patch_constructor;
|
static jmethodID s_overlay_control_data_constructor;
|
||||||
jfieldID patch_enabled_field;
|
static jfieldID s_overlay_control_data_id_field;
|
||||||
jfieldID patch_name_field;
|
static jfieldID s_overlay_control_data_enabled_field;
|
||||||
jfieldID patch_version_field;
|
static jfieldID s_overlay_control_data_individual_scale_field;
|
||||||
jfieldID patch_type_field;
|
static jfieldID s_overlay_control_data_landscape_position_field;
|
||||||
jfieldID patch_program_id_field;
|
static jfieldID s_overlay_control_data_portrait_position_field;
|
||||||
jfieldID patch_title_id_field;
|
static jfieldID s_overlay_control_data_foldable_position_field;
|
||||||
|
|
||||||
jclass double_class;
|
static jclass s_patch_class;
|
||||||
jmethodID double_constructor;
|
static jmethodID s_patch_constructor;
|
||||||
jmethodID double_value_method;
|
static jfieldID s_patch_enabled_field;
|
||||||
|
static jfieldID s_patch_name_field;
|
||||||
|
static jfieldID s_patch_version_field;
|
||||||
|
static jfieldID s_patch_type_field;
|
||||||
|
static jfieldID s_patch_program_id_field;
|
||||||
|
static jfieldID s_patch_title_id_field;
|
||||||
|
|
||||||
jclass integer_class;
|
static jclass s_double_class;
|
||||||
jmethodID integer_constructor;
|
static jmethodID s_double_constructor;
|
||||||
jmethodID integer_value_method;
|
static jmethodID s_double_value_method;
|
||||||
|
|
||||||
jclass boolean_class;
|
static jclass s_integer_class;
|
||||||
jmethodID boolean_constructor;
|
static jmethodID s_integer_constructor;
|
||||||
jmethodID boolean_value_method;
|
static jmethodID s_integer_value_method;
|
||||||
|
|
||||||
jclass player_input_class;
|
static jclass s_boolean_class;
|
||||||
jmethodID player_input_constructor;
|
static jmethodID s_boolean_constructor;
|
||||||
jfieldID player_input_connected_field;
|
static jmethodID s_boolean_value_method;
|
||||||
jfieldID player_input_buttons_field;
|
|
||||||
jfieldID player_input_analogs_field;
|
|
||||||
jfieldID player_input_motions_field;
|
|
||||||
jfieldID player_input_vibration_enabled_field;
|
|
||||||
jfieldID player_input_vibration_strength_field;
|
|
||||||
jfieldID player_input_body_color_left_field;
|
|
||||||
jfieldID player_input_body_color_right_field;
|
|
||||||
jfieldID player_input_button_color_left_field;
|
|
||||||
jfieldID player_input_button_color_right_field;
|
|
||||||
jfieldID player_input_profile_name_field;
|
|
||||||
jfieldID player_input_use_system_vibrator_field;
|
|
||||||
|
|
||||||
jclass yuzu_input_device_interface;
|
static jclass s_player_input_class;
|
||||||
jmethodID yuzu_input_device_get_name;
|
static jmethodID s_player_input_constructor;
|
||||||
jmethodID yuzu_input_device_get_guid;
|
static jfieldID s_player_input_connected_field;
|
||||||
jmethodID yuzu_input_device_get_port;
|
static jfieldID s_player_input_buttons_field;
|
||||||
jmethodID yuzu_input_device_get_supports_vibration;
|
static jfieldID s_player_input_analogs_field;
|
||||||
jmethodID yuzu_input_device_vibrate;
|
static jfieldID s_player_input_motions_field;
|
||||||
jmethodID yuzu_input_device_get_axes;
|
static jfieldID s_player_input_vibration_enabled_field;
|
||||||
jmethodID yuzu_input_device_has_keys;
|
static jfieldID s_player_input_vibration_strength_field;
|
||||||
|
static jfieldID s_player_input_body_color_left_field;
|
||||||
|
static jfieldID s_player_input_body_color_right_field;
|
||||||
|
static jfieldID s_player_input_button_color_left_field;
|
||||||
|
static jfieldID s_player_input_button_color_right_field;
|
||||||
|
static jfieldID s_player_input_profile_name_field;
|
||||||
|
static jfieldID s_player_input_use_system_vibrator_field;
|
||||||
|
|
||||||
jmethodID add_netplay_message;
|
static jclass s_yuzu_input_device_interface;
|
||||||
jmethodID clear_chat;
|
static jmethodID s_yuzu_input_device_get_name;
|
||||||
} state;
|
static jmethodID s_yuzu_input_device_get_guid;
|
||||||
|
static jmethodID s_yuzu_input_device_get_port;
|
||||||
|
static jmethodID s_yuzu_input_device_get_supports_vibration;
|
||||||
|
static jmethodID s_yuzu_input_device_vibrate;
|
||||||
|
static jmethodID s_yuzu_input_device_get_axes;
|
||||||
|
static jmethodID s_yuzu_input_device_has_keys;
|
||||||
|
|
||||||
|
static jmethodID s_add_netplay_message;
|
||||||
|
static jmethodID s_clear_chat;
|
||||||
|
|
||||||
static constexpr jint JNI_VERSION = JNI_VERSION_1_6;
|
static constexpr jint JNI_VERSION = JNI_VERSION_1_6;
|
||||||
|
|
||||||
@@ -107,14 +106,14 @@ namespace Common::Android {
|
|||||||
JNIEnv *GetEnvForThread() {
|
JNIEnv *GetEnvForThread() {
|
||||||
thread_local static struct OwnedEnv {
|
thread_local static struct OwnedEnv {
|
||||||
OwnedEnv() {
|
OwnedEnv() {
|
||||||
status = state.java_vm->GetEnv(reinterpret_cast<void **>(&env), JNI_VERSION_1_6);
|
status = s_java_vm->GetEnv(reinterpret_cast<void **>(&env), JNI_VERSION_1_6);
|
||||||
if (status == JNI_EDETACHED)
|
if (status == JNI_EDETACHED)
|
||||||
state.java_vm->AttachCurrentThread(&env, nullptr);
|
s_java_vm->AttachCurrentThread(&env, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
~OwnedEnv() {
|
~OwnedEnv() {
|
||||||
if (status == JNI_EDETACHED)
|
if (status == JNI_EDETACHED)
|
||||||
state.java_vm->DetachCurrentThread();
|
s_java_vm->DetachCurrentThread();
|
||||||
}
|
}
|
||||||
|
|
||||||
int status;
|
int status;
|
||||||
@@ -124,303 +123,303 @@ namespace Common::Android {
|
|||||||
}
|
}
|
||||||
|
|
||||||
jclass GetNativeLibraryClass() {
|
jclass GetNativeLibraryClass() {
|
||||||
return state.native_library_class;
|
return s_native_library_class;
|
||||||
}
|
}
|
||||||
|
|
||||||
jclass GetDiskCacheProgressClass() {
|
jclass GetDiskCacheProgressClass() {
|
||||||
return state.disk_cache_progress_class;
|
return s_disk_cache_progress_class;
|
||||||
}
|
}
|
||||||
|
|
||||||
jclass GetDiskCacheLoadCallbackStageClass() {
|
jclass GetDiskCacheLoadCallbackStageClass() {
|
||||||
return state.load_callback_stage_class;
|
return s_load_callback_stage_class;
|
||||||
}
|
}
|
||||||
|
|
||||||
jclass GetGameDirClass() {
|
jclass GetGameDirClass() {
|
||||||
return state.game_dir_class;
|
return s_game_dir_class;
|
||||||
}
|
}
|
||||||
|
|
||||||
jmethodID GetGameDirConstructor() {
|
jmethodID GetGameDirConstructor() {
|
||||||
return state.game_dir_constructor;
|
return s_game_dir_constructor;
|
||||||
}
|
}
|
||||||
|
|
||||||
jmethodID GetExitEmulationActivity() {
|
jmethodID GetExitEmulationActivity() {
|
||||||
return state.exit_emulation_activity;
|
return s_exit_emulation_activity;
|
||||||
}
|
}
|
||||||
|
|
||||||
jmethodID GetDiskCacheLoadProgress() {
|
jmethodID GetDiskCacheLoadProgress() {
|
||||||
return state.disk_cache_load_progress;
|
return s_disk_cache_load_progress;
|
||||||
}
|
}
|
||||||
|
|
||||||
jmethodID GetCopyToStorage() {
|
jmethodID GetCopyToStorage() {
|
||||||
return state.copy_to_storage;
|
return s_copy_to_storage;
|
||||||
}
|
}
|
||||||
|
|
||||||
jmethodID GetFileExists() {
|
jmethodID GetFileExists() {
|
||||||
return state.file_exists;
|
return s_file_exists;
|
||||||
}
|
}
|
||||||
|
|
||||||
jmethodID GetFileExtension() {
|
jmethodID GetFileExtension() {
|
||||||
return state.file_extension;
|
return s_file_extension;
|
||||||
}
|
}
|
||||||
|
|
||||||
jmethodID GetOnEmulationStarted() {
|
jmethodID GetOnEmulationStarted() {
|
||||||
return state.on_emulation_started;
|
return s_on_emulation_started;
|
||||||
}
|
}
|
||||||
|
|
||||||
jmethodID GetOnEmulationStopped() {
|
jmethodID GetOnEmulationStopped() {
|
||||||
return state.on_emulation_stopped;
|
return s_on_emulation_stopped;
|
||||||
}
|
}
|
||||||
|
|
||||||
jmethodID GetOnProgramChanged() {
|
jmethodID GetOnProgramChanged() {
|
||||||
return state.on_program_changed;
|
return s_on_program_changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
jclass GetGameClass() {
|
jclass GetGameClass() {
|
||||||
return state.game_class;
|
return s_game_class;
|
||||||
}
|
}
|
||||||
|
|
||||||
jmethodID GetGameConstructor() {
|
jmethodID GetGameConstructor() {
|
||||||
return state.game_constructor;
|
return s_game_constructor;
|
||||||
}
|
}
|
||||||
|
|
||||||
jfieldID GetGameTitleField() {
|
jfieldID GetGameTitleField() {
|
||||||
return state.game_title_field;
|
return s_game_title_field;
|
||||||
}
|
}
|
||||||
|
|
||||||
jfieldID GetGamePathField() {
|
jfieldID GetGamePathField() {
|
||||||
return state.game_path_field;
|
return s_game_path_field;
|
||||||
}
|
}
|
||||||
|
|
||||||
jfieldID GetGameProgramIdField() {
|
jfieldID GetGameProgramIdField() {
|
||||||
return state.game_program_id_field;
|
return s_game_program_id_field;
|
||||||
}
|
}
|
||||||
|
|
||||||
jfieldID GetGameDeveloperField() {
|
jfieldID GetGameDeveloperField() {
|
||||||
return state.game_developer_field;
|
return s_game_developer_field;
|
||||||
}
|
}
|
||||||
|
|
||||||
jfieldID GetGameVersionField() {
|
jfieldID GetGameVersionField() {
|
||||||
return state.game_version_field;
|
return s_game_version_field;
|
||||||
}
|
}
|
||||||
|
|
||||||
jfieldID GetGameIsHomebrewField() {
|
jfieldID GetGameIsHomebrewField() {
|
||||||
return state.game_is_homebrew_field;
|
return s_game_is_homebrew_field;
|
||||||
}
|
}
|
||||||
|
|
||||||
jclass GetStringClass() {
|
jclass GetStringClass() {
|
||||||
return state.string_class;
|
return s_string_class;
|
||||||
}
|
}
|
||||||
|
|
||||||
jclass GetPairClass() {
|
jclass GetPairClass() {
|
||||||
return state.pair_class;
|
return s_pair_class;
|
||||||
}
|
}
|
||||||
|
|
||||||
jmethodID GetPairConstructor() {
|
jmethodID GetPairConstructor() {
|
||||||
return state.pair_constructor;
|
return s_pair_constructor;
|
||||||
}
|
}
|
||||||
|
|
||||||
jfieldID GetPairFirstField() {
|
jfieldID GetPairFirstField() {
|
||||||
return state.pair_first_field;
|
return s_pair_first_field;
|
||||||
}
|
}
|
||||||
|
|
||||||
jfieldID GetPairSecondField() {
|
jfieldID GetPairSecondField() {
|
||||||
return state.pair_second_field;
|
return s_pair_second_field;
|
||||||
}
|
}
|
||||||
|
|
||||||
jclass GetOverlayControlDataClass() {
|
jclass GetOverlayControlDataClass() {
|
||||||
return state.overlay_control_data_class;
|
return s_overlay_control_data_class;
|
||||||
}
|
}
|
||||||
|
|
||||||
jmethodID GetOverlayControlDataConstructor() {
|
jmethodID GetOverlayControlDataConstructor() {
|
||||||
return state.overlay_control_data_constructor;
|
return s_overlay_control_data_constructor;
|
||||||
}
|
}
|
||||||
|
|
||||||
jfieldID GetOverlayControlDataIdField() {
|
jfieldID GetOverlayControlDataIdField() {
|
||||||
return state.overlay_control_data_id_field;
|
return s_overlay_control_data_id_field;
|
||||||
}
|
}
|
||||||
|
|
||||||
jfieldID GetOverlayControlDataEnabledField() {
|
jfieldID GetOverlayControlDataEnabledField() {
|
||||||
return state.overlay_control_data_enabled_field;
|
return s_overlay_control_data_enabled_field;
|
||||||
}
|
}
|
||||||
|
|
||||||
jfieldID GetOverlayControlDataIndividualScaleField() {
|
jfieldID GetOverlayControlDataIndividualScaleField() {
|
||||||
return state.overlay_control_data_individual_scale_field;
|
return s_overlay_control_data_individual_scale_field;
|
||||||
}
|
}
|
||||||
|
|
||||||
jfieldID GetOverlayControlDataLandscapePositionField() {
|
jfieldID GetOverlayControlDataLandscapePositionField() {
|
||||||
return state.overlay_control_data_landscape_position_field;
|
return s_overlay_control_data_landscape_position_field;
|
||||||
}
|
}
|
||||||
|
|
||||||
jfieldID GetOverlayControlDataPortraitPositionField() {
|
jfieldID GetOverlayControlDataPortraitPositionField() {
|
||||||
return state.overlay_control_data_portrait_position_field;
|
return s_overlay_control_data_portrait_position_field;
|
||||||
}
|
}
|
||||||
|
|
||||||
jfieldID GetOverlayControlDataFoldablePositionField() {
|
jfieldID GetOverlayControlDataFoldablePositionField() {
|
||||||
return state.overlay_control_data_foldable_position_field;
|
return s_overlay_control_data_foldable_position_field;
|
||||||
}
|
}
|
||||||
|
|
||||||
jclass GetPatchClass() {
|
jclass GetPatchClass() {
|
||||||
return state.patch_class;
|
return s_patch_class;
|
||||||
}
|
}
|
||||||
|
|
||||||
jmethodID GetPatchConstructor() {
|
jmethodID GetPatchConstructor() {
|
||||||
return state.patch_constructor;
|
return s_patch_constructor;
|
||||||
}
|
}
|
||||||
|
|
||||||
jfieldID GetPatchEnabledField() {
|
jfieldID GetPatchEnabledField() {
|
||||||
return state.patch_enabled_field;
|
return s_patch_enabled_field;
|
||||||
}
|
}
|
||||||
|
|
||||||
jfieldID GetPatchNameField() {
|
jfieldID GetPatchNameField() {
|
||||||
return state.patch_name_field;
|
return s_patch_name_field;
|
||||||
}
|
}
|
||||||
|
|
||||||
jfieldID GetPatchVersionField() {
|
jfieldID GetPatchVersionField() {
|
||||||
return state.patch_version_field;
|
return s_patch_version_field;
|
||||||
}
|
}
|
||||||
|
|
||||||
jfieldID GetPatchTypeField() {
|
jfieldID GetPatchTypeField() {
|
||||||
return state.patch_type_field;
|
return s_patch_type_field;
|
||||||
}
|
}
|
||||||
|
|
||||||
jfieldID GetPatchProgramIdField() {
|
jfieldID GetPatchProgramIdField() {
|
||||||
return state.patch_program_id_field;
|
return s_patch_program_id_field;
|
||||||
}
|
}
|
||||||
|
|
||||||
jfieldID GetPatchTitleIdField() {
|
jfieldID GetPatchTitleIdField() {
|
||||||
return state.patch_title_id_field;
|
return s_patch_title_id_field;
|
||||||
}
|
}
|
||||||
|
|
||||||
jclass GetDoubleClass() {
|
jclass GetDoubleClass() {
|
||||||
return state.double_class;
|
return s_double_class;
|
||||||
}
|
}
|
||||||
|
|
||||||
jmethodID GetDoubleConstructor() {
|
jmethodID GetDoubleConstructor() {
|
||||||
return state.double_constructor;
|
return s_double_constructor;
|
||||||
}
|
}
|
||||||
|
|
||||||
jmethodID GetDoubleValueMethod() {
|
jmethodID GetDoubleValueMethod() {
|
||||||
return state.double_value_method;
|
return s_double_value_method;
|
||||||
}
|
}
|
||||||
|
|
||||||
jclass GetIntegerClass() {
|
jclass GetIntegerClass() {
|
||||||
return state.integer_class;
|
return s_integer_class;
|
||||||
}
|
}
|
||||||
|
|
||||||
jmethodID GetIntegerConstructor() {
|
jmethodID GetIntegerConstructor() {
|
||||||
return state.integer_constructor;
|
return s_integer_constructor;
|
||||||
}
|
}
|
||||||
|
|
||||||
jmethodID GetIntegerValueMethod() {
|
jmethodID GetIntegerValueMethod() {
|
||||||
return state.integer_value_method;
|
return s_integer_value_method;
|
||||||
}
|
}
|
||||||
|
|
||||||
jclass GetBooleanClass() {
|
jclass GetBooleanClass() {
|
||||||
return state.boolean_class;
|
return s_boolean_class;
|
||||||
}
|
}
|
||||||
|
|
||||||
jmethodID GetBooleanConstructor() {
|
jmethodID GetBooleanConstructor() {
|
||||||
return state.boolean_constructor;
|
return s_boolean_constructor;
|
||||||
}
|
}
|
||||||
|
|
||||||
jmethodID GetBooleanValueMethod() {
|
jmethodID GetBooleanValueMethod() {
|
||||||
return state.boolean_value_method;
|
return s_boolean_value_method;
|
||||||
}
|
}
|
||||||
|
|
||||||
jclass GetPlayerInputClass() {
|
jclass GetPlayerInputClass() {
|
||||||
return state.player_input_class;
|
return s_player_input_class;
|
||||||
}
|
}
|
||||||
|
|
||||||
jmethodID GetPlayerInputConstructor() {
|
jmethodID GetPlayerInputConstructor() {
|
||||||
return state.player_input_constructor;
|
return s_player_input_constructor;
|
||||||
}
|
}
|
||||||
|
|
||||||
jfieldID GetPlayerInputConnectedField() {
|
jfieldID GetPlayerInputConnectedField() {
|
||||||
return state.player_input_connected_field;
|
return s_player_input_connected_field;
|
||||||
}
|
}
|
||||||
|
|
||||||
jfieldID GetPlayerInputButtonsField() {
|
jfieldID GetPlayerInputButtonsField() {
|
||||||
return state.player_input_buttons_field;
|
return s_player_input_buttons_field;
|
||||||
}
|
}
|
||||||
|
|
||||||
jfieldID GetPlayerInputAnalogsField() {
|
jfieldID GetPlayerInputAnalogsField() {
|
||||||
return state.player_input_analogs_field;
|
return s_player_input_analogs_field;
|
||||||
}
|
}
|
||||||
|
|
||||||
jfieldID GetPlayerInputMotionsField() {
|
jfieldID GetPlayerInputMotionsField() {
|
||||||
return state.player_input_motions_field;
|
return s_player_input_motions_field;
|
||||||
}
|
}
|
||||||
|
|
||||||
jfieldID GetPlayerInputVibrationEnabledField() {
|
jfieldID GetPlayerInputVibrationEnabledField() {
|
||||||
return state.player_input_vibration_enabled_field;
|
return s_player_input_vibration_enabled_field;
|
||||||
}
|
}
|
||||||
|
|
||||||
jfieldID GetPlayerInputVibrationStrengthField() {
|
jfieldID GetPlayerInputVibrationStrengthField() {
|
||||||
return state.player_input_vibration_strength_field;
|
return s_player_input_vibration_strength_field;
|
||||||
}
|
}
|
||||||
|
|
||||||
jfieldID GetPlayerInputBodyColorLeftField() {
|
jfieldID GetPlayerInputBodyColorLeftField() {
|
||||||
return state.player_input_body_color_left_field;
|
return s_player_input_body_color_left_field;
|
||||||
}
|
}
|
||||||
|
|
||||||
jfieldID GetPlayerInputBodyColorRightField() {
|
jfieldID GetPlayerInputBodyColorRightField() {
|
||||||
return state.player_input_body_color_right_field;
|
return s_player_input_body_color_right_field;
|
||||||
}
|
}
|
||||||
|
|
||||||
jfieldID GetPlayerInputButtonColorLeftField() {
|
jfieldID GetPlayerInputButtonColorLeftField() {
|
||||||
return state.player_input_button_color_left_field;
|
return s_player_input_button_color_left_field;
|
||||||
}
|
}
|
||||||
|
|
||||||
jfieldID GetPlayerInputButtonColorRightField() {
|
jfieldID GetPlayerInputButtonColorRightField() {
|
||||||
return state.player_input_button_color_right_field;
|
return s_player_input_button_color_right_field;
|
||||||
}
|
}
|
||||||
|
|
||||||
jfieldID GetPlayerInputProfileNameField() {
|
jfieldID GetPlayerInputProfileNameField() {
|
||||||
return state.player_input_profile_name_field;
|
return s_player_input_profile_name_field;
|
||||||
}
|
}
|
||||||
|
|
||||||
jfieldID GetPlayerInputUseSystemVibratorField() {
|
jfieldID GetPlayerInputUseSystemVibratorField() {
|
||||||
return state.player_input_use_system_vibrator_field;
|
return s_player_input_use_system_vibrator_field;
|
||||||
}
|
}
|
||||||
|
|
||||||
jclass GetYuzuInputDeviceInterface() {
|
jclass GetYuzuInputDeviceInterface() {
|
||||||
return state.yuzu_input_device_interface;
|
return s_yuzu_input_device_interface;
|
||||||
}
|
}
|
||||||
|
|
||||||
jmethodID GetYuzuDeviceGetName() {
|
jmethodID GetYuzuDeviceGetName() {
|
||||||
return state.yuzu_input_device_get_name;
|
return s_yuzu_input_device_get_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
jmethodID GetYuzuDeviceGetGUID() {
|
jmethodID GetYuzuDeviceGetGUID() {
|
||||||
return state.yuzu_input_device_get_guid;
|
return s_yuzu_input_device_get_guid;
|
||||||
}
|
}
|
||||||
|
|
||||||
jmethodID GetYuzuDeviceGetPort() {
|
jmethodID GetYuzuDeviceGetPort() {
|
||||||
return state.yuzu_input_device_get_port;
|
return s_yuzu_input_device_get_port;
|
||||||
}
|
}
|
||||||
|
|
||||||
jmethodID GetYuzuDeviceGetSupportsVibration() {
|
jmethodID GetYuzuDeviceGetSupportsVibration() {
|
||||||
return state.yuzu_input_device_get_supports_vibration;
|
return s_yuzu_input_device_get_supports_vibration;
|
||||||
}
|
}
|
||||||
|
|
||||||
jmethodID GetYuzuDeviceVibrate() {
|
jmethodID GetYuzuDeviceVibrate() {
|
||||||
return state.yuzu_input_device_vibrate;
|
return s_yuzu_input_device_vibrate;
|
||||||
}
|
}
|
||||||
|
|
||||||
jmethodID GetYuzuDeviceGetAxes() {
|
jmethodID GetYuzuDeviceGetAxes() {
|
||||||
return state.yuzu_input_device_get_axes;
|
return s_yuzu_input_device_get_axes;
|
||||||
}
|
}
|
||||||
|
|
||||||
jmethodID GetYuzuDeviceHasKeys() {
|
jmethodID GetYuzuDeviceHasKeys() {
|
||||||
return state.yuzu_input_device_has_keys;
|
return s_yuzu_input_device_has_keys;
|
||||||
}
|
}
|
||||||
|
|
||||||
jmethodID GetAddNetPlayMessage() {
|
jmethodID GetAddNetPlayMessage() {
|
||||||
return state.add_netplay_message;
|
return s_add_netplay_message;
|
||||||
}
|
}
|
||||||
|
|
||||||
jmethodID ClearChat() {
|
jmethodID ClearChat() {
|
||||||
return state.clear_chat;
|
return s_clear_chat;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
@@ -437,20 +436,20 @@ namespace Common::Android {
|
|||||||
|
|
||||||
// UnInitialize Android Storage
|
// UnInitialize Android Storage
|
||||||
Common::FS::Android::UnRegisterCallbacks();
|
Common::FS::Android::UnRegisterCallbacks();
|
||||||
env->DeleteGlobalRef(state.native_library_class);
|
env->DeleteGlobalRef(s_native_library_class);
|
||||||
env->DeleteGlobalRef(state.disk_cache_progress_class);
|
env->DeleteGlobalRef(s_disk_cache_progress_class);
|
||||||
env->DeleteGlobalRef(state.load_callback_stage_class);
|
env->DeleteGlobalRef(s_load_callback_stage_class);
|
||||||
env->DeleteGlobalRef(state.game_dir_class);
|
env->DeleteGlobalRef(s_game_dir_class);
|
||||||
env->DeleteGlobalRef(state.game_class);
|
env->DeleteGlobalRef(s_game_class);
|
||||||
env->DeleteGlobalRef(state.string_class);
|
env->DeleteGlobalRef(s_string_class);
|
||||||
env->DeleteGlobalRef(state.pair_class);
|
env->DeleteGlobalRef(s_pair_class);
|
||||||
env->DeleteGlobalRef(state.overlay_control_data_class);
|
env->DeleteGlobalRef(s_overlay_control_data_class);
|
||||||
env->DeleteGlobalRef(state.patch_class);
|
env->DeleteGlobalRef(s_patch_class);
|
||||||
env->DeleteGlobalRef(state.double_class);
|
env->DeleteGlobalRef(s_double_class);
|
||||||
env->DeleteGlobalRef(state.integer_class);
|
env->DeleteGlobalRef(s_integer_class);
|
||||||
env->DeleteGlobalRef(state.boolean_class);
|
env->DeleteGlobalRef(s_boolean_class);
|
||||||
env->DeleteGlobalRef(state.player_input_class);
|
env->DeleteGlobalRef(s_player_input_class);
|
||||||
env->DeleteGlobalRef(state.yuzu_input_device_interface);
|
env->DeleteGlobalRef(s_yuzu_input_device_interface);
|
||||||
|
|
||||||
// UnInitialize applets
|
// UnInitialize applets
|
||||||
SoftwareKeyboard::CleanupJNI(env);
|
SoftwareKeyboard::CleanupJNI(env);
|
||||||
@@ -464,7 +463,7 @@ namespace Common::Android {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
void Initialize(JavaVM* vm, JNIEnv *env) {
|
void Initialize(JavaVM* vm, JNIEnv *env) {
|
||||||
state.java_vm = vm;
|
s_java_vm = vm;
|
||||||
InitFFmpegOnLoad(vm);
|
InitFFmpegOnLoad(vm);
|
||||||
|
|
||||||
if (env->ExceptionCheck()) {
|
if (env->ExceptionCheck()) {
|
||||||
@@ -473,169 +472,169 @@ void Initialize(JavaVM* vm, JNIEnv *env) {
|
|||||||
|
|
||||||
// Initialize Java classes
|
// Initialize Java classes
|
||||||
const jclass native_library_class = env->FindClass("org/yuzu/yuzu_emu/NativeLibrary");
|
const jclass native_library_class = env->FindClass("org/yuzu/yuzu_emu/NativeLibrary");
|
||||||
state.native_library_class = reinterpret_cast<jclass>(env->NewGlobalRef(native_library_class));
|
s_native_library_class = reinterpret_cast<jclass>(env->NewGlobalRef(native_library_class));
|
||||||
state.disk_cache_progress_class = reinterpret_cast<jclass>(env->NewGlobalRef(
|
s_disk_cache_progress_class = reinterpret_cast<jclass>(env->NewGlobalRef(
|
||||||
env->FindClass("org/yuzu/yuzu_emu/disk_shader_cache/DiskShaderCacheProgress")));
|
env->FindClass("org/yuzu/yuzu_emu/disk_shader_cache/DiskShaderCacheProgress")));
|
||||||
state.load_callback_stage_class = reinterpret_cast<jclass>(env->NewGlobalRef(env->FindClass(
|
s_load_callback_stage_class = reinterpret_cast<jclass>(env->NewGlobalRef(env->FindClass(
|
||||||
"org/yuzu/yuzu_emu/disk_shader_cache/DiskShaderCacheProgress$LoadCallbackStage")));
|
"org/yuzu/yuzu_emu/disk_shader_cache/DiskShaderCacheProgress$LoadCallbackStage")));
|
||||||
|
|
||||||
const jclass game_dir_class = env->FindClass("org/yuzu/yuzu_emu/model/GameDir");
|
const jclass game_dir_class = env->FindClass("org/yuzu/yuzu_emu/model/GameDir");
|
||||||
state.game_dir_class = reinterpret_cast<jclass>(env->NewGlobalRef(game_dir_class));
|
s_game_dir_class = reinterpret_cast<jclass>(env->NewGlobalRef(game_dir_class));
|
||||||
state.game_dir_constructor = env->GetMethodID(game_dir_class, "<init>",
|
s_game_dir_constructor = env->GetMethodID(game_dir_class, "<init>",
|
||||||
"(Ljava/lang/String;Z)V");
|
"(Ljava/lang/String;Z)V");
|
||||||
env->DeleteLocalRef(game_dir_class);
|
env->DeleteLocalRef(game_dir_class);
|
||||||
|
|
||||||
// Initialize methods
|
// Initialize methods
|
||||||
state.exit_emulation_activity =
|
s_exit_emulation_activity =
|
||||||
env->GetStaticMethodID(state.native_library_class, "exitEmulationActivity", "(I)V");
|
env->GetStaticMethodID(s_native_library_class, "exitEmulationActivity", "(I)V");
|
||||||
state.disk_cache_load_progress =
|
s_disk_cache_load_progress =
|
||||||
env->GetStaticMethodID(state.disk_cache_progress_class, "loadProgress", "(III)V");
|
env->GetStaticMethodID(s_disk_cache_progress_class, "loadProgress", "(III)V");
|
||||||
state.copy_to_storage = env->GetStaticMethodID(state.native_library_class, "copyFileToStorage",
|
s_copy_to_storage = env->GetStaticMethodID(s_native_library_class, "copyFileToStorage",
|
||||||
"(Ljava/lang/String;Ljava/lang/String;)Z");
|
"(Ljava/lang/String;Ljava/lang/String;)Z");
|
||||||
state.file_exists = env->GetStaticMethodID(state.native_library_class, "exists",
|
s_file_exists = env->GetStaticMethodID(s_native_library_class, "exists",
|
||||||
"(Ljava/lang/String;)Z");
|
"(Ljava/lang/String;)Z");
|
||||||
state.file_extension = env->GetStaticMethodID(state.native_library_class, "getFileExtension",
|
s_file_extension = env->GetStaticMethodID(s_native_library_class, "getFileExtension",
|
||||||
"(Ljava/lang/String;)Ljava/lang/String;");
|
"(Ljava/lang/String;)Ljava/lang/String;");
|
||||||
state.on_emulation_started =
|
s_on_emulation_started =
|
||||||
env->GetStaticMethodID(state.native_library_class, "onEmulationStarted", "()V");
|
env->GetStaticMethodID(s_native_library_class, "onEmulationStarted", "()V");
|
||||||
state.on_emulation_stopped =
|
s_on_emulation_stopped =
|
||||||
env->GetStaticMethodID(state.native_library_class, "onEmulationStopped", "(I)V");
|
env->GetStaticMethodID(s_native_library_class, "onEmulationStopped", "(I)V");
|
||||||
state.on_program_changed =
|
s_on_program_changed =
|
||||||
env->GetStaticMethodID(state.native_library_class, "onProgramChanged", "(I)V");
|
env->GetStaticMethodID(s_native_library_class, "onProgramChanged", "(I)V");
|
||||||
|
|
||||||
const jclass game_class = env->FindClass("org/yuzu/yuzu_emu/model/Game");
|
const jclass game_class = env->FindClass("org/yuzu/yuzu_emu/model/Game");
|
||||||
state.game_class = reinterpret_cast<jclass>(env->NewGlobalRef(game_class));
|
s_game_class = reinterpret_cast<jclass>(env->NewGlobalRef(game_class));
|
||||||
state.game_constructor = env->GetMethodID(game_class, "<init>",
|
s_game_constructor = env->GetMethodID(game_class, "<init>",
|
||||||
"(Ljava/lang/String;Ljava/lang/String;Ljava/lang/"
|
"(Ljava/lang/String;Ljava/lang/String;Ljava/lang/"
|
||||||
"String;Ljava/lang/String;Ljava/lang/String;Z)V");
|
"String;Ljava/lang/String;Ljava/lang/String;Z)V");
|
||||||
state.game_title_field = env->GetFieldID(game_class, "title", "Ljava/lang/String;");
|
s_game_title_field = env->GetFieldID(game_class, "title", "Ljava/lang/String;");
|
||||||
state.game_path_field = env->GetFieldID(game_class, "path", "Ljava/lang/String;");
|
s_game_path_field = env->GetFieldID(game_class, "path", "Ljava/lang/String;");
|
||||||
state.game_program_id_field = env->GetFieldID(game_class, "programId", "Ljava/lang/String;");
|
s_game_program_id_field = env->GetFieldID(game_class, "programId", "Ljava/lang/String;");
|
||||||
state.game_developer_field = env->GetFieldID(game_class, "developer", "Ljava/lang/String;");
|
s_game_developer_field = env->GetFieldID(game_class, "developer", "Ljava/lang/String;");
|
||||||
state.game_version_field = env->GetFieldID(game_class, "version", "Ljava/lang/String;");
|
s_game_version_field = env->GetFieldID(game_class, "version", "Ljava/lang/String;");
|
||||||
state.game_is_homebrew_field = env->GetFieldID(game_class, "isHomebrew", "Z");
|
s_game_is_homebrew_field = env->GetFieldID(game_class, "isHomebrew", "Z");
|
||||||
env->DeleteLocalRef(game_class);
|
env->DeleteLocalRef(game_class);
|
||||||
|
|
||||||
const jclass string_class = env->FindClass("java/lang/String");
|
const jclass string_class = env->FindClass("java/lang/String");
|
||||||
state.string_class = reinterpret_cast<jclass>(env->NewGlobalRef(string_class));
|
s_string_class = reinterpret_cast<jclass>(env->NewGlobalRef(string_class));
|
||||||
env->DeleteLocalRef(string_class);
|
env->DeleteLocalRef(string_class);
|
||||||
|
|
||||||
const jclass pair_class = env->FindClass("kotlin/Pair");
|
const jclass pair_class = env->FindClass("kotlin/Pair");
|
||||||
state.pair_class = reinterpret_cast<jclass>(env->NewGlobalRef(pair_class));
|
s_pair_class = reinterpret_cast<jclass>(env->NewGlobalRef(pair_class));
|
||||||
state.pair_constructor =
|
s_pair_constructor =
|
||||||
env->GetMethodID(pair_class, "<init>", "(Ljava/lang/Object;Ljava/lang/Object;)V");
|
env->GetMethodID(pair_class, "<init>", "(Ljava/lang/Object;Ljava/lang/Object;)V");
|
||||||
state.pair_first_field = env->GetFieldID(pair_class, "first", "Ljava/lang/Object;");
|
s_pair_first_field = env->GetFieldID(pair_class, "first", "Ljava/lang/Object;");
|
||||||
state.pair_second_field = env->GetFieldID(pair_class, "second", "Ljava/lang/Object;");
|
s_pair_second_field = env->GetFieldID(pair_class, "second", "Ljava/lang/Object;");
|
||||||
env->DeleteLocalRef(pair_class);
|
env->DeleteLocalRef(pair_class);
|
||||||
|
|
||||||
const jclass overlay_control_data_class =
|
const jclass overlay_control_data_class =
|
||||||
env->FindClass("org/yuzu/yuzu_emu/overlay/model/OverlayControlData");
|
env->FindClass("org/yuzu/yuzu_emu/overlay/model/OverlayControlData");
|
||||||
state.overlay_control_data_class =
|
s_overlay_control_data_class =
|
||||||
reinterpret_cast<jclass>(env->NewGlobalRef(overlay_control_data_class));
|
reinterpret_cast<jclass>(env->NewGlobalRef(overlay_control_data_class));
|
||||||
state.overlay_control_data_constructor =
|
s_overlay_control_data_constructor =
|
||||||
env->GetMethodID(overlay_control_data_class, "<init>",
|
env->GetMethodID(overlay_control_data_class, "<init>",
|
||||||
"(Ljava/lang/String;ZLkotlin/Pair;Lkotlin/Pair;Lkotlin/Pair;F)V");
|
"(Ljava/lang/String;ZLkotlin/Pair;Lkotlin/Pair;Lkotlin/Pair;F)V");
|
||||||
state.overlay_control_data_id_field =
|
s_overlay_control_data_id_field =
|
||||||
env->GetFieldID(overlay_control_data_class, "id", "Ljava/lang/String;");
|
env->GetFieldID(overlay_control_data_class, "id", "Ljava/lang/String;");
|
||||||
state.overlay_control_data_enabled_field =
|
s_overlay_control_data_enabled_field =
|
||||||
env->GetFieldID(overlay_control_data_class, "enabled", "Z");
|
env->GetFieldID(overlay_control_data_class, "enabled", "Z");
|
||||||
state.overlay_control_data_landscape_position_field =
|
s_overlay_control_data_landscape_position_field =
|
||||||
env->GetFieldID(overlay_control_data_class, "landscapePosition", "Lkotlin/Pair;");
|
env->GetFieldID(overlay_control_data_class, "landscapePosition", "Lkotlin/Pair;");
|
||||||
state.overlay_control_data_portrait_position_field =
|
s_overlay_control_data_portrait_position_field =
|
||||||
env->GetFieldID(overlay_control_data_class, "portraitPosition", "Lkotlin/Pair;");
|
env->GetFieldID(overlay_control_data_class, "portraitPosition", "Lkotlin/Pair;");
|
||||||
state.overlay_control_data_foldable_position_field =
|
s_overlay_control_data_foldable_position_field =
|
||||||
env->GetFieldID(overlay_control_data_class, "foldablePosition", "Lkotlin/Pair;");
|
env->GetFieldID(overlay_control_data_class, "foldablePosition", "Lkotlin/Pair;");
|
||||||
state.overlay_control_data_individual_scale_field =
|
s_overlay_control_data_individual_scale_field =
|
||||||
env->GetFieldID(overlay_control_data_class, "individualScale", "F");
|
env->GetFieldID(overlay_control_data_class, "individualScale", "F");
|
||||||
env->DeleteLocalRef(overlay_control_data_class);
|
env->DeleteLocalRef(overlay_control_data_class);
|
||||||
|
|
||||||
const jclass patch_class = env->FindClass("org/yuzu/yuzu_emu/model/Patch");
|
const jclass patch_class = env->FindClass("org/yuzu/yuzu_emu/model/Patch");
|
||||||
state.patch_class = reinterpret_cast<jclass>(env->NewGlobalRef(patch_class));
|
s_patch_class = reinterpret_cast<jclass>(env->NewGlobalRef(patch_class));
|
||||||
state.patch_constructor = env->GetMethodID(
|
s_patch_constructor = env->GetMethodID(
|
||||||
patch_class, "<init>",
|
patch_class, "<init>",
|
||||||
"(ZLjava/lang/String;Ljava/lang/String;ILjava/lang/String;Ljava/lang/String;JI)V");
|
"(ZLjava/lang/String;Ljava/lang/String;ILjava/lang/String;Ljava/lang/String;JI)V");
|
||||||
state.patch_enabled_field = env->GetFieldID(patch_class, "enabled", "Z");
|
s_patch_enabled_field = env->GetFieldID(patch_class, "enabled", "Z");
|
||||||
state.patch_name_field = env->GetFieldID(patch_class, "name", "Ljava/lang/String;");
|
s_patch_name_field = env->GetFieldID(patch_class, "name", "Ljava/lang/String;");
|
||||||
state.patch_version_field = env->GetFieldID(patch_class, "version", "Ljava/lang/String;");
|
s_patch_version_field = env->GetFieldID(patch_class, "version", "Ljava/lang/String;");
|
||||||
state.patch_type_field = env->GetFieldID(patch_class, "type", "I");
|
s_patch_type_field = env->GetFieldID(patch_class, "type", "I");
|
||||||
state.patch_program_id_field = env->GetFieldID(patch_class, "programId", "Ljava/lang/String;");
|
s_patch_program_id_field = env->GetFieldID(patch_class, "programId", "Ljava/lang/String;");
|
||||||
state.patch_title_id_field = env->GetFieldID(patch_class, "titleId", "Ljava/lang/String;");
|
s_patch_title_id_field = env->GetFieldID(patch_class, "titleId", "Ljava/lang/String;");
|
||||||
env->DeleteLocalRef(patch_class);
|
env->DeleteLocalRef(patch_class);
|
||||||
|
|
||||||
const jclass double_class = env->FindClass("java/lang/Double");
|
const jclass double_class = env->FindClass("java/lang/Double");
|
||||||
state.double_class = reinterpret_cast<jclass>(env->NewGlobalRef(double_class));
|
s_double_class = reinterpret_cast<jclass>(env->NewGlobalRef(double_class));
|
||||||
state.double_constructor = env->GetMethodID(double_class, "<init>", "(D)V");
|
s_double_constructor = env->GetMethodID(double_class, "<init>", "(D)V");
|
||||||
state.double_value_method = env->GetMethodID(double_class, "doubleValue", "()D");
|
s_double_value_method = env->GetMethodID(double_class, "doubleValue", "()D");
|
||||||
env->DeleteLocalRef(double_class);
|
env->DeleteLocalRef(double_class);
|
||||||
|
|
||||||
const jclass int_class = env->FindClass("java/lang/Integer");
|
const jclass int_class = env->FindClass("java/lang/Integer");
|
||||||
state.integer_class = reinterpret_cast<jclass>(env->NewGlobalRef(int_class));
|
s_integer_class = reinterpret_cast<jclass>(env->NewGlobalRef(int_class));
|
||||||
state.integer_constructor = env->GetMethodID(int_class, "<init>", "(I)V");
|
s_integer_constructor = env->GetMethodID(int_class, "<init>", "(I)V");
|
||||||
state.integer_value_method = env->GetMethodID(int_class, "intValue", "()I");
|
s_integer_value_method = env->GetMethodID(int_class, "intValue", "()I");
|
||||||
env->DeleteLocalRef(int_class);
|
env->DeleteLocalRef(int_class);
|
||||||
|
|
||||||
const jclass boolean_class = env->FindClass("java/lang/Boolean");
|
const jclass boolean_class = env->FindClass("java/lang/Boolean");
|
||||||
state.boolean_class = reinterpret_cast<jclass>(env->NewGlobalRef(boolean_class));
|
s_boolean_class = reinterpret_cast<jclass>(env->NewGlobalRef(boolean_class));
|
||||||
state.boolean_constructor = env->GetMethodID(boolean_class, "<init>", "(Z)V");
|
s_boolean_constructor = env->GetMethodID(boolean_class, "<init>", "(Z)V");
|
||||||
state.boolean_value_method = env->GetMethodID(boolean_class, "booleanValue", "()Z");
|
s_boolean_value_method = env->GetMethodID(boolean_class, "booleanValue", "()Z");
|
||||||
env->DeleteLocalRef(boolean_class);
|
env->DeleteLocalRef(boolean_class);
|
||||||
|
|
||||||
const jclass player_input_class =
|
const jclass player_input_class =
|
||||||
env->FindClass("org/yuzu/yuzu_emu/features/input/model/PlayerInput");
|
env->FindClass("org/yuzu/yuzu_emu/features/input/model/PlayerInput");
|
||||||
state.player_input_class = reinterpret_cast<jclass>(env->NewGlobalRef(player_input_class));
|
s_player_input_class = reinterpret_cast<jclass>(env->NewGlobalRef(player_input_class));
|
||||||
state.player_input_constructor = env->GetMethodID(
|
s_player_input_constructor = env->GetMethodID(
|
||||||
player_input_class, "<init>",
|
player_input_class, "<init>",
|
||||||
"(Z[Ljava/lang/String;[Ljava/lang/String;[Ljava/lang/String;ZIJJJJLjava/lang/String;Z)V");
|
"(Z[Ljava/lang/String;[Ljava/lang/String;[Ljava/lang/String;ZIJJJJLjava/lang/String;Z)V");
|
||||||
state.player_input_connected_field = env->GetFieldID(player_input_class, "connected", "Z");
|
s_player_input_connected_field = env->GetFieldID(player_input_class, "connected", "Z");
|
||||||
state.player_input_buttons_field =
|
s_player_input_buttons_field =
|
||||||
env->GetFieldID(player_input_class, "buttons", "[Ljava/lang/String;");
|
env->GetFieldID(player_input_class, "buttons", "[Ljava/lang/String;");
|
||||||
state.player_input_analogs_field =
|
s_player_input_analogs_field =
|
||||||
env->GetFieldID(player_input_class, "analogs", "[Ljava/lang/String;");
|
env->GetFieldID(player_input_class, "analogs", "[Ljava/lang/String;");
|
||||||
state.player_input_motions_field =
|
s_player_input_motions_field =
|
||||||
env->GetFieldID(player_input_class, "motions", "[Ljava/lang/String;");
|
env->GetFieldID(player_input_class, "motions", "[Ljava/lang/String;");
|
||||||
state.player_input_vibration_enabled_field =
|
s_player_input_vibration_enabled_field =
|
||||||
env->GetFieldID(player_input_class, "vibrationEnabled", "Z");
|
env->GetFieldID(player_input_class, "vibrationEnabled", "Z");
|
||||||
state.player_input_vibration_strength_field =
|
s_player_input_vibration_strength_field =
|
||||||
env->GetFieldID(player_input_class, "vibrationStrength", "I");
|
env->GetFieldID(player_input_class, "vibrationStrength", "I");
|
||||||
state.player_input_body_color_left_field =
|
s_player_input_body_color_left_field =
|
||||||
env->GetFieldID(player_input_class, "bodyColorLeft", "J");
|
env->GetFieldID(player_input_class, "bodyColorLeft", "J");
|
||||||
state.player_input_body_color_right_field =
|
s_player_input_body_color_right_field =
|
||||||
env->GetFieldID(player_input_class, "bodyColorRight", "J");
|
env->GetFieldID(player_input_class, "bodyColorRight", "J");
|
||||||
state.player_input_button_color_left_field =
|
s_player_input_button_color_left_field =
|
||||||
env->GetFieldID(player_input_class, "buttonColorLeft", "J");
|
env->GetFieldID(player_input_class, "buttonColorLeft", "J");
|
||||||
state.player_input_button_color_right_field =
|
s_player_input_button_color_right_field =
|
||||||
env->GetFieldID(player_input_class, "buttonColorRight", "J");
|
env->GetFieldID(player_input_class, "buttonColorRight", "J");
|
||||||
state.player_input_profile_name_field =
|
s_player_input_profile_name_field =
|
||||||
env->GetFieldID(player_input_class, "profileName", "Ljava/lang/String;");
|
env->GetFieldID(player_input_class, "profileName", "Ljava/lang/String;");
|
||||||
state.player_input_use_system_vibrator_field =
|
s_player_input_use_system_vibrator_field =
|
||||||
env->GetFieldID(player_input_class, "useSystemVibrator", "Z");
|
env->GetFieldID(player_input_class, "useSystemVibrator", "Z");
|
||||||
env->DeleteLocalRef(player_input_class);
|
env->DeleteLocalRef(player_input_class);
|
||||||
|
|
||||||
const jclass yuzu_input_device_interface =
|
const jclass yuzu_input_device_interface =
|
||||||
env->FindClass("org/yuzu/yuzu_emu/features/input/YuzuInputDevice");
|
env->FindClass("org/yuzu/yuzu_emu/features/input/YuzuInputDevice");
|
||||||
state.yuzu_input_device_interface =
|
s_yuzu_input_device_interface =
|
||||||
reinterpret_cast<jclass>(env->NewGlobalRef(yuzu_input_device_interface));
|
reinterpret_cast<jclass>(env->NewGlobalRef(yuzu_input_device_interface));
|
||||||
state.yuzu_input_device_get_name =
|
s_yuzu_input_device_get_name =
|
||||||
env->GetMethodID(yuzu_input_device_interface, "getName", "()Ljava/lang/String;");
|
env->GetMethodID(yuzu_input_device_interface, "getName", "()Ljava/lang/String;");
|
||||||
state.yuzu_input_device_get_guid =
|
s_yuzu_input_device_get_guid =
|
||||||
env->GetMethodID(yuzu_input_device_interface, "getGUID", "()Ljava/lang/String;");
|
env->GetMethodID(yuzu_input_device_interface, "getGUID", "()Ljava/lang/String;");
|
||||||
state.yuzu_input_device_get_port = env->GetMethodID(yuzu_input_device_interface, "getPort",
|
s_yuzu_input_device_get_port = env->GetMethodID(yuzu_input_device_interface, "getPort",
|
||||||
"()I");
|
"()I");
|
||||||
state.yuzu_input_device_get_supports_vibration =
|
s_yuzu_input_device_get_supports_vibration =
|
||||||
env->GetMethodID(yuzu_input_device_interface, "getSupportsVibration", "()Z");
|
env->GetMethodID(yuzu_input_device_interface, "getSupportsVibration", "()Z");
|
||||||
state.yuzu_input_device_vibrate = env->GetMethodID(yuzu_input_device_interface, "vibrate",
|
s_yuzu_input_device_vibrate = env->GetMethodID(yuzu_input_device_interface, "vibrate",
|
||||||
"(F)V");
|
"(F)V");
|
||||||
state.yuzu_input_device_get_axes =
|
s_yuzu_input_device_get_axes =
|
||||||
env->GetMethodID(yuzu_input_device_interface, "getAxes", "()[Ljava/lang/Integer;");
|
env->GetMethodID(yuzu_input_device_interface, "getAxes", "()[Ljava/lang/Integer;");
|
||||||
state.yuzu_input_device_has_keys =
|
s_yuzu_input_device_has_keys =
|
||||||
env->GetMethodID(yuzu_input_device_interface, "hasKeys", "([I)[Z");
|
env->GetMethodID(yuzu_input_device_interface, "hasKeys", "([I)[Z");
|
||||||
env->DeleteLocalRef(yuzu_input_device_interface);
|
env->DeleteLocalRef(yuzu_input_device_interface);
|
||||||
state.add_netplay_message = env->GetStaticMethodID(state.native_library_class, "addNetPlayMessage",
|
s_add_netplay_message = env->GetStaticMethodID(s_native_library_class, "addNetPlayMessage",
|
||||||
"(ILjava/lang/String;)V");
|
"(ILjava/lang/String;)V");
|
||||||
state.clear_chat = env->GetStaticMethodID(state.native_library_class, "clearChat", "()V");
|
s_clear_chat = env->GetStaticMethodID(s_native_library_class, "clearChat", "()V");
|
||||||
|
|
||||||
// Initialize Android Storage
|
// Initialize Android Storage
|
||||||
Common::FS::Android::RegisterCallbacks(env, state.native_library_class);
|
Common::FS::Android::RegisterCallbacks(env, s_native_library_class);
|
||||||
|
|
||||||
// Initialize applets
|
// Initialize applets
|
||||||
Common::Android::SoftwareKeyboard::InitJNI(env);
|
Common::Android::SoftwareKeyboard::InitJNI(env);
|
||||||
|
|||||||
+18
-4
@@ -22,22 +22,36 @@ template <typename T>
|
|||||||
return std::size_t(sizeof(T) * CHAR_BIT);
|
return std::size_t(sizeof(T) * CHAR_BIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
requires std::is_integral_v<T>
|
||||||
|
[[nodiscard]] constexpr u32 MostSignificantBit(const T value) {
|
||||||
|
return u32(sizeof(T) * CHAR_BIT - 1 - std::countl_zero(value));
|
||||||
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
requires std::is_integral_v<T>
|
requires std::is_integral_v<T>
|
||||||
[[nodiscard]] constexpr T Log2Floor(const T value) {
|
[[nodiscard]] constexpr T Log2Floor(const T value) {
|
||||||
return std::bit_width(value) - 1;
|
return T(MostSignificantBit<T>(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
requires std::is_integral_v<T>
|
requires std::is_integral_v<T>
|
||||||
[[nodiscard]] constexpr T Log2Ceil(const T value) {
|
[[nodiscard]] constexpr T Log2Ceil(const T value) {
|
||||||
return std::bit_width(value - 1);
|
const T log2_f = Log2Floor<T>(value);
|
||||||
|
return T(log2_f + T((value ^ (T(1ULL) << log2_f)) != T(0ULL)));
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
requires std::is_integral_v<T>
|
||||||
|
[[nodiscard]] T NextPow2(T value) {
|
||||||
|
return T(1ULL << (sizeof(T) * CHAR_BIT - std::countl_zero(value - 1U)));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <size_t bit_index, typename T>
|
template <size_t bit_index, typename T>
|
||||||
requires (std::is_integral_v<T> && bit_index < BitSize<T>())
|
requires std::is_integral_v<T>
|
||||||
[[nodiscard]] constexpr bool Bit(const T value) {
|
[[nodiscard]] constexpr bool Bit(const T value) {
|
||||||
return (T(value >> bit_index) & T(1)) == T(1);
|
static_assert(bit_index < BitSize<T>(), "bit_index must be smaller than size of T");
|
||||||
|
return ((value >> bit_index) & T(1)) == T(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Common
|
} // namespace Common
|
||||||
|
|||||||
@@ -25,18 +25,26 @@ template <typename T>
|
|||||||
requires std::is_unsigned_v<T>
|
requires std::is_unsigned_v<T>
|
||||||
inline std::size_t HashValue(T val) {
|
inline std::size_t HashValue(T val) {
|
||||||
const unsigned int size_t_bits = std::numeric_limits<std::size_t>::digits;
|
const unsigned int size_t_bits = std::numeric_limits<std::size_t>::digits;
|
||||||
const unsigned int length = (std::numeric_limits<T>::digits - 1) / static_cast<unsigned int>(size_t_bits);
|
const unsigned int length =
|
||||||
|
(std::numeric_limits<T>::digits - 1) / static_cast<unsigned int>(size_t_bits);
|
||||||
|
|
||||||
std::size_t seed = 0;
|
std::size_t seed = 0;
|
||||||
for (unsigned int i = length * size_t_bits; i > 0; i -= size_t_bits)
|
|
||||||
seed ^= std::size_t(val >> i) + (seed << 6) + (seed >> 2);
|
for (unsigned int i = length * size_t_bits; i > 0; i -= size_t_bits) {
|
||||||
return seed ^= std::size_t(val) + (seed << 6) + (seed >> 2);
|
seed ^= static_cast<size_t>(val >> i) + (seed << 6) + (seed >> 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
seed ^= static_cast<size_t>(val) + (seed << 6) + (seed >> 2);
|
||||||
|
|
||||||
|
return seed;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <size_t Bits>
|
template <size_t Bits>
|
||||||
struct HashCombineImpl {
|
struct HashCombineImpl {
|
||||||
template <typename T>
|
template <typename T>
|
||||||
static inline T fn(T seed, T value) {
|
static inline T fn(T seed, T value) {
|
||||||
return seed ^= value + 0x9e3779b9 + (seed << 6) + (seed >> 2);
|
seed ^= value + 0x9e3779b9 + (seed << 6) + (seed >> 2);
|
||||||
|
return seed;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,3 @@
|
|||||||
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
|
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
|
|
||||||
// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
@@ -15,14 +12,14 @@ namespace Common {
|
|||||||
template <typename N, typename D>
|
template <typename N, typename D>
|
||||||
requires std::is_integral_v<N> && std::is_unsigned_v<D>
|
requires std::is_integral_v<N> && std::is_unsigned_v<D>
|
||||||
[[nodiscard]] constexpr N DivCeil(N number, D divisor) {
|
[[nodiscard]] constexpr N DivCeil(N number, D divisor) {
|
||||||
return N((D(number) + divisor - 1) / divisor);
|
return static_cast<N>((static_cast<D>(number) + divisor - 1) / divisor);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Ceiled integer division with logarithmic divisor in base 2
|
/// Ceiled integer division with logarithmic divisor in base 2
|
||||||
template <typename N, typename D>
|
template <typename N, typename D>
|
||||||
requires std::is_integral_v<N> && std::is_unsigned_v<D>
|
requires std::is_integral_v<N> && std::is_unsigned_v<D>
|
||||||
[[nodiscard]] constexpr N DivCeilLog2(N value, D alignment_log2) {
|
[[nodiscard]] constexpr N DivCeilLog2(N value, D alignment_log2) {
|
||||||
return N((D(value) + (D(1) << alignment_log2) - 1) >> alignment_log2);
|
return static_cast<N>((static_cast<D>(value) + (D(1) << alignment_log2) - 1) >> alignment_log2);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Common
|
} // namespace Common
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
// SPDX-FileCopyrightText: 2015 Citra Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <cstddef>
|
||||||
|
#include <utility>
|
||||||
|
#include <boost/functional/hash.hpp>
|
||||||
|
|
||||||
|
namespace Common {
|
||||||
|
|
||||||
|
struct PairHash {
|
||||||
|
template <class T1, class T2>
|
||||||
|
std::size_t operator()(const std::pair<T1, T2>& pair) const noexcept {
|
||||||
|
std::size_t seed = std::hash<T1>()(pair.first);
|
||||||
|
boost::hash_combine(seed, std::hash<T2>()(pair.second));
|
||||||
|
return seed;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct IdentityHash {
|
||||||
|
[[nodiscard]] size_t operator()(T value) const noexcept {
|
||||||
|
return static_cast<size_t>(value);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Common
|
||||||
+16
-10
@@ -1,6 +1,3 @@
|
|||||||
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
|
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
|
|
||||||
// SPDX-FileCopyrightText: 2013 Dolphin Emulator Project
|
// SPDX-FileCopyrightText: 2013 Dolphin Emulator Project
|
||||||
// SPDX-FileCopyrightText: 2014 Citra Emulator Project
|
// SPDX-FileCopyrightText: 2014 Citra Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
@@ -19,12 +16,14 @@ namespace Common {
|
|||||||
|
|
||||||
[[nodiscard]] constexpr u8 ToHexNibble(char c) {
|
[[nodiscard]] constexpr u8 ToHexNibble(char c) {
|
||||||
if (c >= 65 && c <= 70) {
|
if (c >= 65 && c <= 70) {
|
||||||
return u8(c - 55);
|
return static_cast<u8>(c - 55);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (c >= 97 && c <= 102) {
|
if (c >= 97 && c <= 102) {
|
||||||
return u8(c - 87);
|
return static_cast<u8>(c - 87);
|
||||||
}
|
}
|
||||||
return u8(c - 48);
|
|
||||||
|
return static_cast<u8>(c - 48);
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] std::vector<u8> HexStringToVector(std::string_view str, bool little_endian);
|
[[nodiscard]] std::vector<u8> HexStringToVector(std::string_view str, bool little_endian);
|
||||||
@@ -32,28 +31,35 @@ namespace Common {
|
|||||||
template <std::size_t Size, bool le = false>
|
template <std::size_t Size, bool le = false>
|
||||||
[[nodiscard]] constexpr std::array<u8, Size> HexStringToArray(std::string_view str) {
|
[[nodiscard]] constexpr std::array<u8, Size> HexStringToArray(std::string_view str) {
|
||||||
ASSERT_MSG(Size * 2 <= str.size(), "Invalid string size");
|
ASSERT_MSG(Size * 2 <= str.size(), "Invalid string size");
|
||||||
|
|
||||||
std::array<u8, Size> out{};
|
std::array<u8, Size> out{};
|
||||||
if constexpr (le) {
|
if constexpr (le) {
|
||||||
for (std::size_t i = 2 * Size - 2; i <= 2 * Size; i -= 2) {
|
for (std::size_t i = 2 * Size - 2; i <= 2 * Size; i -= 2) {
|
||||||
out[i / 2] = u8((ToHexNibble(str[i]) << 4) | ToHexNibble(str[i + 1]));
|
out[i / 2] = static_cast<u8>((ToHexNibble(str[i]) << 4) | ToHexNibble(str[i + 1]));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (std::size_t i = 0; i < 2 * Size; i += 2) {
|
for (std::size_t i = 0; i < 2 * Size; i += 2) {
|
||||||
out[i / 2] = u8((ToHexNibble(str[i]) << 4) | ToHexNibble(str[i + 1]));
|
out[i / 2] = static_cast<u8>((ToHexNibble(str[i]) << 4) | ToHexNibble(str[i + 1]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename ContiguousContainer>
|
template <typename ContiguousContainer>
|
||||||
requires std::is_same_v<typename ContiguousContainer::value_type, u8>
|
|
||||||
[[nodiscard]] std::string HexToString(const ContiguousContainer& data, bool upper = true) {
|
[[nodiscard]] std::string HexToString(const ContiguousContainer& data, bool upper = true) {
|
||||||
|
static_assert(std::is_same_v<typename ContiguousContainer::value_type, u8>,
|
||||||
|
"Underlying type within the contiguous container must be u8.");
|
||||||
|
|
||||||
constexpr std::size_t pad_width = 2;
|
constexpr std::size_t pad_width = 2;
|
||||||
|
|
||||||
std::string out;
|
std::string out;
|
||||||
out.reserve(std::size(data) * pad_width);
|
out.reserve(std::size(data) * pad_width);
|
||||||
|
|
||||||
const auto format_str = fmt::runtime(upper ? "{:02X}" : "{:02x}");
|
const auto format_str = fmt::runtime(upper ? "{:02X}" : "{:02x}");
|
||||||
for (const u8 c : data)
|
for (const u8 c : data) {
|
||||||
out += fmt::format(format_str, c);
|
out += fmt::format(format_str, c);
|
||||||
|
}
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+6
-10
@@ -10,7 +10,6 @@
|
|||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <regex>
|
#include <regex>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <boost/algorithm/string/predicate.hpp>
|
|
||||||
|
|
||||||
#if defined(__ANDROID__)
|
#if defined(__ANDROID__)
|
||||||
#include <android/log.h>
|
#include <android/log.h>
|
||||||
@@ -96,10 +95,9 @@ std::string FormatLogMessage(const Entry& entry) noexcept {
|
|||||||
|
|
||||||
template <typename It>
|
template <typename It>
|
||||||
Level GetLevelByName(const It begin, const It end) {
|
Level GetLevelByName(const It begin, const It end) {
|
||||||
std::string_view const sv{begin, end};
|
|
||||||
for (u32 i = 0; i < u32(Level::Count); ++i) {
|
for (u32 i = 0; i < u32(Level::Count); ++i) {
|
||||||
auto const level_name = GetLevelName(Level(i));
|
const char* level_name = GetLevelName(Level(i));
|
||||||
if (boost::iequals(sv, level_name))
|
if (Common::ComparePartialString(begin, end, level_name))
|
||||||
return Level(i);
|
return Level(i);
|
||||||
}
|
}
|
||||||
return Level::Count;
|
return Level::Count;
|
||||||
@@ -107,10 +105,9 @@ Level GetLevelByName(const It begin, const It end) {
|
|||||||
|
|
||||||
template <typename It>
|
template <typename It>
|
||||||
Class GetClassByName(const It begin, const It end) {
|
Class GetClassByName(const It begin, const It end) {
|
||||||
std::string_view const sv{begin, end};
|
|
||||||
for (u32 i = 0; i < u32(Class::Count); ++i) {
|
for (u32 i = 0; i < u32(Class::Count); ++i) {
|
||||||
auto const level_name = GetLogClassName(Class(i));
|
const char* level_name = GetLogClassName(Class(i));
|
||||||
if (boost::iequals(sv, level_name))
|
if (Common::ComparePartialString(begin, end, level_name))
|
||||||
return Class(i);
|
return Class(i);
|
||||||
}
|
}
|
||||||
return Class::Count;
|
return Class::Count;
|
||||||
@@ -123,13 +120,12 @@ bool ParseFilterRule(Filter& instance, Iterator begin, Iterator end) {
|
|||||||
LOG_ERROR(Log, "Invalid log filter. Must specify a log level after `:`: {}", std::string(begin, end));
|
LOG_ERROR(Log, "Invalid log filter. Must specify a log level after `:`: {}", std::string(begin, end));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
auto const sv = std::string_view{begin, level_separator};
|
const Level level = GetLevelByName(level_separator + 1, end);
|
||||||
auto const level = GetLevelByName(level_separator + 1, end);
|
|
||||||
if (level == Level::Count) {
|
if (level == Level::Count) {
|
||||||
LOG_ERROR(Log, "Unknown log level in filter: {}", std::string(begin, end));
|
LOG_ERROR(Log, "Unknown log level in filter: {}", std::string(begin, end));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (boost::iequals(sv, "*")) {
|
if (Common::ComparePartialString(begin, level_separator, "*")) {
|
||||||
instance.class_levels.fill(level);
|
instance.class_levels.fill(level);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,9 +8,6 @@
|
|||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <boost/algorithm/string/classification.hpp>
|
|
||||||
#include <boost/algorithm/string/replace.hpp>
|
|
||||||
#include <boost/algorithm/string/split.hpp>
|
|
||||||
|
|
||||||
#include "common/logging.h"
|
#include "common/logging.h"
|
||||||
#include "common/param_package.h"
|
#include "common/param_package.h"
|
||||||
@@ -18,16 +15,17 @@
|
|||||||
|
|
||||||
namespace Common {
|
namespace Common {
|
||||||
|
|
||||||
constexpr auto KEY_VALUE_SEPARATOR = ":";
|
constexpr char KEY_VALUE_SEPARATOR = ':';
|
||||||
constexpr auto PARAM_SEPARATOR = ",";
|
constexpr char PARAM_SEPARATOR = ',';
|
||||||
constexpr auto ESCAPE_CHARACTER = "$";
|
|
||||||
constexpr auto KEY_VALUE_SEPARATOR_ESCAPE = "$0";
|
constexpr char ESCAPE_CHARACTER = '$';
|
||||||
constexpr auto PARAM_SEPARATOR_ESCAPE = "$1";
|
constexpr char KEY_VALUE_SEPARATOR_ESCAPE[] = "$0";
|
||||||
constexpr auto ESCAPE_CHARACTER_ESCAPE = "$2";
|
constexpr char PARAM_SEPARATOR_ESCAPE[] = "$1";
|
||||||
|
constexpr char ESCAPE_CHARACTER_ESCAPE[] = "$2";
|
||||||
|
|
||||||
/// A placeholder for empty param packages to avoid empty strings
|
/// A placeholder for empty param packages to avoid empty strings
|
||||||
/// (they may be recognized as "not set" by some frontend libraries like qt)
|
/// (they may be recognized as "not set" by some frontend libraries like qt)
|
||||||
constexpr auto EMPTY_PLACEHOLDER = "[empty]";
|
constexpr char EMPTY_PLACEHOLDER[] = "[empty]";
|
||||||
|
|
||||||
ParamPackage::ParamPackage(const std::string& serialized) {
|
ParamPackage::ParamPackage(const std::string& serialized) {
|
||||||
if (serialized == EMPTY_PLACEHOLDER) {
|
if (serialized == EMPTY_PLACEHOLDER) {
|
||||||
@@ -35,20 +33,20 @@ ParamPackage::ParamPackage(const std::string& serialized) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::string> pairs;
|
std::vector<std::string> pairs;
|
||||||
boost::split(pairs, serialized, boost::is_any_of(PARAM_SEPARATOR));
|
Common::SplitString(serialized, PARAM_SEPARATOR, pairs);
|
||||||
|
|
||||||
for (const std::string& pair : pairs) {
|
for (const std::string& pair : pairs) {
|
||||||
std::vector<std::string> key_value;
|
std::vector<std::string> key_value;
|
||||||
boost::split(key_value, pair, boost::is_any_of(KEY_VALUE_SEPARATOR));
|
Common::SplitString(pair, KEY_VALUE_SEPARATOR, key_value);
|
||||||
if (key_value.size() != 2) {
|
if (key_value.size() != 2) {
|
||||||
LOG_ERROR(Common, "invalid key pair {}", pair);
|
LOG_ERROR(Common, "invalid key pair {}", pair);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto& part : key_value) {
|
for (std::string& part : key_value) {
|
||||||
boost::replace_all(part, KEY_VALUE_SEPARATOR_ESCAPE, KEY_VALUE_SEPARATOR);
|
part = Common::ReplaceAll(part, KEY_VALUE_SEPARATOR_ESCAPE, {KEY_VALUE_SEPARATOR});
|
||||||
boost::replace_all(part, PARAM_SEPARATOR_ESCAPE, PARAM_SEPARATOR);
|
part = Common::ReplaceAll(part, PARAM_SEPARATOR_ESCAPE, {PARAM_SEPARATOR});
|
||||||
boost::replace_all(part, ESCAPE_CHARACTER_ESCAPE, ESCAPE_CHARACTER);
|
part = Common::ReplaceAll(part, ESCAPE_CHARACTER_ESCAPE, {ESCAPE_CHARACTER});
|
||||||
}
|
}
|
||||||
|
|
||||||
Set(key_value[0], std::move(key_value[1]));
|
Set(key_value[0], std::move(key_value[1]));
|
||||||
@@ -65,10 +63,10 @@ std::string ParamPackage::Serialize() const {
|
|||||||
|
|
||||||
for (const auto& pair : data) {
|
for (const auto& pair : data) {
|
||||||
std::array<std::string, 2> key_value{{pair.first, pair.second}};
|
std::array<std::string, 2> key_value{{pair.first, pair.second}};
|
||||||
for (auto& part : key_value) {
|
for (std::string& part : key_value) {
|
||||||
boost::replace_all(part, ESCAPE_CHARACTER, ESCAPE_CHARACTER_ESCAPE);
|
part = Common::ReplaceAll(part, {ESCAPE_CHARACTER}, ESCAPE_CHARACTER_ESCAPE);
|
||||||
boost::replace_all(part, PARAM_SEPARATOR, PARAM_SEPARATOR_ESCAPE);
|
part = Common::ReplaceAll(part, {PARAM_SEPARATOR}, PARAM_SEPARATOR_ESCAPE);
|
||||||
boost::replace_all(part, KEY_VALUE_SEPARATOR, KEY_VALUE_SEPARATOR_ESCAPE);
|
part = Common::ReplaceAll(part, {KEY_VALUE_SEPARATOR}, KEY_VALUE_SEPARATOR_ESCAPE);
|
||||||
}
|
}
|
||||||
result += key_value[0] + KEY_VALUE_SEPARATOR + key_value[1] + PARAM_SEPARATOR;
|
result += key_value[0] + KEY_VALUE_SEPARATOR + key_value[1] + PARAM_SEPARATOR;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -178,6 +178,10 @@ bool IsGPUFenceBehaviorAccurate() {
|
|||||||
return values.gpu_fence_behavior.GetValue() == GpuFenceBehavior::Accurate;
|
return values.gpu_fence_behavior.GetValue() == GpuFenceBehavior::Accurate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IsGPUFenceBehaviorStrict() {
|
||||||
|
return values.gpu_fence_behavior.GetValue() == GpuFenceBehavior::Strict;
|
||||||
|
}
|
||||||
|
|
||||||
bool IsFastmemEnabled() {
|
bool IsFastmemEnabled() {
|
||||||
if (values.cpu_accuracy.GetValue() == Settings::CpuAccuracy::Debugging)
|
if (values.cpu_accuracy.GetValue() == Settings::CpuAccuracy::Debugging)
|
||||||
return bool(values.cpuopt_fastmem);
|
return bool(values.cpuopt_fastmem);
|
||||||
|
|||||||
@@ -525,7 +525,7 @@ struct Values {
|
|||||||
SwitchableSetting<GpuFenceBehavior, true> gpu_fence_behavior{linkage,
|
SwitchableSetting<GpuFenceBehavior, true> gpu_fence_behavior{linkage,
|
||||||
GpuFenceBehavior::Default,
|
GpuFenceBehavior::Default,
|
||||||
GpuFenceBehavior::Default,
|
GpuFenceBehavior::Default,
|
||||||
GpuFenceBehavior::Accurate,
|
GpuFenceBehavior::Strict,
|
||||||
"gpu_fence_behavior",
|
"gpu_fence_behavior",
|
||||||
Category::RendererAdvanced,
|
Category::RendererAdvanced,
|
||||||
Specialization::Default,
|
Specialization::Default,
|
||||||
@@ -655,6 +655,13 @@ struct Values {
|
|||||||
|
|
||||||
SwitchableSetting<bool> rescale_hack{linkage, false, "rescale_hack",
|
SwitchableSetting<bool> rescale_hack{linkage, false, "rescale_hack",
|
||||||
Category::RendererHacks};
|
Category::RendererHacks};
|
||||||
|
SwitchableSetting<bool> enable_gpu_buffer_readback{linkage,
|
||||||
|
false,
|
||||||
|
"enable_gpu_buffer_readback",
|
||||||
|
Category::RendererAdvanced,
|
||||||
|
Specialization::Default,
|
||||||
|
true,
|
||||||
|
true};
|
||||||
|
|
||||||
SwitchableSetting<bool> use_asynchronous_shaders{linkage, false, "use_asynchronous_shaders",
|
SwitchableSetting<bool> use_asynchronous_shaders{linkage, false, "use_asynchronous_shaders",
|
||||||
Category::RendererHacks};
|
Category::RendererHacks};
|
||||||
@@ -972,6 +979,7 @@ bool IsDMALevelSafe();
|
|||||||
bool IsGPUFenceBehaviorDefault();
|
bool IsGPUFenceBehaviorDefault();
|
||||||
bool IsGPUFenceBehaviorBalanced();
|
bool IsGPUFenceBehaviorBalanced();
|
||||||
bool IsGPUFenceBehaviorAccurate();
|
bool IsGPUFenceBehaviorAccurate();
|
||||||
|
bool IsGPUFenceBehaviorStrict();
|
||||||
|
|
||||||
bool IsFastmemEnabled();
|
bool IsFastmemEnabled();
|
||||||
void SetNceEnabled(bool is_64bit);
|
void SetNceEnabled(bool is_64bit);
|
||||||
|
|||||||
@@ -137,7 +137,7 @@ ENUM(VramUsageMode, Conservative, Aggressive);
|
|||||||
ENUM(RendererBackend, OpenGL_GLSL, Vulkan, Null, OpenGL_GLASM, OpenGL_SPIRV);
|
ENUM(RendererBackend, OpenGL_GLSL, Vulkan, Null, OpenGL_GLASM, OpenGL_SPIRV);
|
||||||
ENUM(GpuAccuracy, Low, High);
|
ENUM(GpuAccuracy, Low, High);
|
||||||
ENUM(DmaAccuracy, Default, Unsafe, Safe);
|
ENUM(DmaAccuracy, Default, Unsafe, Safe);
|
||||||
ENUM(GpuFenceBehavior, Default, Immediate, Balanced, Accurate);
|
ENUM(GpuFenceBehavior, Default, Immediate, Balanced, Accurate, Strict);
|
||||||
ENUM(CpuBackend, Dynarmic, Nce);
|
ENUM(CpuBackend, Dynarmic, Nce);
|
||||||
ENUM(CpuAccuracy, Auto, Accurate, Unsafe, Paranoid, Debugging);
|
ENUM(CpuAccuracy, Auto, Accurate, Unsafe, Paranoid, Debugging);
|
||||||
ENUM(CpuClock, Normal, Boost, Overclock)
|
ENUM(CpuClock, Normal, Boost, Overclock)
|
||||||
|
|||||||
@@ -6,7 +6,6 @@
|
|||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <algorithm>
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#else
|
#else
|
||||||
@@ -21,22 +20,19 @@ namespace Common {
|
|||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
static std::vector<std::pair<u64, u64>> vector_regions {};
|
static std::vector<std::pair<u64, u64>> vector_regions {};
|
||||||
static std::mutex vector_regions_mutex {};
|
|
||||||
|
|
||||||
// Workaround for handling non-commited memory accessed by Dynarmic; usually result of an error
|
// Workaround for handling non-commited memory accessed by Dynarmic; usually result of an error
|
||||||
static LONG WINAPI FakePageFaultHandler(PEXCEPTION_POINTERS info) {
|
static LONG WINAPI FakePageFaultHandler(PEXCEPTION_POINTERS info) {
|
||||||
DWORD code = info->ExceptionRecord->ExceptionCode;
|
DWORD code = info->ExceptionRecord->ExceptionCode;
|
||||||
u64 exception_addr = reinterpret_cast<u64>(info->ExceptionRecord->ExceptionInformation[1]);
|
u64 exception_addr = reinterpret_cast<u64>(info->ExceptionRecord->ExceptionAddress);
|
||||||
|
|
||||||
if (code != EXCEPTION_ACCESS_VIOLATION || info->ExceptionRecord->ExceptionInformation[0] == 1) {
|
if (code != EXCEPTION_ACCESS_VIOLATION) {
|
||||||
// Not our problem
|
// Not our problem
|
||||||
return EXCEPTION_CONTINUE_SEARCH;
|
return EXCEPTION_CONTINUE_SEARCH;
|
||||||
}
|
}
|
||||||
|
|
||||||
u64 addr = 0, addr2 = 0;
|
u64 addr = 0, addr2 = 0;
|
||||||
|
|
||||||
{
|
|
||||||
std::lock_guard lock(vector_regions_mutex);
|
|
||||||
for (auto region: vector_regions) {
|
for (auto region: vector_regions) {
|
||||||
auto addr_shifted = exception_addr >> HostPageBits;
|
auto addr_shifted = exception_addr >> HostPageBits;
|
||||||
if (region.first <= addr_shifted && addr_shifted <= region.second) {
|
if (region.first <= addr_shifted && addr_shifted <= region.second) {
|
||||||
@@ -52,7 +48,6 @@ static LONG WINAPI FakePageFaultHandler(PEXCEPTION_POINTERS info) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (addr == 0 && addr2 == 0) {
|
if (addr == 0 && addr2 == 0) {
|
||||||
// Not our problem
|
// Not our problem
|
||||||
@@ -82,16 +77,8 @@ bool CommitVectorPage(uintptr_t addr, bool write) noexcept {
|
|||||||
auto res = VirtualQuery(reinterpret_cast<void*>(addr), &info, sizeof(info));
|
auto res = VirtualQuery(reinterpret_cast<void*>(addr), &info, sizeof(info));
|
||||||
if (res == 0) {
|
if (res == 0) {
|
||||||
LOG_CRITICAL(HW_Memory, "Failed to query large buffer region at {:#x} with error {}, will try committing anyway", addr, GetLastError());
|
LOG_CRITICAL(HW_Memory, "Failed to query large buffer region at {:#x} with error {}, will try committing anyway", addr, GetLastError());
|
||||||
} else if (info.State == MEM_COMMIT) {
|
|
||||||
DWORD old_protect {};
|
|
||||||
auto perm = write ? PAGE_READWRITE : PAGE_READONLY;
|
|
||||||
if (!VirtualProtect(reinterpret_cast<void*>(addr), HostPageSize, perm, &old_protect)) {
|
|
||||||
LOG_ERROR(HW_Memory, "Failed to change permissions of large buffer region at {:#x}, error {}", addr, GetLastError());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
} else if (info.State != MEM_RESERVE) {
|
} else if (info.State != MEM_RESERVE) {
|
||||||
LOG_ERROR(HW_Memory, "Tried to commit an unreserved large buffer region at {:#x} that is not mapped (state {:#x})", addr, info.State);
|
LOG_ERROR(HW_Memory, "Tried to commit an unreserved large buffer region at {:#x} that is not mapped or is already committed (state {:#x})", addr, info.State);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -136,8 +123,7 @@ void* AllocateMemoryPages(std::size_t size) noexcept {
|
|||||||
void* base = VirtualAlloc(nullptr, size, MEM_RESERVE, PAGE_READWRITE);
|
void* base = VirtualAlloc(nullptr, size, MEM_RESERVE, PAGE_READWRITE);
|
||||||
|
|
||||||
if (base != nullptr) {
|
if (base != nullptr) {
|
||||||
std::lock_guard lock(vector_regions_mutex);
|
vector_regions.emplace_back(reinterpret_cast<u64>(base), reinterpret_cast<u64>(base) + size);
|
||||||
vector_regions.emplace_back(reinterpret_cast<u64>(base) >> HostPageBits, (reinterpret_cast<u64>(base) + size) >> HostPageBits);
|
|
||||||
|
|
||||||
static std::once_flag flag;
|
static std::once_flag flag;
|
||||||
std::call_once(flag, []() { AddVectoredExceptionHandler(1, FakePageFaultHandler); });
|
std::call_once(flag, []() { AddVectoredExceptionHandler(1, FakePageFaultHandler); });
|
||||||
@@ -163,8 +149,6 @@ void FreeMemoryPages(void* base, [[maybe_unused]] std::size_t size) noexcept {
|
|||||||
if (!base)
|
if (!base)
|
||||||
return;
|
return;
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
std::lock_guard lock(vector_regions_mutex);
|
|
||||||
std::erase_if(vector_regions, [base](const auto& r) {return r.first == reinterpret_cast<u64>(base); });
|
|
||||||
ASSERT(VirtualFree(base, 0, MEM_RELEASE));
|
ASSERT(VirtualFree(base, 0, MEM_RELEASE));
|
||||||
#else
|
#else
|
||||||
ASSERT(munmap(base, size) == 0);
|
ASSERT(munmap(base, size) == 0);
|
||||||
|
|||||||
@@ -28,9 +28,9 @@ constexpr u64 HostPageBits = 12;
|
|||||||
constexpr u64 HostPageMask = ~(HostPageSize - 1);
|
constexpr u64 HostPageMask = ~(HostPageSize - 1);
|
||||||
bool CommitVectorPage(uintptr_t addr, bool write) noexcept;
|
bool CommitVectorPage(uintptr_t addr, bool write) noexcept;
|
||||||
#else
|
#else
|
||||||
inline const u64 HostPageSize = sysconf(_SC_PAGESIZE);
|
const u64 HostPageSize = sysconf(_SC_PAGESIZE);
|
||||||
inline const u64 HostPageBits = std::countr_zero(HostPageSize);
|
const u64 HostPageBits = std::countr_zero(HostPageSize);
|
||||||
inline const u64 HostPageMask = ~(HostPageSize - 1);
|
const u64 HostPageMask = ~(HostPageSize - 1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void* AllocateMemoryPages(std::size_t size) noexcept;
|
void* AllocateMemoryPages(std::size_t size) noexcept;
|
||||||
@@ -81,8 +81,8 @@ public:
|
|||||||
UNREACHABLE_MSG("Out of bounds RW access on SparseLargeVector @ {}", index);
|
UNREACHABLE_MSG("Out of bounds RW access on SparseLargeVector @ {}", index);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!IsCommittedPage(index) && !CommitPage(index)) {
|
if (!IsCommittedPage(index)) {
|
||||||
UNREACHABLE_MSG("Cannot access SparseLargeVector index {} with RW permission", index);
|
CommitPage(index);
|
||||||
}
|
}
|
||||||
return base_ptr[index];
|
return base_ptr[index];
|
||||||
}
|
}
|
||||||
@@ -103,7 +103,8 @@ public:
|
|||||||
LOG_CRITICAL(Common_Memory, "Out of bounds write on SparseLargeVector @ {}", index);
|
LOG_CRITICAL(Common_Memory, "Out of bounds write on SparseLargeVector @ {}", index);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (IsCommittedPage(index) || CommitPage(index))
|
if (!IsCommittedPage(index))
|
||||||
|
CommitPage(index);
|
||||||
base_ptr[index] = value;
|
base_ptr[index] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -176,22 +177,16 @@ private:
|
|||||||
return (val >> (page & 63)) & 1;
|
return (val >> (page & 63)) & 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr bool CommitPage(std::size_t index) noexcept {
|
constexpr void CommitPage(std::size_t index) noexcept {
|
||||||
auto page_index = (index * sizeof(T)) >> HostPageBits;
|
auto page_index = (index * sizeof(T)) >> HostPageBits;
|
||||||
auto page = reinterpret_cast<uintptr_t>(base_ptr + index) & HostPageMask;
|
auto page = reinterpret_cast<uintptr_t>(base_ptr + index) & HostPageMask;
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
if (!CommitVectorPage(page, true)) {
|
CommitVectorPage(page, true);
|
||||||
return false;
|
|
||||||
}
|
|
||||||
#else
|
#else
|
||||||
if (mprotect(reinterpret_cast<void*>(page), HostPageSize, PROT_READ | PROT_WRITE) != 0) {
|
mprotect(reinterpret_cast<void*>(page), HostPageSize, PROT_READ | PROT_WRITE);
|
||||||
LOG_ERROR(Common_Memory, "Failed to commit large buffer region at index {}, error {}", index, strerror(errno));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
committed_pages[page_index >> 6].fetch_or(1ULL << (page_index & 63), std::memory_order_release);
|
committed_pages[page_index >> 6].fetch_or(1ULL << (page_index & 63), std::memory_order_release);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr void DecommitPage(std::size_t index) noexcept {
|
constexpr void DecommitPage(std::size_t index) noexcept {
|
||||||
|
|||||||
@@ -24,6 +24,22 @@
|
|||||||
|
|
||||||
namespace Common {
|
namespace Common {
|
||||||
|
|
||||||
|
/// Make a string lowercase
|
||||||
|
std::string ToLower(const std::string_view sv) {
|
||||||
|
std::string str{sv};
|
||||||
|
std::transform(str.begin(), str.end(), str.begin(),
|
||||||
|
[](auto const c) { return char(std::tolower(c)); });
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Make a string uppercase
|
||||||
|
std::string ToUpper(const std::string_view sv) {
|
||||||
|
std::string str{sv};
|
||||||
|
std::transform(str.begin(), str.end(), str.begin(),
|
||||||
|
[](auto const c) { return char(std::toupper(c)); });
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
bool SplitPath(const std::string& full_path, std::string* _pPath, std::string* _pFilename,
|
bool SplitPath(const std::string& full_path, std::string* _pPath, std::string* _pFilename,
|
||||||
std::string* _pExtension) {
|
std::string* _pExtension) {
|
||||||
if (full_path.empty())
|
if (full_path.empty())
|
||||||
@@ -64,6 +80,41 @@ bool SplitPath(const std::string& full_path, std::string* _pPath, std::string* _
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SplitString(const std::string& str, const char delim, std::vector<std::string>& output) {
|
||||||
|
std::istringstream iss(str);
|
||||||
|
output.resize(1);
|
||||||
|
|
||||||
|
while (std::getline(iss, *output.rbegin(), delim)) {
|
||||||
|
output.emplace_back();
|
||||||
|
}
|
||||||
|
|
||||||
|
output.pop_back();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string TabsToSpaces(int tab_size, std::string in) {
|
||||||
|
std::size_t i = 0;
|
||||||
|
|
||||||
|
while ((i = in.find('\t')) != std::string::npos) {
|
||||||
|
in.replace(i, 1, tab_size, ' ');
|
||||||
|
}
|
||||||
|
|
||||||
|
return in;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string ReplaceAll(std::string result, const std::string& src, const std::string& dest) {
|
||||||
|
std::size_t pos = 0;
|
||||||
|
|
||||||
|
if (src == dest)
|
||||||
|
return result;
|
||||||
|
|
||||||
|
while ((pos = result.find(src, pos)) != std::string::npos) {
|
||||||
|
result.replace(pos, src.size(), dest);
|
||||||
|
pos += dest.length();
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
std::string UTF16ToUTF8(std::u16string_view input) {
|
std::string UTF16ToUTF8(std::u16string_view input) {
|
||||||
std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t> convert;
|
std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t> convert;
|
||||||
return convert.to_bytes(input.data(), input.data() + input.size());
|
return convert.to_bytes(input.data(), input.data() + input.size());
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
// SPDX-FileCopyrightText: 2013 Dolphin Emulator Project
|
// SPDX-FileCopyrightText: 2013 Dolphin Emulator Project
|
||||||
@@ -16,6 +16,12 @@
|
|||||||
|
|
||||||
namespace Common {
|
namespace Common {
|
||||||
|
|
||||||
|
/// Make a string lowercase
|
||||||
|
[[nodiscard]] std::string ToLower(const std::string_view sv);
|
||||||
|
|
||||||
|
/// Make a string uppercase
|
||||||
|
[[nodiscard]] std::string ToUpper(const std::string_view sv);
|
||||||
|
|
||||||
[[nodiscard]] inline std::string StringFromBuffer(std::span<const u8> data) noexcept {
|
[[nodiscard]] inline std::string StringFromBuffer(std::span<const u8> data) noexcept {
|
||||||
return std::string(data.begin(), std::find(data.begin(), data.end(), '\0'));
|
return std::string(data.begin(), std::find(data.begin(), data.end(), '\0'));
|
||||||
}
|
}
|
||||||
@@ -23,8 +29,37 @@ namespace Common {
|
|||||||
return std::string(data.begin(), std::find(data.begin(), data.end(), '\0'));
|
return std::string(data.begin(), std::find(data.begin(), data.end(), '\0'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Turns " hej " into "hej". Also handles tabs.
|
||||||
|
[[nodiscard]] inline std::string StripSpaces(const std::string_view str) noexcept {
|
||||||
|
const std::size_t s = str.find_first_not_of(" \t\r\n");
|
||||||
|
if (str.npos != s)
|
||||||
|
return std::string{str.substr(s, str.find_last_not_of(" \t\r\n") - s + 1)};
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
/// "\"hello\"" is turned to "hello"
|
||||||
|
/// This one assumes that the string has already been space stripped in both
|
||||||
|
/// ends, as done by StripSpaces above, for example.
|
||||||
|
[[nodiscard]] inline std::string StripQuotes(const std::string_view s) noexcept {
|
||||||
|
if (s.size() && '\"' == s[0] && '\"' == *s.rbegin())
|
||||||
|
return std::string{s.substr(1, s.size() - 2)};
|
||||||
|
return std::string{s};
|
||||||
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] inline std::string StringFromBool(bool value) noexcept {
|
||||||
|
return value ? "True" : "False";
|
||||||
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] std::string TabsToSpaces(int tab_size, std::string in);
|
||||||
|
|
||||||
|
void SplitString(const std::string& str, char delim, std::vector<std::string>& output);
|
||||||
|
|
||||||
// "C:/Windows/winhelp.exe" to "C:/Windows/", "winhelp", ".exe"
|
// "C:/Windows/winhelp.exe" to "C:/Windows/", "winhelp", ".exe"
|
||||||
bool SplitPath(const std::string& full_path, std::string* _pPath, std::string* _pFilename, std::string* _pExtension);
|
bool SplitPath(const std::string& full_path, std::string* _pPath, std::string* _pFilename,
|
||||||
|
std::string* _pExtension);
|
||||||
|
|
||||||
|
[[nodiscard]] std::string ReplaceAll(std::string result, const std::string& src,
|
||||||
|
const std::string& dest);
|
||||||
|
|
||||||
[[nodiscard]] std::string UTF16ToUTF8(std::u16string_view input);
|
[[nodiscard]] std::string UTF16ToUTF8(std::u16string_view input);
|
||||||
[[nodiscard]] std::u16string UTF8ToUTF16(std::string_view input);
|
[[nodiscard]] std::u16string UTF8ToUTF16(std::string_view input);
|
||||||
@@ -38,13 +73,30 @@ bool SplitPath(const std::string& full_path, std::string* _pPath, std::string* _
|
|||||||
|
|
||||||
[[nodiscard]] std::u16string U16StringFromBuffer(const u16* input, std::size_t length);
|
[[nodiscard]] std::u16string U16StringFromBuffer(const u16* input, std::size_t length);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compares the string defined by the range [`begin`, `end`) to the null-terminated C-string
|
||||||
|
* `other` for equality.
|
||||||
|
*/
|
||||||
|
template <typename InIt>
|
||||||
|
[[nodiscard]] inline bool ComparePartialString(InIt begin, InIt end, const char* other) noexcept {
|
||||||
|
for (; begin != end && *other != '\0'; ++begin, ++other) {
|
||||||
|
if (*begin != *other) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Only return true if both strings finished at the same point
|
||||||
|
return (begin == end) == (*other == '\0');
|
||||||
|
}
|
||||||
|
|
||||||
/// Creates a std::string from a fixed-size NUL-terminated char buffer. If the buffer isn't
|
/// Creates a std::string from a fixed-size NUL-terminated char buffer. If the buffer isn't
|
||||||
/// NUL-terminated then the string ends at max_len characters.
|
/// NUL-terminated then the string ends at max_len characters.
|
||||||
[[nodiscard]] std::string StringFromFixedZeroTerminatedBuffer(std::string_view buffer, std::size_t max_len);
|
[[nodiscard]] std::string StringFromFixedZeroTerminatedBuffer(std::string_view buffer,
|
||||||
|
std::size_t max_len);
|
||||||
|
|
||||||
/// Creates a UTF-16 std::u16string from a fixed-size NUL-terminated char buffer. If the buffer isn't
|
/// Creates a UTF-16 std::u16string from a fixed-size NUL-terminated char buffer. If the buffer isn't
|
||||||
/// null-terminated, then the string ends at the greatest multiple of two less then or equal to
|
/// null-terminated, then the string ends at the greatest multiple of two less then or equal to
|
||||||
/// max_len_bytes.
|
/// max_len_bytes.
|
||||||
[[nodiscard]] std::u16string UTF16StringFromFixedZeroTerminatedBuffer(std::u16string_view buffer, std::size_t max_len);
|
[[nodiscard]] std::u16string UTF16StringFromFixedZeroTerminatedBuffer(std::u16string_view buffer,
|
||||||
|
std::size_t max_len);
|
||||||
|
|
||||||
} // namespace Common
|
} // namespace Common
|
||||||
|
|||||||
@@ -1,46 +0,0 @@
|
|||||||
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
|
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
|
|
||||||
#include <cstring>
|
|
||||||
|
|
||||||
#include "common/zbic_compression.h"
|
|
||||||
|
|
||||||
#define ZSTD_ZBIC_SUPPORT 1
|
|
||||||
#define ZSTDLIB_VISIBLE static
|
|
||||||
#define ZSTDLIB_HIDDEN static
|
|
||||||
#define ZSTDERRORLIB_VISIBLE static
|
|
||||||
#define ZSTDERRORLIB_HIDDEN static
|
|
||||||
#undef ZSTD_MULTITHREAD
|
|
||||||
|
|
||||||
#if defined(__ANDROID__)
|
|
||||||
#undef _GNU_SOURCE
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "zstd.h"
|
|
||||||
#define g_ZSTD_threading_useless_symbol g_ZSTD_zbic_threading_useless_symbol
|
|
||||||
#include "zstd.c"
|
|
||||||
#undef g_ZSTD_threading_useless_symbol
|
|
||||||
|
|
||||||
namespace Common::Compression {
|
|
||||||
|
|
||||||
bool IsZBIC(std::span<const u8> src) {
|
|
||||||
if (src.size() < sizeof(u32)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
u32 magic = 0;
|
|
||||||
std::memcpy(&magic, src.data(), sizeof(u32));
|
|
||||||
return magic == ZSTD_MAGICNUMBER; // 0x4349425A ("ZBIC")
|
|
||||||
}
|
|
||||||
|
|
||||||
int DecompressDataZBIC(std::span<u8> dst, std::span<const u8> src) {
|
|
||||||
if (dst.empty() || src.empty()) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
const size_t res = ZSTD_decompress(dst.data(), dst.size(), src.data(), src.size());
|
|
||||||
if (ZSTD_isError(res)) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
return static_cast<int>(res);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Common::Compression
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
|
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <span>
|
|
||||||
#include "common/common_types.h"
|
|
||||||
|
|
||||||
namespace Common::Compression {
|
|
||||||
|
|
||||||
[[nodiscard]] bool IsZBIC(std::span<const u8> src);
|
|
||||||
|
|
||||||
[[nodiscard]] int DecompressDataZBIC(std::span<u8> dst, std::span<const u8> src);
|
|
||||||
|
|
||||||
} // namespace Common::Compression
|
|
||||||
@@ -13,6 +13,7 @@
|
|||||||
#include <dynarmic/interface/A64/a64.h>
|
#include <dynarmic/interface/A64/a64.h>
|
||||||
#include <dynarmic/interface/code_page.h>
|
#include <dynarmic/interface/code_page.h>
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
|
#include "common/hash.h"
|
||||||
#include "core/arm/arm_interface.h"
|
#include "core/arm/arm_interface.h"
|
||||||
#include "core/arm/dynarmic/dynarmic_exclusive_monitor.h"
|
#include "core/arm/dynarmic/dynarmic_exclusive_monitor.h"
|
||||||
#include "dynarmic/interface/A64/config.h"
|
#include "dynarmic/interface/A64/config.h"
|
||||||
|
|||||||
@@ -168,7 +168,7 @@ void CpuManager::ShutdownThread(Kernel::KernelCore& kernel) {
|
|||||||
UNREACHABLE();
|
UNREACHABLE();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CpuManager::RunThread(std::stop_token stop_token, std::size_t core) {
|
void CpuManager::RunThread(std::stop_token token, std::size_t core) {
|
||||||
/// Initialization
|
/// Initialization
|
||||||
system.RegisterCoreThread(core);
|
system.RegisterCoreThread(core);
|
||||||
std::string name = is_multicore ? ("CPUCore_" + std::to_string(core)) : std::string{"CPUThread"};
|
std::string name = is_multicore ? ("CPUCore_" + std::to_string(core)) : std::string{"CPUThread"};
|
||||||
@@ -178,19 +178,26 @@ void CpuManager::RunThread(std::stop_token stop_token, std::size_t core) {
|
|||||||
auto& data = core_data[core];
|
auto& data = core_data[core];
|
||||||
data.host_context = Common::Fiber::ThreadToFiber();
|
data.host_context = Common::Fiber::ThreadToFiber();
|
||||||
|
|
||||||
|
// Cleanup
|
||||||
|
SCOPE_EXIT {
|
||||||
|
data.host_context->Exit();
|
||||||
|
};
|
||||||
|
|
||||||
// Running
|
// Running
|
||||||
gpu_barrier->arrive_and_wait();
|
if (!gpu_barrier->Sync(token)) {
|
||||||
if (!stop_token.stop_requested()) {
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!is_async_gpu && !is_multicore) {
|
if (!is_async_gpu && !is_multicore) {
|
||||||
system.GPU().ObtainContext();
|
system.GPU().ObtainContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto& kernel = system.Kernel();
|
auto& kernel = system.Kernel();
|
||||||
auto& scheduler = *kernel.CurrentScheduler();
|
auto& scheduler = *kernel.CurrentScheduler();
|
||||||
auto* thread = scheduler.GetSchedulerCurrentThread();
|
auto* thread = scheduler.GetSchedulerCurrentThread();
|
||||||
Kernel::SetCurrentThread(kernel, thread);
|
Kernel::SetCurrentThread(kernel, thread);
|
||||||
|
|
||||||
Common::Fiber::YieldTo(data.host_context, *thread->GetHostContext());
|
Common::Fiber::YieldTo(data.host_context, *thread->GetHostContext());
|
||||||
}
|
|
||||||
data.host_context->Exit();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Core
|
} // namespace Core
|
||||||
|
|||||||
@@ -8,7 +8,6 @@
|
|||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <barrier>
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
@@ -53,7 +52,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void OnGpuReady() {
|
void OnGpuReady() {
|
||||||
gpu_barrier->arrive_and_wait();
|
gpu_barrier->Sync();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Initialize();
|
void Initialize();
|
||||||
@@ -96,7 +95,7 @@ private:
|
|||||||
|
|
||||||
static constexpr std::size_t max_cycle_runs = 5;
|
static constexpr std::size_t max_cycle_runs = 5;
|
||||||
|
|
||||||
std::optional<std::barrier<>> gpu_barrier{};
|
std::optional<Common::Barrier> gpu_barrier{};
|
||||||
struct CoreData {
|
struct CoreData {
|
||||||
std::shared_ptr<Common::Fiber> host_context;
|
std::shared_ptr<Common::Fiber> host_context;
|
||||||
std::jthread host_thread;
|
std::jthread host_thread;
|
||||||
|
|||||||
@@ -14,7 +14,6 @@
|
|||||||
#include <tuple>
|
#include <tuple>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <boost/algorithm/string/case_conv.hpp>
|
|
||||||
#include <openssl/evp.h>
|
#include <openssl/evp.h>
|
||||||
|
|
||||||
#include "common/fs/file.h"
|
#include "common/fs/file.h"
|
||||||
@@ -623,7 +622,7 @@ void KeyManager::LoadFromFile(const std::filesystem::path& file_path, bool is_ti
|
|||||||
Key128 key = Common::HexStringToArray<16>(out[1]);
|
Key128 key = Common::HexStringToArray<16>(out[1]);
|
||||||
s128_keys[{S128KeyType::Titlekey, rights_id[1], rights_id[0]}] = key;
|
s128_keys[{S128KeyType::Titlekey, rights_id[1], rights_id[0]}] = key;
|
||||||
} else {
|
} else {
|
||||||
boost::algorithm::to_lower(out[0]);
|
out[0] = Common::ToLower(out[0]);
|
||||||
if (const auto iter128 = Find128ByName(out[0]); iter128 != s128_file_id.end()) {
|
if (const auto iter128 = Find128ByName(out[0]); iter128 != s128_file_id.end()) {
|
||||||
const auto& index = iter128->second;
|
const auto& index = iter128->second;
|
||||||
const Key128 key = Common::HexStringToArray<16>(out[1]);
|
const Key128 key = Common::HexStringToArray<16>(out[1]);
|
||||||
|
|||||||
@@ -6,7 +6,6 @@
|
|||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <boost/algorithm/string/case_conv.hpp>
|
|
||||||
#include "common/common_funcs.h"
|
#include "common/common_funcs.h"
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
#include "common/hex_util.h"
|
#include "common/hex_util.h"
|
||||||
@@ -42,13 +41,16 @@ static_assert(sizeof(Package2Header) == 0x200, "Package2Header has incorrect siz
|
|||||||
|
|
||||||
const u8 PartitionDataManager::MAX_KEYBLOB_SOURCE_HASH = 32;
|
const u8 PartitionDataManager::MAX_KEYBLOB_SOURCE_HASH = 32;
|
||||||
|
|
||||||
static FileSys::VirtualFile FindFileInDirWithNames(const FileSys::VirtualDir& dir, const std::string& name) {
|
static FileSys::VirtualFile FindFileInDirWithNames(const FileSys::VirtualDir& dir,
|
||||||
const auto upper = boost::algorithm::to_upper_copy(name);
|
const std::string& name) {
|
||||||
|
const auto upper = Common::ToUpper(name);
|
||||||
|
|
||||||
for (const auto& fname : {name, name + ".bin", upper, upper + ".BIN"}) {
|
for (const auto& fname : {name, name + ".bin", upper, upper + ".BIN"}) {
|
||||||
if (dir->GetFile(fname) != nullptr) {
|
if (dir->GetFile(fname) != nullptr) {
|
||||||
return dir->GetFile(fname);
|
return dir->GetFile(fname);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,6 @@
|
|||||||
#include <array>
|
#include <array>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <boost/algorithm/string/case_conv.hpp>
|
|
||||||
|
|
||||||
#include "common/assert.h"
|
#include "common/assert.h"
|
||||||
#include "common/hex_util.h"
|
#include "common/hex_util.h"
|
||||||
@@ -74,10 +73,12 @@ VirtualDir FindSubdirectoryCaseless(const VirtualDir dir, std::string_view name)
|
|||||||
#else
|
#else
|
||||||
const auto subdirs = dir->GetSubdirectories();
|
const auto subdirs = dir->GetSubdirectories();
|
||||||
for (const auto& subdir : subdirs) {
|
for (const auto& subdir : subdirs) {
|
||||||
if (name == boost::algorithm::to_lower_copy(subdir->GetName())) {
|
std::string dir_name = Common::ToLower(subdir->GetName());
|
||||||
|
if (dir_name == name) {
|
||||||
return subdir;
|
return subdir;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,6 @@
|
|||||||
#include <limits>
|
#include <limits>
|
||||||
#include <random>
|
#include <random>
|
||||||
#include <regex>
|
#include <regex>
|
||||||
#include <boost/algorithm/string/case_conv.hpp>
|
|
||||||
#include <openssl/evp.h>
|
#include <openssl/evp.h>
|
||||||
#include "common/assert.h"
|
#include "common/assert.h"
|
||||||
#include "common/fs/path_util.h"
|
#include "common/fs/path_util.h"
|
||||||
@@ -1415,10 +1414,11 @@ void ExternalContentProvider::ScanDirectory(const VirtualDir& dir) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto ext = boost::to_lower_copy(filename.substr(dot_pos + 1));
|
const auto extension = Common::ToLower(filename.substr(dot_pos + 1));
|
||||||
if (ext == "nsp") {
|
|
||||||
|
if (extension == "nsp") {
|
||||||
ProcessNSP(file);
|
ProcessNSP(file);
|
||||||
} else if (ext == "xci") {
|
} else if (extension == "xci") {
|
||||||
ProcessXCI(file);
|
ProcessXCI(file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,6 @@
|
|||||||
#include <regex>
|
#include <regex>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include <boost/algorithm/string/case_conv.hpp>
|
|
||||||
#include <openssl/err.h>
|
#include <openssl/err.h>
|
||||||
#include <openssl/evp.h>
|
#include <openssl/evp.h>
|
||||||
|
|
||||||
@@ -64,8 +63,8 @@ NAX::NAX(VirtualFile file_)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string two_dir = boost::algorithm::to_upper_copy(std::string{match[1]});
|
const std::string two_dir = Common::ToUpper(std::string{match[1]});
|
||||||
const std::string nca_id = boost::algorithm::to_lower_copy(std::string{match[2]});
|
const std::string nca_id = Common::ToLower(std::string{match[2]});
|
||||||
status = Parse(fmt::format("/registered/{}/{}.nca", two_dir, nca_id));
|
status = Parse(fmt::format("/registered/{}/{}.nca", two_dir, nca_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,3 @@
|
|||||||
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
|
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
|
|
||||||
// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
@@ -22,14 +19,8 @@ constexpr u32 NUM_CPU_CORES = 4; // Number of CPU Cores - sync wit
|
|||||||
|
|
||||||
// Virtual to Physical core map.
|
// Virtual to Physical core map.
|
||||||
constexpr std::array<s32, Common::BitSize<u64>()> VirtualToPhysicalCoreMap{
|
constexpr std::array<s32, Common::BitSize<u64>()> VirtualToPhysicalCoreMap{
|
||||||
0, 1, 2, 3, 0, 0, 0, 0,
|
0, 1, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
0, 0, 0, 0, 0, 0, 0, 0,
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3,
|
||||||
0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 3,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static constexpr inline size_t NumVirtualCores = Common::BitSize<u64>();
|
static constexpr inline size_t NumVirtualCores = Common::BitSize<u64>();
|
||||||
|
|||||||
@@ -10,7 +10,6 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <concepts>
|
#include <concepts>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <boost/algorithm/string/case_conv.hpp>
|
|
||||||
#include "common/concepts.h"
|
#include "common/concepts.h"
|
||||||
#include "common/fs/path_util.h"
|
#include "common/fs/path_util.h"
|
||||||
#include "common/logging.h"
|
#include "common/logging.h"
|
||||||
@@ -171,7 +170,8 @@ FileType GuessFromFilename(const std::string& name) {
|
|||||||
else if (name == "00")
|
else if (name == "00")
|
||||||
return FileType::NCA;
|
return FileType::NCA;
|
||||||
|
|
||||||
auto const extension = boost::algorithm::to_lower_copy(std::string(Common::FS::GetExtensionFromFilename(name)));
|
auto const extension =
|
||||||
|
Common::ToLower(std::string(Common::FS::GetExtensionFromFilename(name)));
|
||||||
if (extension == "nro")
|
if (extension == "nro")
|
||||||
return FileType::NRO;
|
return FileType::NRO;
|
||||||
else if (extension == "nso")
|
else if (extension == "nso")
|
||||||
|
|||||||
+3
-30
@@ -7,14 +7,12 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cinttypes>
|
#include <cinttypes>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <span>
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "common/common_funcs.h"
|
#include "common/common_funcs.h"
|
||||||
#include "common/hex_util.h"
|
#include "common/hex_util.h"
|
||||||
#include "common/logging.h"
|
#include "common/logging.h"
|
||||||
#include "common/lz4_compression.h"
|
#include "common/lz4_compression.h"
|
||||||
#include "common/zbic_compression.h"
|
|
||||||
#include "common/settings.h"
|
#include "common/settings.h"
|
||||||
#include "common/swap.h"
|
#include "common/swap.h"
|
||||||
#include "core/core.h"
|
#include "core/core.h"
|
||||||
@@ -106,36 +104,11 @@ std::optional<VAddr> AppLoader_NSO::LoadModule(Kernel::KProcess& process, Core::
|
|||||||
for (std::size_t i = 0; i < nso_header.segments.size(); ++i) {
|
for (std::size_t i = 0; i < nso_header.segments.size(); ++i) {
|
||||||
nso_file.Read(compressed_data.data(), nso_header.segments_compressed_size[i], nso_header.segments[i].offset);
|
nso_file.Read(compressed_data.data(), nso_header.segments_compressed_size[i], nso_header.segments[i].offset);
|
||||||
if (nso_header.IsSegmentCompressed(i)) {
|
if (nso_header.IsSegmentCompressed(i)) {
|
||||||
if (nso_header.IsZBICCompressed()) {
|
int r = Common::Compression::DecompressDataLZ4(decompressed_size.data(), nso_header.segments[i].size, compressed_data.data(), nso_header.segments_compressed_size[i]);
|
||||||
// ZBIC compression
|
|
||||||
const int r = Common::Compression::DecompressDataZBIC(
|
|
||||||
std::span<u8>{decompressed_size}.first(nso_header.segments[i].size),
|
|
||||||
std::span<const u8>{compressed_data}.first(nso_header.segments_compressed_size[i])
|
|
||||||
);
|
|
||||||
ASSERT(r > 0);
|
|
||||||
} else {
|
|
||||||
// LZ4 compression
|
|
||||||
int r = Common::Compression::DecompressDataLZ4(
|
|
||||||
decompressed_size.data(),
|
|
||||||
nso_header.segments[i].size,
|
|
||||||
compressed_data.data(),
|
|
||||||
nso_header.segments_compressed_size[i]
|
|
||||||
);
|
|
||||||
ASSERT(r == int(nso_header.segments[i].size));
|
ASSERT(r == int(nso_header.segments[i].size));
|
||||||
}
|
std::memcpy(codeset.memory.data() + module_start + nso_header.segments[i].location, decompressed_size.data(), nso_header.segments[i].size);
|
||||||
|
|
||||||
std::memcpy(
|
|
||||||
codeset.memory.data() + module_start + nso_header.segments[i].location,
|
|
||||||
decompressed_size.data(),
|
|
||||||
nso_header.segments[i].size
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
// Not compressed
|
std::memcpy(codeset.memory.data() + module_start + nso_header.segments[i].location, compressed_data.data(), nso_header.segments[i].size);
|
||||||
std::memcpy(
|
|
||||||
codeset.memory.data() + module_start + nso_header.segments[i].location,
|
|
||||||
compressed_data.data(),
|
|
||||||
nso_header.segments[i].size
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
codeset.segments[i].addr = module_start + nso_header.segments[i].location;
|
codeset.segments[i].addr = module_start + nso_header.segments[i].location;
|
||||||
codeset.segments[i].offset = module_start + nso_header.segments[i].location;
|
codeset.segments[i].offset = module_start + nso_header.segments[i].location;
|
||||||
|
|||||||
@@ -1,6 +1,3 @@
|
|||||||
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
|
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
|
|
||||||
// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
@@ -61,9 +58,6 @@ struct NSOHeader {
|
|||||||
std::array<SHA256Hash, 3> segment_hashes;
|
std::array<SHA256Hash, 3> segment_hashes;
|
||||||
|
|
||||||
bool IsSegmentCompressed(size_t segment_num) const;
|
bool IsSegmentCompressed(size_t segment_num) const;
|
||||||
bool IsZBICCompressed() const {
|
|
||||||
return ((flags >> 7) & 1) != 0;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
static_assert(sizeof(NSOHeader) == 0x100, "NSOHeader has incorrect size.");
|
static_assert(sizeof(NSOHeader) == 0x100, "NSOHeader has incorrect size.");
|
||||||
static_assert(std::is_trivially_copyable_v<NSOHeader>, "NSOHeader must be trivially copyable.");
|
static_assert(std::is_trivially_copyable_v<NSOHeader>, "NSOHeader must be trivially copyable.");
|
||||||
|
|||||||
@@ -14,7 +14,6 @@
|
|||||||
#include <regex>
|
#include <regex>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <boost/algorithm/string/trim.hpp>
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
// windows.h needs to be included before shellapi.h
|
// windows.h needs to be included before shellapi.h
|
||||||
@@ -133,7 +132,7 @@ static Network::Room::BanList LoadBanList(const std::string& path) {
|
|||||||
std::string line;
|
std::string line;
|
||||||
std::getline(file, line);
|
std::getline(file, line);
|
||||||
line.erase(std::remove(line.begin(), line.end(), '\0'), line.end());
|
line.erase(std::remove(line.begin(), line.end(), '\0'), line.end());
|
||||||
boost::trim(line);
|
line = Common::StripSpaces(line);
|
||||||
if (line.empty()) {
|
if (line.empty()) {
|
||||||
// An empty line marks start of the IP ban list
|
// An empty line marks start of the IP ban list
|
||||||
ban_list_type = true;
|
ban_list_type = true;
|
||||||
|
|||||||
@@ -761,6 +761,9 @@ void EmulatedController::StartMotionCalibration() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void EmulatedController::SetButton(const Common::Input::CallbackStatus& callback, std::size_t index, Common::UUID uuid) {
|
void EmulatedController::SetButton(const Common::Input::CallbackStatus& callback, std::size_t index, Common::UUID uuid) {
|
||||||
|
const auto player_index = Service::HID::NpadIdTypeToIndex(npad_id_type);
|
||||||
|
const auto& player = Settings::values.players.GetValue()[player_index];
|
||||||
|
|
||||||
if (index >= controller.button_values.size()) {
|
if (index >= controller.button_values.size()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -913,10 +916,21 @@ void EmulatedController::SetButton(const Common::Input::CallbackStatus& callback
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto player_index = Service::HID::NpadIdTypeToIndex(npad_id_type);
|
if (!is_connected) {
|
||||||
const auto& player = Settings::values.players.GetValue()[player_index];
|
if (npad_type == NpadStyleIndex::Handheld) {
|
||||||
if (player.connected) {
|
if (npad_id_type == NpadIdType::Handheld) {
|
||||||
Connect();
|
Connect();
|
||||||
|
controller_connected[player_index] = true;
|
||||||
|
}
|
||||||
|
} else if (npad_type != NpadStyleIndex::Handheld) {
|
||||||
|
if (npad_id_type == NpadIdType::Player1) {
|
||||||
|
Connect();
|
||||||
|
controller_connected[player_index] = true;
|
||||||
|
} else if (player.connected && !controller_connected[player_index]) {
|
||||||
|
Connect();
|
||||||
|
controller_connected[player_index] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TriggerOnChange(ControllerTriggerType::Button, true);
|
TriggerOnChange(ControllerTriggerType::Button, true);
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
#include "common/settings.h"
|
#include "common/settings.h"
|
||||||
#include "common/vector_math.h"
|
#include "common/vector_math.h"
|
||||||
#include "hid_core/frontend/motion_input.h"
|
#include "hid_core/frontend/motion_input.h"
|
||||||
|
#include "hid_core/hid_core.h"
|
||||||
#include "hid_core/hid_types.h"
|
#include "hid_core/hid_types.h"
|
||||||
#include "hid_core/irsensor/irs_types.h"
|
#include "hid_core/irsensor/irs_types.h"
|
||||||
|
|
||||||
@@ -584,6 +585,7 @@ private:
|
|||||||
std::array<VibrationValue, 2> last_vibration_value{DEFAULT_VIBRATION_VALUE,
|
std::array<VibrationValue, 2> last_vibration_value{DEFAULT_VIBRATION_VALUE,
|
||||||
DEFAULT_VIBRATION_VALUE};
|
DEFAULT_VIBRATION_VALUE};
|
||||||
std::array<std::chrono::steady_clock::time_point, 2> last_vibration_timepoint{};
|
std::array<std::chrono::steady_clock::time_point, 2> last_vibration_timepoint{};
|
||||||
|
std::array<bool, HIDCore::available_controllers> controller_connected{};
|
||||||
|
|
||||||
// Atomically synched values
|
// Atomically synched values
|
||||||
std::atomic<HID::NpadStyleIndex> npad_type{HID::NpadStyleIndex::None};
|
std::atomic<HID::NpadStyleIndex> npad_type{HID::NpadStyleIndex::None};
|
||||||
|
|||||||
@@ -226,7 +226,9 @@ std::unique_ptr<TranslationMap> InitializeTranslations(QObject* parent) {
|
|||||||
INSERT(Settings, dma_accuracy, tr("DMA Accuracy:"),
|
INSERT(Settings, dma_accuracy, tr("DMA Accuracy:"),
|
||||||
tr("Controls the DMA read mode.\nUnsafe is faster, while Safe is more stable and can fix issues in some games.\nDefault follows the GPU Accuracy setting."));
|
tr("Controls the DMA read mode.\nUnsafe is faster, while Safe is more stable and can fix issues in some games.\nDefault follows the GPU Accuracy setting."));
|
||||||
INSERT(Settings, gpu_fence_behavior, tr("GPU Fence Behavior:"),
|
INSERT(Settings, gpu_fence_behavior, tr("GPU Fence Behavior:"),
|
||||||
tr("Controls the GPU fence synchronization behavior.\nImmediate is the fastest option, but can introduce some issues.\nBalanced offers better compatibility and may fix issues in some games.\nAccurate further improves compatibility at the cost of some performance.\nDefault follows the GPU Mode setting."));
|
tr("Controls the GPU fence synchronization behavior.\nImmediate is the fastest option, but can introduce some issues.\nBalanced offers better compatibility and may fix issues in some games.\nAccurate further improves compatibility at the cost of some performance.\nStrict is the slowest option, but can fix issues that require stricter synchronization.\nDefault follows the GPU Accuracy setting."));
|
||||||
|
INSERT(Settings, enable_gpu_buffer_readback, tr("Enable GPU buffer readback"),
|
||||||
|
tr("Preserves GPU-modified data by reading it back before uploading.\nSome games require this to render certain effects properly."));
|
||||||
INSERT(Settings, use_asynchronous_shaders, tr("Enable asynchronous shader compilation"),
|
INSERT(Settings, use_asynchronous_shaders, tr("Enable asynchronous shader compilation"),
|
||||||
tr("May reduce shader stutter."));
|
tr("May reduce shader stutter."));
|
||||||
INSERT(Settings, gpu_clock, tr("GPU Clocks"),
|
INSERT(Settings, gpu_clock, tr("GPU Clocks"),
|
||||||
@@ -440,6 +442,7 @@ std::unique_ptr<ComboboxTranslationMap> ComboboxEnumeration(QObject* parent) {
|
|||||||
PAIR(GpuFenceBehavior, Immediate, tr("Immediate")),
|
PAIR(GpuFenceBehavior, Immediate, tr("Immediate")),
|
||||||
PAIR(GpuFenceBehavior, Balanced, tr("Balanced")),
|
PAIR(GpuFenceBehavior, Balanced, tr("Balanced")),
|
||||||
PAIR(GpuFenceBehavior, Accurate, tr("Accurate")),
|
PAIR(GpuFenceBehavior, Accurate, tr("Accurate")),
|
||||||
|
PAIR(GpuFenceBehavior, Strict, tr("Strict")),
|
||||||
}});
|
}});
|
||||||
translations->insert(
|
translations->insert(
|
||||||
{Settings::EnumMetadata<Settings::CpuAccuracy>::Index(),
|
{Settings::EnumMetadata<Settings::CpuAccuracy>::Index(),
|
||||||
|
|||||||
@@ -8,7 +8,6 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include <QEventLoop>
|
#include <QEventLoop>
|
||||||
#include <boost/algorithm/string/case_conv.hpp>
|
|
||||||
#include <boost/algorithm/string/replace.hpp>
|
#include <boost/algorithm/string/replace.hpp>
|
||||||
#include "common/httplib.h"
|
#include "common/httplib.h"
|
||||||
|
|
||||||
@@ -46,7 +45,7 @@ void DiscordImpl::Pause() {
|
|||||||
|
|
||||||
std::string DiscordImpl::GetGameString(const std::string& title) {
|
std::string DiscordImpl::GetGameString(const std::string& title) {
|
||||||
// Convert to lowercase
|
// Convert to lowercase
|
||||||
std::string icon_name = boost::algorithm::to_lower_copy(title);
|
std::string icon_name = Common::ToLower(title);
|
||||||
|
|
||||||
// Replace spaces with dashes
|
// Replace spaces with dashes
|
||||||
std::replace(icon_name.begin(), icon_name.end(), ' ', '-');
|
std::replace(icon_name.begin(), icon_name.end(), ' ', '-');
|
||||||
|
|||||||
@@ -249,10 +249,6 @@ bool BufferCache<P>::DMACopy(GPUVAddr src_address, GPUVAddr dest_address, u64 am
|
|||||||
runtime.CopyBuffer(dest_buffer, src_buffer, copies, true);
|
runtime.CopyBuffer(dest_buffer, src_buffer, copies, true);
|
||||||
if (has_new_downloads) {
|
if (has_new_downloads) {
|
||||||
memory_tracker.MarkRegionAsGpuModified(*cpu_dest_address, amount);
|
memory_tracker.MarkRegionAsGpuModified(*cpu_dest_address, amount);
|
||||||
const bool should_sync = Settings::IsGPUFenceBehaviorBalanced() || Settings::IsGPUFenceBehaviorAccurate();
|
|
||||||
if (should_sync) {
|
|
||||||
runtime.Finish();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Tegra::Memory::DeviceGuestMemoryScoped<u8, Tegra::Memory::GuestMemoryFlags::UnsafeReadWrite>
|
Tegra::Memory::DeviceGuestMemoryScoped<u8, Tegra::Memory::GuestMemoryFlags::UnsafeReadWrite>
|
||||||
@@ -1234,7 +1230,7 @@ void BufferCache<P>::BindHostComputeStorageBuffers() {
|
|||||||
buffer.MarkUsage(offset, size);
|
buffer.MarkUsage(offset, size);
|
||||||
|
|
||||||
if (is_written) {
|
if (is_written) {
|
||||||
MarkWrittenBuffer(binding.buffer_id, binding.device_addr, size, true);
|
MarkWrittenBuffer(binding.buffer_id, binding.device_addr, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
if constexpr (NEEDS_BIND_STORAGE_INDEX) {
|
if constexpr (NEEDS_BIND_STORAGE_INDEX) {
|
||||||
@@ -1520,13 +1516,11 @@ void BufferCache<P>::UpdateComputeTextureBuffers() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <class P>
|
template <class P>
|
||||||
void BufferCache<P>::MarkWrittenBuffer(BufferId buffer_id, DAddr device_addr, u32 size, bool needs_sync) {
|
void BufferCache<P>::MarkWrittenBuffer(BufferId buffer_id, DAddr device_addr, u32 size) {
|
||||||
if constexpr (!IS_OPENGL) {
|
if constexpr (!IS_OPENGL) {
|
||||||
if (needs_sync) {
|
|
||||||
Buffer& buffer = slot_buffers[buffer_id];
|
Buffer& buffer = slot_buffers[buffer_id];
|
||||||
buffer.setWriteTick(runtime.CurrentTick());
|
buffer.setWriteTick(runtime.CurrentTick());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
memory_tracker.MarkRegionAsGpuModified(device_addr, size);
|
memory_tracker.MarkRegionAsGpuModified(device_addr, size);
|
||||||
gpu_modified_ranges.Add(device_addr, size);
|
gpu_modified_ranges.Add(device_addr, size);
|
||||||
uncommitted_gpu_modified_ranges.Add(device_addr, size);
|
uncommitted_gpu_modified_ranges.Add(device_addr, size);
|
||||||
@@ -1541,11 +1535,8 @@ BufferId BufferCache<P>::FindBuffer(DAddr device_addr, u32 size, bool sparse_com
|
|||||||
const BufferId buffer_id = page_table[page];
|
const BufferId buffer_id = page_table[page];
|
||||||
if (buffer_id) {
|
if (buffer_id) {
|
||||||
Buffer& buffer = slot_buffers[buffer_id];
|
Buffer& buffer = slot_buffers[buffer_id];
|
||||||
|
WaitForGpuFenceIfNeeded(buffer);
|
||||||
if (buffer.IsInBounds(device_addr, size)) {
|
if (buffer.IsInBounds(device_addr, size)) {
|
||||||
const bool should_sync = Settings::IsGPUFenceBehaviorAccurate();
|
|
||||||
if (should_sync) {
|
|
||||||
SynchronizeBufferWrites(buffer);
|
|
||||||
}
|
|
||||||
bool usable = true;
|
bool usable = true;
|
||||||
if constexpr (requires { buffer.IsSparseCompatible(); }) {
|
if constexpr (requires { buffer.IsSparseCompatible(); }) {
|
||||||
if (sparse_compatible && !buffer.IsSparseCompatible()) {
|
if (sparse_compatible && !buffer.IsSparseCompatible()) {
|
||||||
@@ -1561,13 +1552,19 @@ BufferId BufferCache<P>::FindBuffer(DAddr device_addr, u32 size, bool sparse_com
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <class P>
|
template <class P>
|
||||||
void BufferCache<P>::SynchronizeBufferWrites(Buffer& buffer) {
|
void BufferCache<P>::WaitForGpuFenceIfNeeded(Buffer& buffer) {
|
||||||
if constexpr (!IS_OPENGL) {
|
if constexpr (!IS_OPENGL) {
|
||||||
|
const bool gpu_fence_accurate = Settings::IsGPUFenceBehaviorAccurate();
|
||||||
|
const bool gpu_fence_strict = Settings::IsGPUFenceBehaviorStrict();
|
||||||
|
if (gpu_fence_accurate || gpu_fence_strict) {
|
||||||
|
const u64 gpu_tick_delay = gpu_fence_strict ? 0 : 3;
|
||||||
const u64 buffer_tick = buffer.getWriteTick();
|
const u64 buffer_tick = buffer.getWriteTick();
|
||||||
if (!runtime.IsFree(buffer_tick)) {
|
const u64 gpu_tick = runtime.KnownGpuTick();
|
||||||
|
if (buffer_tick > gpu_tick + gpu_tick_delay) {
|
||||||
runtime.Wait(buffer_tick);
|
runtime.Wait(buffer_tick);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class P>
|
template <class P>
|
||||||
@@ -1798,6 +1795,9 @@ void BufferCache<P>::ImmediateUploadMemory([[maybe_unused]] Buffer& buffer,
|
|||||||
if (immediate_buffer.empty()) {
|
if (immediate_buffer.empty()) {
|
||||||
immediate_buffer = ImmediateBuffer(largest_copy);
|
immediate_buffer = ImmediateBuffer(largest_copy);
|
||||||
}
|
}
|
||||||
|
if (Settings::values.enable_gpu_buffer_readback.GetValue()) {
|
||||||
|
DownloadBufferMemory(buffer, device_addr, copy.size);
|
||||||
|
}
|
||||||
device_memory.ReadBlockUnsafe(device_addr, immediate_buffer.data(), copy.size);
|
device_memory.ReadBlockUnsafe(device_addr, immediate_buffer.data(), copy.size);
|
||||||
upload_span = immediate_buffer.subspan(0, copy.size);
|
upload_span = immediate_buffer.subspan(0, copy.size);
|
||||||
}
|
}
|
||||||
@@ -1816,6 +1816,9 @@ void BufferCache<P>::MappedUploadMemory([[maybe_unused]] Buffer& buffer,
|
|||||||
for (BufferCopy& copy : copies) {
|
for (BufferCopy& copy : copies) {
|
||||||
u8* const src_pointer = staging_pointer.data() + copy.src_offset;
|
u8* const src_pointer = staging_pointer.data() + copy.src_offset;
|
||||||
const DAddr device_addr = buffer.CpuAddr() + copy.dst_offset;
|
const DAddr device_addr = buffer.CpuAddr() + copy.dst_offset;
|
||||||
|
if (Settings::values.enable_gpu_buffer_readback.GetValue()) {
|
||||||
|
DownloadBufferMemory(buffer, device_addr, copy.size);
|
||||||
|
}
|
||||||
device_memory.ReadBlockUnsafe(device_addr, src_pointer, copy.size);
|
device_memory.ReadBlockUnsafe(device_addr, src_pointer, copy.size);
|
||||||
// Apply the staging offset
|
// Apply the staging offset
|
||||||
copy.src_offset += upload_staging.offset;
|
copy.src_offset += upload_staging.offset;
|
||||||
|
|||||||
@@ -430,11 +430,11 @@ private:
|
|||||||
|
|
||||||
void UpdateComputeTextureBuffers();
|
void UpdateComputeTextureBuffers();
|
||||||
|
|
||||||
void MarkWrittenBuffer(BufferId buffer_id, DAddr device_addr, u32 size, bool needs_sync = false);
|
void MarkWrittenBuffer(BufferId buffer_id, DAddr device_addr, u32 size);
|
||||||
|
|
||||||
[[nodiscard]] BufferId FindBuffer(DAddr device_addr, u32 size, bool sparse_compatible);
|
[[nodiscard]] BufferId FindBuffer(DAddr device_addr, u32 size, bool sparse_compatible);
|
||||||
|
|
||||||
void SynchronizeBufferWrites(Buffer& buffer);
|
void WaitForGpuFenceIfNeeded(Buffer& buffer);
|
||||||
|
|
||||||
[[nodiscard]] OverlapResult ResolveOverlaps(DAddr device_addr, u32 wanted_size);
|
[[nodiscard]] OverlapResult ResolveOverlaps(DAddr device_addr, u32 wanted_size);
|
||||||
|
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SignalFence(std::function<void()>&& func) {
|
void SignalFence(std::function<void()>&& func) {
|
||||||
const bool delay_fence = Settings::IsGPUFenceBehaviorDefault() ? Settings::IsGPULevelHigh() : Settings::IsGPUFenceBehaviorBalanced() || Settings::IsGPUFenceBehaviorAccurate();
|
const bool delay_fence = Settings::IsGPUFenceBehaviorDefault() ? Settings::IsGPULevelHigh() : Settings::IsGPUFenceBehaviorBalanced() || Settings::IsGPUFenceBehaviorAccurate() || Settings::IsGPUFenceBehaviorStrict();
|
||||||
const bool should_flush = ShouldFlush();
|
const bool should_flush = ShouldFlush();
|
||||||
if constexpr (!can_async_check) {
|
if constexpr (!can_async_check) {
|
||||||
TryReleasePendingFences<false>();
|
TryReleasePendingFences<false>();
|
||||||
|
|||||||
@@ -260,7 +260,7 @@ void QueryCacheBase<Traits>::CounterReport(GPUVAddr addr, QueryType counter_type
|
|||||||
};
|
};
|
||||||
u8* pointer = impl->device_memory.template GetPointer<u8>(cpu_addr);
|
u8* pointer = impl->device_memory.template GetPointer<u8>(cpu_addr);
|
||||||
u8* pointer_timestamp = impl->device_memory.template GetPointer<u8>(cpu_addr + 8);
|
u8* pointer_timestamp = impl->device_memory.template GetPointer<u8>(cpu_addr + 8);
|
||||||
bool is_synced = (Settings::IsGPUFenceBehaviorDefault() ? !Settings::IsGPULevelHigh() : !Settings::IsGPUFenceBehaviorBalanced() && !Settings::IsGPUFenceBehaviorAccurate()) && is_fence;
|
bool is_synced = (Settings::IsGPUFenceBehaviorDefault() ? !Settings::IsGPULevelHigh() : !Settings::IsGPUFenceBehaviorBalanced() && !Settings::IsGPUFenceBehaviorAccurate() && !Settings::IsGPUFenceBehaviorStrict()) && is_fence;
|
||||||
std::function<void()> operation([this, is_synced, streamer, query_base = query, query_location,
|
std::function<void()> operation([this, is_synced, streamer, query_base = query, query_location,
|
||||||
pointer, pointer_timestamp] {
|
pointer, pointer_timestamp] {
|
||||||
if (True(query_base->flags & QueryFlagBits::IsInvalidated)) {
|
if (True(query_base->flags & QueryFlagBits::IsInvalidated)) {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
|
||||||
@@ -55,7 +55,7 @@ size_t StagingBuffers::RequestBuffer(size_t requested_size) {
|
|||||||
}
|
}
|
||||||
StagingBufferAlloc alloc;
|
StagingBufferAlloc alloc;
|
||||||
alloc.buffer.Create();
|
alloc.buffer.Create();
|
||||||
const auto next_pow2_size = std::bit_ceil(requested_size);
|
const auto next_pow2_size = Common::NextPow2(requested_size);
|
||||||
glNamedBufferStorage(alloc.buffer.handle, next_pow2_size, nullptr,
|
glNamedBufferStorage(alloc.buffer.handle, next_pow2_size, nullptr,
|
||||||
storage_flags | GL_MAP_PERSISTENT_BIT);
|
storage_flags | GL_MAP_PERSISTENT_BIT);
|
||||||
alloc.map = static_cast<u8*>(glMapNamedBufferRange(alloc.buffer.handle, 0, next_pow2_size,
|
alloc.map = static_cast<u8*>(glMapNamedBufferRange(alloc.buffer.handle, 0, next_pow2_size,
|
||||||
|
|||||||
@@ -1404,7 +1404,7 @@ void FormatConversionPass::ConvertImage(Image& dst_image, Image& src_image,
|
|||||||
const u32 copy_size = region.width * region.height * region.depth * img_bpp;
|
const u32 copy_size = region.width * region.height * region.depth * img_bpp;
|
||||||
if (pbo_size < copy_size) {
|
if (pbo_size < copy_size) {
|
||||||
intermediate_pbo.Create();
|
intermediate_pbo.Create();
|
||||||
pbo_size = std::bit_ceil(copy_size);
|
pbo_size = Common::NextPow2(copy_size);
|
||||||
glNamedBufferData(intermediate_pbo.handle, pbo_size, nullptr, GL_STREAM_COPY);
|
glNamedBufferData(intermediate_pbo.handle, pbo_size, nullptr, GL_STREAM_COPY);
|
||||||
}
|
}
|
||||||
// Copy from source to PBO
|
// Copy from source to PBO
|
||||||
|
|||||||
@@ -200,7 +200,7 @@ public:
|
|||||||
if (host_visible) {
|
if (host_visible) {
|
||||||
return StagingBufferRef{};
|
return StagingBufferRef{};
|
||||||
}
|
}
|
||||||
return staging_pool.Request(size_bytes, MemoryUsage::Upload);
|
return staging_pool.Request(device, size_bytes, MemoryUsage::Upload);
|
||||||
}();
|
}();
|
||||||
|
|
||||||
u8* staging_data = host_visible ? buffer.Mapped().data() : staging.mapped_span.data();
|
u8* staging_data = host_visible ? buffer.Mapped().data() : staging.mapped_span.data();
|
||||||
@@ -375,11 +375,11 @@ BufferCacheRuntime::BufferCacheRuntime(const Device& device_, MemoryAllocator& m
|
|||||||
}
|
}
|
||||||
|
|
||||||
StagingBufferRef BufferCacheRuntime::UploadStagingBuffer(size_t size) {
|
StagingBufferRef BufferCacheRuntime::UploadStagingBuffer(size_t size) {
|
||||||
return staging_pool.Request(size, MemoryUsage::Upload);
|
return staging_pool.Request(device, size, MemoryUsage::Upload);
|
||||||
}
|
}
|
||||||
|
|
||||||
StagingBufferRef BufferCacheRuntime::DownloadStagingBuffer(size_t size, bool deferred) {
|
StagingBufferRef BufferCacheRuntime::DownloadStagingBuffer(size_t size, bool deferred) {
|
||||||
return staging_pool.Request(size, MemoryUsage::Download, deferred);
|
return staging_pool.Request(device, size, MemoryUsage::Download, deferred);
|
||||||
}
|
}
|
||||||
|
|
||||||
VkFormat BufferCacheRuntime::TexelBufferFormat(VideoCore::Surface::PixelFormat format) const {
|
VkFormat BufferCacheRuntime::TexelBufferFormat(VideoCore::Surface::PixelFormat format) const {
|
||||||
@@ -419,15 +419,15 @@ void BufferCacheRuntime::TickFrame(Common::SlotVector<Buffer>& slot_buffers) noe
|
|||||||
}
|
}
|
||||||
|
|
||||||
u64 BufferCacheRuntime::CurrentTick() {
|
u64 BufferCacheRuntime::CurrentTick() {
|
||||||
return scheduler.CurrentTick();
|
return scheduler.GetMasterSemaphore().CurrentTick();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BufferCacheRuntime::IsFree(u64 tick) {
|
u64 BufferCacheRuntime::KnownGpuTick() {
|
||||||
return scheduler.IsFree(tick);
|
return scheduler.GetMasterSemaphore().KnownGpuTick();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BufferCacheRuntime::Wait(u64 tick) {
|
void BufferCacheRuntime::Wait(u64 buffer_tick) {
|
||||||
scheduler.Wait(tick);
|
scheduler.Wait(buffer_tick);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BufferCacheRuntime::Finish() {
|
void BufferCacheRuntime::Finish() {
|
||||||
|
|||||||
@@ -112,9 +112,9 @@ public:
|
|||||||
|
|
||||||
u64 CurrentTick();
|
u64 CurrentTick();
|
||||||
|
|
||||||
bool IsFree(u64 tick);
|
u64 KnownGpuTick();
|
||||||
|
|
||||||
void Wait(u64 tick);
|
void Wait(u64 buffer_tick);
|
||||||
|
|
||||||
void Finish();
|
void Finish();
|
||||||
|
|
||||||
@@ -162,7 +162,7 @@ public:
|
|||||||
std::span<u8> BindMappedUniformBuffer([[maybe_unused]] size_t stage,
|
std::span<u8> BindMappedUniformBuffer([[maybe_unused]] size_t stage,
|
||||||
[[maybe_unused]] u32 binding_index,
|
[[maybe_unused]] u32 binding_index,
|
||||||
u32 size) {
|
u32 size) {
|
||||||
const StagingBufferRef ref = staging_pool.Request(size, MemoryUsage::Upload);
|
const StagingBufferRef ref = staging_pool.Request(device, size, MemoryUsage::Upload);
|
||||||
guest_descriptor_queue.AddBuffer(ref.buffer, ref.device_address,
|
guest_descriptor_queue.AddBuffer(ref.buffer, ref.device_address,
|
||||||
static_cast<u32>(ref.offset), size);
|
static_cast<u32>(ref.offset), size);
|
||||||
return ref.mapped_span;
|
return ref.mapped_span;
|
||||||
|
|||||||
@@ -287,7 +287,7 @@ Uint8Pass::~Uint8Pass() = default;
|
|||||||
std::pair<VkBuffer, VkDeviceSize> Uint8Pass::Assemble(u32 num_vertices, VkBuffer src_buffer,
|
std::pair<VkBuffer, VkDeviceSize> Uint8Pass::Assemble(u32 num_vertices, VkBuffer src_buffer,
|
||||||
u32 src_offset) {
|
u32 src_offset) {
|
||||||
const u32 staging_size = static_cast<u32>(num_vertices * sizeof(u16));
|
const u32 staging_size = static_cast<u32>(num_vertices * sizeof(u16));
|
||||||
const auto staging = staging_buffer_pool.Request(staging_size, MemoryUsage::DeviceLocal);
|
const auto staging = staging_buffer_pool.Request(device, staging_size, MemoryUsage::DeviceLocal);
|
||||||
|
|
||||||
compute_pass_descriptor_queue.Acquire(scheduler, 2);
|
compute_pass_descriptor_queue.Acquire(scheduler, 2);
|
||||||
compute_pass_descriptor_queue.AddBuffer(src_buffer, src_offset, num_vertices);
|
compute_pass_descriptor_queue.AddBuffer(src_buffer, src_offset, num_vertices);
|
||||||
@@ -345,7 +345,7 @@ std::pair<VkBuffer, VkDeviceSize> QuadIndexedPass::Assemble(
|
|||||||
const u32 num_tri_vertices = (is_strip ? (num_vertices - 2) / 2 : num_vertices / 4) * 6;
|
const u32 num_tri_vertices = (is_strip ? (num_vertices - 2) / 2 : num_vertices / 4) * 6;
|
||||||
|
|
||||||
const std::size_t staging_size = num_tri_vertices * sizeof(u32);
|
const std::size_t staging_size = num_tri_vertices * sizeof(u32);
|
||||||
const auto staging = staging_buffer_pool.Request(staging_size, MemoryUsage::DeviceLocal);
|
const auto staging = staging_buffer_pool.Request(device, staging_size, MemoryUsage::DeviceLocal);
|
||||||
|
|
||||||
compute_pass_descriptor_queue.Acquire(scheduler, 2);
|
compute_pass_descriptor_queue.Acquire(scheduler, 2);
|
||||||
compute_pass_descriptor_queue.AddBuffer(src_buffer, src_offset, input_size);
|
compute_pass_descriptor_queue.AddBuffer(src_buffer, src_offset, input_size);
|
||||||
|
|||||||
@@ -852,7 +852,7 @@ public:
|
|||||||
|
|
||||||
void PushUnsyncedQueries() override {
|
void PushUnsyncedQueries() override {
|
||||||
CloseCounter();
|
CloseCounter();
|
||||||
auto staging_ref = staging_pool.Request(
|
auto staging_ref = staging_pool.Request(device,
|
||||||
pending_flush_queries.size() * TFBQueryBank::QUERY_SIZE, MemoryUsage::Download, true);
|
pending_flush_queries.size() * TFBQueryBank::QUERY_SIZE, MemoryUsage::Download, true);
|
||||||
size_t offset_base = staging_ref.offset;
|
size_t offset_base = staging_ref.offset;
|
||||||
for (auto q : pending_flush_queries) {
|
for (auto q : pending_flush_queries) {
|
||||||
@@ -1657,7 +1657,7 @@ void QueryCacheRuntime::SyncValues(std::span<SyncValuesType> values, VkBuffer ba
|
|||||||
impl->copies_setup.clear();
|
impl->copies_setup.clear();
|
||||||
impl->copies_setup.resize(impl->little_cache.size());
|
impl->copies_setup.resize(impl->little_cache.size());
|
||||||
if constexpr (SyncValuesType::GeneratesBaseBuffer) {
|
if constexpr (SyncValuesType::GeneratesBaseBuffer) {
|
||||||
ref = impl->staging_pool.Request(total_size, MemoryUsage::Upload);
|
ref = impl->staging_pool.Request(impl->device, total_size, MemoryUsage::Upload);
|
||||||
size_t current_offset = ref.offset;
|
size_t current_offset = ref.offset;
|
||||||
size_t accumulated_size = 0;
|
size_t accumulated_size = 0;
|
||||||
for (size_t i = 0; i < values.size(); i++) {
|
for (size_t i = 0; i < values.size(); i++) {
|
||||||
|
|||||||
@@ -28,55 +28,42 @@ using namespace Common::Literals;
|
|||||||
// Maximum potential alignment of a Vulkan buffer
|
// Maximum potential alignment of a Vulkan buffer
|
||||||
constexpr VkDeviceSize MAX_ALIGNMENT = 256;
|
constexpr VkDeviceSize MAX_ALIGNMENT = 256;
|
||||||
|
|
||||||
// Stream buffer size in bytes
|
size_t GetStreamBufferSize(const Device& device, size_t max_stream_buffer_size, size_t max_alignment) {
|
||||||
// *NIX drivers are more sensitive to increased buffers for streaming.
|
|
||||||
// Windows ones however, can intake bigger buffers and generally do not OOM.
|
|
||||||
// - GTX 960 on Windows will not OOM with 256mib
|
|
||||||
// - GT 1030 on ^NIX will OOM with 256mib
|
|
||||||
#if defined(__FreeBSD__)
|
|
||||||
constexpr VkDeviceSize MAX_STREAM_BUFFER_SIZE = 128_MiB;
|
|
||||||
#else
|
|
||||||
constexpr VkDeviceSize MAX_STREAM_BUFFER_SIZE = 256_MiB;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
size_t GetStreamBufferSize(const Device& device) {
|
|
||||||
if (!device.HasDebuggingToolAttached()) {
|
if (!device.HasDebuggingToolAttached()) {
|
||||||
return MAX_STREAM_BUFFER_SIZE;
|
return max_stream_buffer_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
VkDeviceSize size{0};
|
VkDeviceSize size{0};
|
||||||
bool has_device_local_host_visible_heap{};
|
bool has_device_local_host_visible_heap{};
|
||||||
ForEachDeviceLocalHostVisibleHeap(device, [&size, &has_device_local_host_visible_heap](
|
ForEachDeviceLocalHostVisibleHeap(device, [&size, &has_device_local_host_visible_heap](size_t index, VkMemoryHeap& heap) {
|
||||||
size_t index, VkMemoryHeap& heap) {
|
|
||||||
has_device_local_host_visible_heap = true;
|
has_device_local_host_visible_heap = true;
|
||||||
size = (std::max)(size, heap.size);
|
size = std::max<size_t>(size, heap.size);
|
||||||
});
|
});
|
||||||
if (has_device_local_host_visible_heap) {
|
if (has_device_local_host_visible_heap) {
|
||||||
// If rebar is not supported, cut the max heap size to 40%. This will allow 2 captures to be
|
// If rebar is not supported, cut the max heap size to 40%. This will allow 2 captures to be
|
||||||
// loaded at the same time in RenderDoc. If rebar is supported, this shouldn't be an issue
|
// loaded at the same time in RenderDoc. If rebar is supported, this shouldn't be an issue
|
||||||
// as the heap will be much larger.
|
// as the heap will be much larger.
|
||||||
if (size <= MAX_STREAM_BUFFER_SIZE) {
|
if (size <= max_stream_buffer_size) {
|
||||||
size = size * 40 / 100;
|
size = size * 40 / 100;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
size = MAX_STREAM_BUFFER_SIZE;
|
size = max_stream_buffer_size;
|
||||||
}
|
}
|
||||||
return (std::min)(Common::AlignUp(size, MAX_ALIGNMENT), MAX_STREAM_BUFFER_SIZE);
|
return std::min<size_t>(Common::AlignUp(size, max_alignment), max_stream_buffer_size);
|
||||||
}
|
}
|
||||||
} // Anonymous namespace
|
} // Anonymous namespace
|
||||||
|
|
||||||
StagingBufferPool::StagingBufferPool(const Device& device_, MemoryAllocator& memory_allocator_,
|
StagingBufferPool::StagingBufferPool(const Device& device, MemoryAllocator& memory_allocator_, Scheduler& scheduler_)
|
||||||
Scheduler& scheduler_)
|
: memory_allocator{memory_allocator_}, scheduler{scheduler_}
|
||||||
: device{device_}, memory_allocator{memory_allocator_}, scheduler{scheduler_},
|
, stream_buffer_size{GetStreamBufferSize(device, 256_MiB, MAX_ALIGNMENT)}
|
||||||
stream_buffer_size{GetStreamBufferSize(device)}, region_size{stream_buffer_size /
|
{
|
||||||
StagingBufferPool::NUM_SYNCS} {
|
|
||||||
VkBufferCreateInfo stream_ci = {
|
VkBufferCreateInfo stream_ci = {
|
||||||
.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO,
|
.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO,
|
||||||
.pNext = nullptr,
|
.pNext = nullptr,
|
||||||
.flags = 0,
|
.flags = 0,
|
||||||
.size = stream_buffer_size,
|
.size = stream_buffer_size,
|
||||||
.usage = VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT |
|
.usage = VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT
|
||||||
VK_BUFFER_USAGE_INDEX_BUFFER_BIT | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT,
|
| VK_BUFFER_USAGE_INDEX_BUFFER_BIT | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT,
|
||||||
.sharingMode = VK_SHARING_MODE_EXCLUSIVE,
|
.sharingMode = VK_SHARING_MODE_EXCLUSIVE,
|
||||||
.queueFamilyIndexCount = 0,
|
.queueFamilyIndexCount = 0,
|
||||||
.pQueueFamilyIndices = nullptr,
|
.pQueueFamilyIndices = nullptr,
|
||||||
@@ -87,7 +74,16 @@ StagingBufferPool::StagingBufferPool(const Device& device_, MemoryAllocator& mem
|
|||||||
if (device.IsBufferDeviceAddressSupported()) {
|
if (device.IsBufferDeviceAddressSupported()) {
|
||||||
stream_ci.usage |= VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT;
|
stream_ci.usage |= VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT;
|
||||||
}
|
}
|
||||||
|
// Some drivers are more sensitive to increased buffer sizes
|
||||||
|
try {
|
||||||
stream_buffer = memory_allocator.CreateBuffer(stream_ci, MemoryUsage::Stream);
|
stream_buffer = memory_allocator.CreateBuffer(stream_ci, MemoryUsage::Stream);
|
||||||
|
} catch (vk::Exception& e) {
|
||||||
|
LOG_ERROR(Render_Vulkan, "Can't fit {} bytes buffer, halving", stream_ci.size);
|
||||||
|
stream_buffer_size = GetStreamBufferSize(device, 128_MiB, MAX_ALIGNMENT);
|
||||||
|
stream_ci.size = stream_buffer_size;
|
||||||
|
stream_buffer = memory_allocator.CreateBuffer(stream_ci, MemoryUsage::Stream);
|
||||||
|
}
|
||||||
|
region_size = stream_buffer_size / StagingBufferPool::NUM_SYNCS;
|
||||||
if (device.HasDebuggingToolAttached()) {
|
if (device.HasDebuggingToolAttached()) {
|
||||||
stream_buffer.SetObjectNameEXT("Stream Buffer");
|
stream_buffer.SetObjectNameEXT("Stream Buffer");
|
||||||
}
|
}
|
||||||
@@ -100,11 +96,10 @@ StagingBufferPool::StagingBufferPool(const Device& device_, MemoryAllocator& mem
|
|||||||
|
|
||||||
StagingBufferPool::~StagingBufferPool() = default;
|
StagingBufferPool::~StagingBufferPool() = default;
|
||||||
|
|
||||||
StagingBufferRef StagingBufferPool::Request(size_t size, MemoryUsage usage, bool deferred) {
|
StagingBufferRef StagingBufferPool::Request(const Device& device, size_t size, MemoryUsage usage, bool deferred) {
|
||||||
if (!deferred && usage == MemoryUsage::Upload && size <= region_size) {
|
return (!deferred && usage == MemoryUsage::Upload && size <= region_size)
|
||||||
return GetStreamBuffer(size);
|
? GetStreamBuffer(device, size)
|
||||||
}
|
: GetStagingBuffer(device, size, usage, deferred);
|
||||||
return GetStagingBuffer(size, usage, deferred);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void StagingBufferPool::FreeDeferred(StagingBufferRef& ref) {
|
void StagingBufferPool::FreeDeferred(StagingBufferRef& ref) {
|
||||||
@@ -127,11 +122,10 @@ void StagingBufferPool::TickFrame() {
|
|||||||
ReleaseCache(MemoryUsage::Download);
|
ReleaseCache(MemoryUsage::Download);
|
||||||
}
|
}
|
||||||
|
|
||||||
StagingBufferRef StagingBufferPool::GetStreamBuffer(size_t size) {
|
StagingBufferRef StagingBufferPool::GetStreamBuffer(const Device& device, size_t size) {
|
||||||
if (AreRegionsActive(Region(free_iterator) + 1,
|
if (AreRegionsActive(Region(free_iterator) + 1, (std::min)(Region(iterator + size) + 1, NUM_SYNCS))) {
|
||||||
(std::min)(Region(iterator + size) + 1, NUM_SYNCS))) {
|
|
||||||
// Avoid waiting for the previous usages to be free
|
// Avoid waiting for the previous usages to be free
|
||||||
return GetStagingBuffer(size, MemoryUsage::Upload);
|
return GetStagingBuffer(device, size, MemoryUsage::Upload);
|
||||||
}
|
}
|
||||||
const u64 current_tick = scheduler.CurrentTick();
|
const u64 current_tick = scheduler.CurrentTick();
|
||||||
std::fill(sync_ticks.begin() + Region(used_iterator), sync_ticks.begin() + Region(iterator),
|
std::fill(sync_ticks.begin() + Region(used_iterator), sync_ticks.begin() + Region(iterator),
|
||||||
@@ -140,15 +134,14 @@ StagingBufferRef StagingBufferPool::GetStreamBuffer(size_t size) {
|
|||||||
free_iterator = (std::max)(free_iterator, iterator + size);
|
free_iterator = (std::max)(free_iterator, iterator + size);
|
||||||
|
|
||||||
if (iterator + size >= stream_buffer_size) {
|
if (iterator + size >= stream_buffer_size) {
|
||||||
std::fill(sync_ticks.begin() + Region(used_iterator), sync_ticks.begin() + NUM_SYNCS,
|
std::fill(sync_ticks.begin() + Region(used_iterator), sync_ticks.begin() + NUM_SYNCS, current_tick);
|
||||||
current_tick);
|
|
||||||
used_iterator = 0;
|
used_iterator = 0;
|
||||||
iterator = 0;
|
iterator = 0;
|
||||||
free_iterator = size;
|
free_iterator = size;
|
||||||
|
|
||||||
if (AreRegionsActive(0, Region(size) + 1)) {
|
if (AreRegionsActive(0, Region(size) + 1)) {
|
||||||
// Avoid waiting for the previous usages to be free
|
// Avoid waiting for the previous usages to be free
|
||||||
return GetStagingBuffer(size, MemoryUsage::Upload);
|
return GetStagingBuffer(device, size, MemoryUsage::Upload);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const size_t offset = iterator;
|
const size_t offset = iterator;
|
||||||
@@ -156,7 +149,7 @@ StagingBufferRef StagingBufferPool::GetStreamBuffer(size_t size) {
|
|||||||
return StagingBufferRef{
|
return StagingBufferRef{
|
||||||
.buffer = *stream_buffer,
|
.buffer = *stream_buffer,
|
||||||
.device_address = stream_buffer_address,
|
.device_address = stream_buffer_address,
|
||||||
.offset = static_cast<VkDeviceSize>(offset),
|
.offset = VkDeviceSize(offset),
|
||||||
.mapped_span = stream_pointer.subspan(offset, size),
|
.mapped_span = stream_pointer.subspan(offset, size),
|
||||||
.usage{},
|
.usage{},
|
||||||
.log2_level{},
|
.log2_level{},
|
||||||
@@ -166,21 +159,18 @@ StagingBufferRef StagingBufferPool::GetStreamBuffer(size_t size) {
|
|||||||
|
|
||||||
bool StagingBufferPool::AreRegionsActive(size_t region_begin, size_t region_end) const {
|
bool StagingBufferPool::AreRegionsActive(size_t region_begin, size_t region_end) const {
|
||||||
const u64 gpu_tick = scheduler.GetMasterSemaphore().KnownGpuTick();
|
const u64 gpu_tick = scheduler.GetMasterSemaphore().KnownGpuTick();
|
||||||
return std::any_of(sync_ticks.begin() + region_begin, sync_ticks.begin() + region_end,
|
return std::any_of(sync_ticks.begin() + region_begin, sync_ticks.begin() + region_end, [gpu_tick](u64 sync_tick) {
|
||||||
[gpu_tick](u64 sync_tick) { return gpu_tick < sync_tick; });
|
return gpu_tick < sync_tick;
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
StagingBufferRef StagingBufferPool::GetStagingBuffer(size_t size, MemoryUsage usage,
|
StagingBufferRef StagingBufferPool::GetStagingBuffer(const Device& device, size_t size, MemoryUsage usage, bool deferred) {
|
||||||
bool deferred) {
|
if (const std::optional<StagingBufferRef> ref = TryGetReservedBuffer(size, usage, deferred))
|
||||||
if (const std::optional<StagingBufferRef> ref = TryGetReservedBuffer(size, usage, deferred)) {
|
|
||||||
return *ref;
|
return *ref;
|
||||||
}
|
return CreateStagingBuffer(device, size, usage, deferred);
|
||||||
return CreateStagingBuffer(size, usage, deferred);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<StagingBufferRef> StagingBufferPool::TryGetReservedBuffer(size_t size,
|
std::optional<StagingBufferRef> StagingBufferPool::TryGetReservedBuffer(size_t size, MemoryUsage usage, bool deferred) {
|
||||||
MemoryUsage usage,
|
|
||||||
bool deferred) {
|
|
||||||
StagingBuffers& cache_level = GetCache(usage)[Common::Log2Ceil(size)];
|
StagingBuffers& cache_level = GetCache(usage)[Common::Log2Ceil(size)];
|
||||||
|
|
||||||
const auto is_free = [this](const StagingBuffer& entry) {
|
const auto is_free = [this](const StagingBuffer& entry) {
|
||||||
@@ -202,7 +192,7 @@ std::optional<StagingBufferRef> StagingBufferPool::TryGetReservedBuffer(size_t s
|
|||||||
return it->Ref();
|
return it->Ref();
|
||||||
}
|
}
|
||||||
|
|
||||||
StagingBufferRef StagingBufferPool::CreateStagingBuffer(size_t size, MemoryUsage usage, bool deferred) {
|
StagingBufferRef StagingBufferPool::CreateStagingBuffer(const Device& device, size_t size, MemoryUsage usage, bool deferred) {
|
||||||
auto const log2_size = Common::Log2Ceil<u32>(u32(size));
|
auto const log2_size = Common::Log2Ceil<u32>(u32(size));
|
||||||
VkBufferCreateInfo buffer_ci = {
|
VkBufferCreateInfo buffer_ci = {
|
||||||
.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO,
|
.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO,
|
||||||
|
|||||||
@@ -33,11 +33,10 @@ class StagingBufferPool {
|
|||||||
public:
|
public:
|
||||||
static constexpr size_t NUM_SYNCS = 16;
|
static constexpr size_t NUM_SYNCS = 16;
|
||||||
|
|
||||||
explicit StagingBufferPool(const Device& device, MemoryAllocator& memory_allocator,
|
explicit StagingBufferPool(const Device& device, MemoryAllocator& memory_allocator, Scheduler& scheduler);
|
||||||
Scheduler& scheduler);
|
|
||||||
~StagingBufferPool();
|
~StagingBufferPool();
|
||||||
|
|
||||||
StagingBufferRef Request(size_t size, MemoryUsage usage, bool deferred = false);
|
StagingBufferRef Request(const Device& device, size_t size, MemoryUsage usage, bool deferred = false);
|
||||||
void FreeDeferred(StagingBufferRef& ref);
|
void FreeDeferred(StagingBufferRef& ref);
|
||||||
|
|
||||||
[[nodiscard]] VkBuffer StreamBuf() const noexcept {
|
[[nodiscard]] VkBuffer StreamBuf() const noexcept {
|
||||||
@@ -84,27 +83,18 @@ private:
|
|||||||
static constexpr size_t NUM_LEVELS = sizeof(size_t) * CHAR_BIT;
|
static constexpr size_t NUM_LEVELS = sizeof(size_t) * CHAR_BIT;
|
||||||
using StagingBuffersCache = std::array<StagingBuffers, NUM_LEVELS>;
|
using StagingBuffersCache = std::array<StagingBuffers, NUM_LEVELS>;
|
||||||
|
|
||||||
StagingBufferRef GetStreamBuffer(size_t size);
|
StagingBufferRef GetStreamBuffer(const Device& device, size_t size);
|
||||||
|
|
||||||
bool AreRegionsActive(size_t region_begin, size_t region_end) const;
|
bool AreRegionsActive(size_t region_begin, size_t region_end) const;
|
||||||
|
StagingBufferRef GetStagingBuffer(const Device& device, size_t size, MemoryUsage usage, bool deferred = false);
|
||||||
StagingBufferRef GetStagingBuffer(size_t size, MemoryUsage usage, bool deferred = false);
|
std::optional<StagingBufferRef> TryGetReservedBuffer(size_t size, MemoryUsage usage, bool deferred);
|
||||||
|
StagingBufferRef CreateStagingBuffer(const Device& device, size_t size, MemoryUsage usage, bool deferred);
|
||||||
std::optional<StagingBufferRef> TryGetReservedBuffer(size_t size, MemoryUsage usage,
|
|
||||||
bool deferred);
|
|
||||||
|
|
||||||
StagingBufferRef CreateStagingBuffer(size_t size, MemoryUsage usage, bool deferred);
|
|
||||||
|
|
||||||
StagingBuffersCache& GetCache(MemoryUsage usage);
|
StagingBuffersCache& GetCache(MemoryUsage usage);
|
||||||
|
|
||||||
void ReleaseCache(MemoryUsage usage);
|
void ReleaseCache(MemoryUsage usage);
|
||||||
|
|
||||||
void ReleaseLevel(StagingBuffersCache& cache, size_t log2);
|
void ReleaseLevel(StagingBuffersCache& cache, size_t log2);
|
||||||
size_t Region(size_t iter) const noexcept {
|
size_t Region(size_t iter) const noexcept {
|
||||||
return iter / region_size;
|
return iter / region_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Device& device;
|
|
||||||
MemoryAllocator& memory_allocator;
|
MemoryAllocator& memory_allocator;
|
||||||
Scheduler& scheduler;
|
Scheduler& scheduler;
|
||||||
|
|
||||||
|
|||||||
@@ -975,11 +975,11 @@ void TextureCacheRuntime::Finish() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
StagingBufferRef TextureCacheRuntime::UploadStagingBuffer(size_t size, bool deferred) {
|
StagingBufferRef TextureCacheRuntime::UploadStagingBuffer(size_t size, bool deferred) {
|
||||||
return staging_buffer_pool.Request(size, MemoryUsage::Upload, deferred);
|
return staging_buffer_pool.Request(device, size, MemoryUsage::Upload, deferred);
|
||||||
}
|
}
|
||||||
|
|
||||||
StagingBufferRef TextureCacheRuntime::DownloadStagingBuffer(size_t size, bool deferred) {
|
StagingBufferRef TextureCacheRuntime::DownloadStagingBuffer(size_t size, bool deferred) {
|
||||||
return staging_buffer_pool.Request(size, MemoryUsage::Download, deferred);
|
return staging_buffer_pool.Request(device, size, MemoryUsage::Download, deferred);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextureCacheRuntime::FreeDeferredStagingBuffer(StagingBufferRef& ref) {
|
void TextureCacheRuntime::FreeDeferredStagingBuffer(StagingBufferRef& ref) {
|
||||||
@@ -1011,7 +1011,7 @@ VkBuffer TextureCacheRuntime::GetTemporaryBuffer(size_t needed_size) {
|
|||||||
if (buffers[level]) {
|
if (buffers[level]) {
|
||||||
return *buffers[level];
|
return *buffers[level];
|
||||||
}
|
}
|
||||||
const auto new_size = std::bit_ceil(needed_size);
|
const auto new_size = Common::NextPow2(needed_size);
|
||||||
static constexpr VkBufferUsageFlags flags =
|
static constexpr VkBufferUsageFlags flags =
|
||||||
VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT |
|
VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT |
|
||||||
VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT | VK_BUFFER_USAGE_STORAGE_TEXEL_BUFFER_BIT;
|
VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT | VK_BUFFER_USAGE_STORAGE_TEXEL_BUFFER_BIT;
|
||||||
|
|||||||
@@ -2190,7 +2190,7 @@ void TextureCache<P>::UnregisterImage(ImageId image_id) {
|
|||||||
image.flags &= ~ImageFlagBits::BadOverlap;
|
image.flags &= ~ImageFlagBits::BadOverlap;
|
||||||
lru_cache.Free(image.lru_index);
|
lru_cache.Free(image.lru_index);
|
||||||
const auto& clear_page_table =
|
const auto& clear_page_table =
|
||||||
[image_id](u64 page, ::Common::unordered_map<u64, std::vector<ImageId>>& selected_page_table) {
|
[image_id](u64 page, ::Common::unordered_map<u64, std::vector<ImageId>, Common::IdentityHash<u64>>& selected_page_table) {
|
||||||
const auto page_it = selected_page_table.find(page);
|
const auto page_it = selected_page_table.find(page);
|
||||||
if (page_it == selected_page_table.end()) {
|
if (page_it == selected_page_table.end()) {
|
||||||
ASSERT_MSG(false, "Unregistering unregistered page={:#x}", page << YUZU_PAGEBITS);
|
ASSERT_MSG(false, "Unregistering unregistered page={:#x}", page << YUZU_PAGEBITS);
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
#include <queue>
|
#include <queue>
|
||||||
|
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
|
#include "common/hash.h"
|
||||||
#include "common/literals.h"
|
#include "common/literals.h"
|
||||||
#include "common/lru_cache.h"
|
#include "common/lru_cache.h"
|
||||||
#include <ranges>
|
#include <ranges>
|
||||||
@@ -68,7 +69,7 @@ struct AsyncDecodeContext {
|
|||||||
std::atomic_bool complete;
|
std::atomic_bool complete;
|
||||||
};
|
};
|
||||||
|
|
||||||
using TextureCacheGPUMap = ::Common::unordered_map<u64, std::vector<ImageId>>;
|
using TextureCacheGPUMap = ::Common::unordered_map<u64, std::vector<ImageId>, Common::IdentityHash<u64>>;
|
||||||
|
|
||||||
class TextureCacheChannelInfo : public ChannelInfo {
|
class TextureCacheChannelInfo : public ChannelInfo {
|
||||||
public:
|
public:
|
||||||
@@ -442,7 +443,7 @@ private:
|
|||||||
u64 last_framebuffer_serial = 0;
|
u64 last_framebuffer_serial = 0;
|
||||||
|
|
||||||
::Common::unordered_map<RenderTargets, FramebufferId> framebuffers;
|
::Common::unordered_map<RenderTargets, FramebufferId> framebuffers;
|
||||||
::Common::unordered_map<u64, std::vector<ImageMapId>> page_table;
|
::Common::unordered_map<u64, std::vector<ImageMapId>, Common::IdentityHash<u64>> page_table;
|
||||||
::Common::unordered_map<ImageId, boost::container::small_vector<ImageViewId, 16>> sparse_views;
|
::Common::unordered_map<ImageId, boost::container::small_vector<ImageViewId, 16>> sparse_views;
|
||||||
|
|
||||||
DAddr virtual_invalid_space{};
|
DAddr virtual_invalid_space{};
|
||||||
|
|||||||
Reference in New Issue
Block a user