diff options
15 files changed, 192 insertions, 146 deletions
diff --git a/src/android/app/build.gradle.kts b/src/android/app/build.gradle.kts index 13bb227ff..d4698ae1c 100644 --- a/src/android/app/build.gradle.kts +++ b/src/android/app/build.gradle.kts | |||
| @@ -74,16 +74,7 @@ android { | |||
| 74 | 74 | ||
| 75 | // Signed by release key, allowing for upload to Play Store. | 75 | // Signed by release key, allowing for upload to Play Store. |
| 76 | release { | 76 | release { |
| 77 | signingConfig = signingConfigs.getByName("debug") | 77 | resValue("string", "app_name_suffixed", "yuzu") |
| 78 | isMinifyEnabled = true | ||
| 79 | isDebuggable = false | ||
| 80 | proguardFiles( | ||
| 81 | getDefaultProguardFile("proguard-android.txt"), | ||
| 82 | "proguard-rules.pro" | ||
| 83 | ) | ||
| 84 | } | ||
| 85 | |||
| 86 | register("relWithVersionCode") { | ||
| 87 | signingConfig = signingConfigs.getByName("debug") | 78 | signingConfig = signingConfigs.getByName("debug") |
| 88 | isMinifyEnabled = true | 79 | isMinifyEnabled = true |
| 89 | isDebuggable = false | 80 | isDebuggable = false |
| @@ -96,6 +87,7 @@ android { | |||
| 96 | // builds a release build that doesn't need signing | 87 | // builds a release build that doesn't need signing |
| 97 | // Attaches 'debug' suffix to version and package name, allowing installation alongside the release build. | 88 | // Attaches 'debug' suffix to version and package name, allowing installation alongside the release build. |
| 98 | register("relWithDebInfo") { | 89 | register("relWithDebInfo") { |
| 90 | resValue("string", "app_name_suffixed", "yuzu Debug Release") | ||
| 99 | signingConfig = signingConfigs.getByName("debug") | 91 | signingConfig = signingConfigs.getByName("debug") |
| 100 | isMinifyEnabled = true | 92 | isMinifyEnabled = true |
| 101 | isDebuggable = true | 93 | isDebuggable = true |
| @@ -103,16 +95,19 @@ android { | |||
| 103 | getDefaultProguardFile("proguard-android.txt"), | 95 | getDefaultProguardFile("proguard-android.txt"), |
| 104 | "proguard-rules.pro" | 96 | "proguard-rules.pro" |
| 105 | ) | 97 | ) |
| 106 | versionNameSuffix = "-debug" | 98 | versionNameSuffix = "-relWithDebInfo" |
| 99 | applicationIdSuffix = ".relWithDebInfo" | ||
| 107 | isJniDebuggable = true | 100 | isJniDebuggable = true |
| 108 | } | 101 | } |
| 109 | 102 | ||
| 110 | // Signed by debug key disallowing distribution on Play Store. | 103 | // Signed by debug key disallowing distribution on Play Store. |
| 111 | // Attaches 'debug' suffix to version and package name, allowing installation alongside the release build. | 104 | // Attaches 'debug' suffix to version and package name, allowing installation alongside the release build. |
| 112 | debug { | 105 | debug { |
| 106 | resValue("string", "app_name_suffixed", "yuzu Debug") | ||
| 113 | isDebuggable = true | 107 | isDebuggable = true |
| 114 | isJniDebuggable = true | 108 | isJniDebuggable = true |
| 115 | versionNameSuffix = "-debug" | 109 | versionNameSuffix = "-debug" |
| 110 | applicationIdSuffix = ".debug" | ||
| 116 | } | 111 | } |
| 117 | } | 112 | } |
| 118 | 113 | ||
| @@ -162,19 +157,19 @@ dependencies { | |||
| 162 | implementation("androidx.appcompat:appcompat:1.6.1") | 157 | implementation("androidx.appcompat:appcompat:1.6.1") |
| 163 | implementation("androidx.recyclerview:recyclerview:1.3.0") | 158 | implementation("androidx.recyclerview:recyclerview:1.3.0") |
| 164 | implementation("androidx.constraintlayout:constraintlayout:2.1.4") | 159 | implementation("androidx.constraintlayout:constraintlayout:2.1.4") |
| 165 | implementation("androidx.fragment:fragment-ktx:1.5.7") | 160 | implementation("androidx.fragment:fragment-ktx:1.6.0") |
| 166 | implementation("androidx.documentfile:documentfile:1.0.1") | 161 | implementation("androidx.documentfile:documentfile:1.0.1") |
| 167 | implementation("com.google.android.material:material:1.9.0") | 162 | implementation("com.google.android.material:material:1.9.0") |
| 168 | implementation("androidx.preference:preference:1.2.0") | 163 | implementation("androidx.preference:preference:1.2.0") |
| 169 | implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.1") | 164 | implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.1") |
| 170 | implementation("io.coil-kt:coil:2.2.2") | 165 | implementation("io.coil-kt:coil:2.2.2") |
| 171 | implementation("androidx.core:core-splashscreen:1.0.1") | 166 | implementation("androidx.core:core-splashscreen:1.0.1") |
| 172 | implementation("androidx.window:window:1.0.0") | 167 | implementation("androidx.window:window:1.1.0") |
| 173 | implementation("org.ini4j:ini4j:0.5.4") | 168 | implementation("org.ini4j:ini4j:0.5.4") |
| 174 | implementation("androidx.constraintlayout:constraintlayout:2.1.4") | 169 | implementation("androidx.constraintlayout:constraintlayout:2.1.4") |
| 175 | implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.1.0") | 170 | implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.1.0") |
| 176 | implementation("androidx.navigation:navigation-fragment-ktx:2.5.3") | 171 | implementation("androidx.navigation:navigation-fragment-ktx:2.6.0") |
| 177 | implementation("androidx.navigation:navigation-ui-ktx:2.5.3") | 172 | implementation("androidx.navigation:navigation-ui-ktx:2.6.0") |
| 178 | implementation("info.debatty:java-string-similarity:2.0.0") | 173 | implementation("info.debatty:java-string-similarity:2.0.0") |
| 179 | implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.0") | 174 | implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.0") |
| 180 | } | 175 | } |
diff --git a/src/android/app/src/main/AndroidManifest.xml b/src/android/app/src/main/AndroidManifest.xml index eef566042..1e92098ec 100644 --- a/src/android/app/src/main/AndroidManifest.xml +++ b/src/android/app/src/main/AndroidManifest.xml | |||
| @@ -18,7 +18,7 @@ SPDX-License-Identifier: GPL-3.0-or-later | |||
| 18 | 18 | ||
| 19 | <application | 19 | <application |
| 20 | android:name="org.yuzu.yuzu_emu.YuzuApplication" | 20 | android:name="org.yuzu.yuzu_emu.YuzuApplication" |
| 21 | android:label="@string/app_name" | 21 | android:label="@string/app_name_suffixed" |
| 22 | android:icon="@drawable/ic_launcher" | 22 | android:icon="@drawable/ic_launcher" |
| 23 | android:allowBackup="true" | 23 | android:allowBackup="true" |
| 24 | android:hasFragileUserData="true" | 24 | android:hasFragileUserData="true" |
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/activities/EmulationActivity.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/activities/EmulationActivity.kt index f4db61cb3..20a0394f5 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/activities/EmulationActivity.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/activities/EmulationActivity.kt | |||
| @@ -6,15 +6,12 @@ package org.yuzu.yuzu_emu.activities | |||
| 6 | import android.app.Activity | 6 | import android.app.Activity |
| 7 | import android.content.Context | 7 | import android.content.Context |
| 8 | import android.content.Intent | 8 | import android.content.Intent |
| 9 | import android.content.res.Configuration | ||
| 10 | import android.graphics.Rect | 9 | import android.graphics.Rect |
| 11 | import android.hardware.Sensor | 10 | import android.hardware.Sensor |
| 12 | import android.hardware.SensorEvent | 11 | import android.hardware.SensorEvent |
| 13 | import android.hardware.SensorEventListener | 12 | import android.hardware.SensorEventListener |
| 14 | import android.hardware.SensorManager | 13 | import android.hardware.SensorManager |
| 15 | import android.hardware.display.DisplayManager | ||
| 16 | import android.os.Bundle | 14 | import android.os.Bundle |
| 17 | import android.view.Display | ||
| 18 | import android.view.InputDevice | 15 | import android.view.InputDevice |
| 19 | import android.view.KeyEvent | 16 | import android.view.KeyEvent |
| 20 | import android.view.MotionEvent | 17 | import android.view.MotionEvent |
| @@ -23,7 +20,6 @@ import android.view.View | |||
| 23 | import android.view.inputmethod.InputMethodManager | 20 | import android.view.inputmethod.InputMethodManager |
| 24 | import androidx.activity.viewModels | 21 | import androidx.activity.viewModels |
| 25 | import androidx.appcompat.app.AppCompatActivity | 22 | import androidx.appcompat.app.AppCompatActivity |
| 26 | import androidx.core.content.getSystemService | ||
| 27 | import androidx.core.view.WindowCompat | 23 | import androidx.core.view.WindowCompat |
| 28 | import androidx.core.view.WindowInsetsCompat | 24 | import androidx.core.view.WindowInsetsCompat |
| 29 | import androidx.core.view.WindowInsetsControllerCompat | 25 | import androidx.core.view.WindowInsetsControllerCompat |
| @@ -39,7 +35,6 @@ import org.yuzu.yuzu_emu.features.settings.model.SettingsViewModel | |||
| 39 | import org.yuzu.yuzu_emu.fragments.EmulationFragment | 35 | import org.yuzu.yuzu_emu.fragments.EmulationFragment |
| 40 | import org.yuzu.yuzu_emu.model.Game | 36 | import org.yuzu.yuzu_emu.model.Game |
| 41 | import org.yuzu.yuzu_emu.utils.ControllerMappingHelper | 37 | import org.yuzu.yuzu_emu.utils.ControllerMappingHelper |
| 42 | import org.yuzu.yuzu_emu.utils.EmulationMenuSettings | ||
| 43 | import org.yuzu.yuzu_emu.utils.ForegroundService | 38 | import org.yuzu.yuzu_emu.utils.ForegroundService |
| 44 | import org.yuzu.yuzu_emu.utils.InputHandler | 39 | import org.yuzu.yuzu_emu.utils.InputHandler |
| 45 | import org.yuzu.yuzu_emu.utils.NfcReader | 40 | import org.yuzu.yuzu_emu.utils.NfcReader |
| @@ -148,11 +143,6 @@ class EmulationActivity : AppCompatActivity(), SensorEventListener { | |||
| 148 | super.onResume() | 143 | super.onResume() |
| 149 | nfcReader.startScanning() | 144 | nfcReader.startScanning() |
| 150 | startMotionSensorListener() | 145 | startMotionSensorListener() |
| 151 | |||
| 152 | NativeLibrary.notifyOrientationChange( | ||
| 153 | EmulationMenuSettings.landscapeScreenLayout, | ||
| 154 | getAdjustedRotation() | ||
| 155 | ) | ||
| 156 | } | 146 | } |
| 157 | 147 | ||
| 158 | override fun onPause() { | 148 | override fun onPause() { |
| @@ -258,24 +248,6 @@ class EmulationActivity : AppCompatActivity(), SensorEventListener { | |||
| 258 | 248 | ||
| 259 | override fun onAccuracyChanged(sensor: Sensor, i: Int) {} | 249 | override fun onAccuracyChanged(sensor: Sensor, i: Int) {} |
| 260 | 250 | ||
| 261 | private fun getAdjustedRotation():Int { | ||
| 262 | val rotation = getSystemService<DisplayManager>()!!.getDisplay(Display.DEFAULT_DISPLAY).rotation | ||
| 263 | val config: Configuration = resources.configuration | ||
| 264 | |||
| 265 | if ((config.screenLayout and Configuration.SCREENLAYOUT_LONG_YES) != 0 || | ||
| 266 | (config.screenLayout and Configuration.SCREENLAYOUT_LONG_NO) == 0 || | ||
| 267 | (config.screenLayout and Configuration.SCREENLAYOUT_SIZE_SMALL) != 0) { | ||
| 268 | return rotation | ||
| 269 | } | ||
| 270 | when (rotation) { | ||
| 271 | Surface.ROTATION_0 -> return Surface.ROTATION_90 | ||
| 272 | Surface.ROTATION_90 -> return Surface.ROTATION_0 | ||
| 273 | Surface.ROTATION_180 -> return Surface.ROTATION_270 | ||
| 274 | Surface.ROTATION_270 -> return Surface.ROTATION_180 | ||
| 275 | } | ||
| 276 | return rotation | ||
| 277 | } | ||
| 278 | |||
| 279 | private fun restoreState(savedInstanceState: Bundle) { | 251 | private fun restoreState(savedInstanceState: Bundle) { |
| 280 | game = savedInstanceState.parcelable(EXTRA_SELECTED_GAME)!! | 252 | game = savedInstanceState.parcelable(EXTRA_SELECTED_GAME)!! |
| 281 | } | 253 | } |
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/ui/main/MainActivity.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/ui/main/MainActivity.kt index 124f62f08..3fca0a7e6 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/ui/main/MainActivity.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/ui/main/MainActivity.kt | |||
| @@ -284,10 +284,10 @@ class MainActivity : AppCompatActivity(), ThemeProvider { | |||
| 284 | if (result == null) | 284 | if (result == null) |
| 285 | return@registerForActivityResult | 285 | return@registerForActivityResult |
| 286 | 286 | ||
| 287 | if (!FileUtil.hasExtension(result.toString(), "keys")) { | 287 | if (!FileUtil.hasExtension(result, "keys")) { |
| 288 | MessageDialogFragment.newInstance( | 288 | MessageDialogFragment.newInstance( |
| 289 | R.string.reading_keys_failure, | 289 | R.string.reading_keys_failure, |
| 290 | R.string.install_keys_failure_extension_description | 290 | R.string.install_prod_keys_failure_extension_description |
| 291 | ).show(supportFragmentManager, MessageDialogFragment.TAG) | 291 | ).show(supportFragmentManager, MessageDialogFragment.TAG) |
| 292 | return@registerForActivityResult | 292 | return@registerForActivityResult |
| 293 | } | 293 | } |
| @@ -379,10 +379,10 @@ class MainActivity : AppCompatActivity(), ThemeProvider { | |||
| 379 | if (result == null) | 379 | if (result == null) |
| 380 | return@registerForActivityResult | 380 | return@registerForActivityResult |
| 381 | 381 | ||
| 382 | if (!FileUtil.hasExtension(result.toString(), "bin")) { | 382 | if (!FileUtil.hasExtension(result, "bin")) { |
| 383 | MessageDialogFragment.newInstance( | 383 | MessageDialogFragment.newInstance( |
| 384 | R.string.reading_keys_failure, | 384 | R.string.reading_keys_failure, |
| 385 | R.string.install_keys_failure_extension_description | 385 | R.string.install_amiibo_keys_failure_extension_description |
| 386 | ).show(supportFragmentManager, MessageDialogFragment.TAG) | 386 | ).show(supportFragmentManager, MessageDialogFragment.TAG) |
| 387 | return@registerForActivityResult | 387 | return@registerForActivityResult |
| 388 | } | 388 | } |
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/FileUtil.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/FileUtil.kt index 593dad8d3..492b1ad91 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/FileUtil.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/FileUtil.kt | |||
| @@ -7,7 +7,9 @@ import android.content.Context | |||
| 7 | import android.database.Cursor | 7 | import android.database.Cursor |
| 8 | import android.net.Uri | 8 | import android.net.Uri |
| 9 | import android.provider.DocumentsContract | 9 | import android.provider.DocumentsContract |
| 10 | import android.provider.OpenableColumns | ||
| 10 | import androidx.documentfile.provider.DocumentFile | 11 | import androidx.documentfile.provider.DocumentFile |
| 12 | import org.yuzu.yuzu_emu.YuzuApplication | ||
| 11 | import org.yuzu.yuzu_emu.model.MinimalDocumentFile | 13 | import org.yuzu.yuzu_emu.model.MinimalDocumentFile |
| 12 | import java.io.BufferedInputStream | 14 | import java.io.BufferedInputStream |
| 13 | import java.io.File | 15 | import java.io.File |
| @@ -324,7 +326,25 @@ object FileUtil { | |||
| 324 | } | 326 | } |
| 325 | } | 327 | } |
| 326 | 328 | ||
| 327 | fun hasExtension(path: String, extension: String): Boolean { | 329 | fun hasExtension(path: String, extension: String): Boolean = |
| 328 | return path.substring(path.lastIndexOf(".") + 1).contains(extension) | 330 | path.substring(path.lastIndexOf(".") + 1).contains(extension) |
| 331 | |||
| 332 | fun hasExtension(uri: Uri, extension: String): Boolean { | ||
| 333 | val fileName: String? | ||
| 334 | val cursor = YuzuApplication.appContext.contentResolver.query(uri, null, null, null, null) | ||
| 335 | val nameIndex = cursor?.getColumnIndex(OpenableColumns.DISPLAY_NAME) | ||
| 336 | cursor?.moveToFirst() | ||
| 337 | |||
| 338 | if (nameIndex == null) { | ||
| 339 | return false | ||
| 340 | } | ||
| 341 | |||
| 342 | fileName = cursor.getString(nameIndex) | ||
| 343 | cursor.close() | ||
| 344 | |||
| 345 | if (fileName == null) { | ||
| 346 | return false | ||
| 347 | } | ||
| 348 | return fileName.substring(fileName.lastIndexOf(".") + 1).contains(extension) | ||
| 329 | } | 349 | } |
| 330 | } | 350 | } |
diff --git a/src/android/app/src/main/jni/native.cpp b/src/android/app/src/main/jni/native.cpp index 03cb0b74b..7ebed5e6a 100644 --- a/src/android/app/src/main/jni/native.cpp +++ b/src/android/app/src/main/jni/native.cpp | |||
| @@ -94,14 +94,6 @@ public: | |||
| 94 | m_native_window = native_window; | 94 | m_native_window = native_window; |
| 95 | } | 95 | } |
| 96 | 96 | ||
| 97 | u32 ScreenRotation() const { | ||
| 98 | return m_screen_rotation; | ||
| 99 | } | ||
| 100 | |||
| 101 | void SetScreenRotation(u32 screen_rotation) { | ||
| 102 | m_screen_rotation = screen_rotation; | ||
| 103 | } | ||
| 104 | |||
| 105 | void InitializeGpuDriver(const std::string& hook_lib_dir, const std::string& custom_driver_dir, | 97 | void InitializeGpuDriver(const std::string& hook_lib_dir, const std::string& custom_driver_dir, |
| 106 | const std::string& custom_driver_name, | 98 | const std::string& custom_driver_name, |
| 107 | const std::string& file_redirect_dir) { | 99 | const std::string& file_redirect_dir) { |
| @@ -400,7 +392,6 @@ private: | |||
| 400 | // Window management | 392 | // Window management |
| 401 | std::unique_ptr<EmuWindow_Android> m_window; | 393 | std::unique_ptr<EmuWindow_Android> m_window; |
| 402 | ANativeWindow* m_native_window{}; | 394 | ANativeWindow* m_native_window{}; |
| 403 | u32 m_screen_rotation{}; | ||
| 404 | 395 | ||
| 405 | // Core emulation | 396 | // Core emulation |
| 406 | Core::System m_system; | 397 | Core::System m_system; |
| @@ -426,10 +417,6 @@ private: | |||
| 426 | 417 | ||
| 427 | } // Anonymous namespace | 418 | } // Anonymous namespace |
| 428 | 419 | ||
| 429 | u32 GetAndroidScreenRotation() { | ||
| 430 | return EmulationSession::GetInstance().ScreenRotation(); | ||
| 431 | } | ||
| 432 | |||
| 433 | static Core::SystemResultStatus RunEmulation(const std::string& filepath) { | 420 | static Core::SystemResultStatus RunEmulation(const std::string& filepath) { |
| 434 | Common::Log::Initialize(); | 421 | Common::Log::Initialize(); |
| 435 | Common::Log::SetColorConsoleBackendEnabled(true); | 422 | Common::Log::SetColorConsoleBackendEnabled(true); |
| @@ -473,13 +460,6 @@ void Java_org_yuzu_yuzu_1emu_NativeLibrary_surfaceDestroyed(JNIEnv* env, | |||
| 473 | EmulationSession::GetInstance().SurfaceChanged(); | 460 | EmulationSession::GetInstance().SurfaceChanged(); |
| 474 | } | 461 | } |
| 475 | 462 | ||
| 476 | void Java_org_yuzu_yuzu_1emu_NativeLibrary_notifyOrientationChange(JNIEnv* env, | ||
| 477 | [[maybe_unused]] jclass clazz, | ||
| 478 | jint layout_option, | ||
| 479 | jint rotation) { | ||
| 480 | return EmulationSession::GetInstance().SetScreenRotation(static_cast<u32>(rotation)); | ||
| 481 | } | ||
| 482 | |||
| 483 | void Java_org_yuzu_yuzu_1emu_NativeLibrary_setAppDirectory(JNIEnv* env, | 463 | void Java_org_yuzu_yuzu_1emu_NativeLibrary_setAppDirectory(JNIEnv* env, |
| 484 | [[maybe_unused]] jclass clazz, | 464 | [[maybe_unused]] jclass clazz, |
| 485 | jstring j_directory) { | 465 | jstring j_directory) { |
diff --git a/src/android/app/src/main/res/values/strings.xml b/src/android/app/src/main/res/values/strings.xml index 0ae69afb4..6e9d47557 100644 --- a/src/android/app/src/main/res/values/strings.xml +++ b/src/android/app/src/main/res/values/strings.xml | |||
| @@ -65,11 +65,8 @@ | |||
| 65 | <string name="invalid_keys_file">Invalid keys file selected</string> | 65 | <string name="invalid_keys_file">Invalid keys file selected</string> |
| 66 | <string name="install_keys_success">Keys successfully installed</string> | 66 | <string name="install_keys_success">Keys successfully installed</string> |
| 67 | <string name="reading_keys_failure">Error reading encryption keys</string> | 67 | <string name="reading_keys_failure">Error reading encryption keys</string> |
| 68 | <string name="install_keys_failure_extension_description"> | 68 | <string name="install_prod_keys_failure_extension_description">Verify your keys file has a .keys extension and try again.</string> |
| 69 | 1. Verify your keys have the .keys extension.\n\n | 69 | <string name="install_amiibo_keys_failure_extension_description">Verify your keys file has a .bin extension and try again.</string> |
| 70 | 2. Keys must not be stored in the Downloads folder.\n\n | ||
| 71 | Resolve the issue(s) and try again. | ||
| 72 | </string> | ||
| 73 | <string name="invalid_keys_error">Invalid encryption keys</string> | 70 | <string name="invalid_keys_error">Invalid encryption keys</string> |
| 74 | <string name="dumping_keys_quickstart_link">https://yuzu-emu.org/help/quickstart/#dumping-decryption-keys</string> | 71 | <string name="dumping_keys_quickstart_link">https://yuzu-emu.org/help/quickstart/#dumping-decryption-keys</string> |
| 75 | <string name="install_keys_failure_description">The selected file is incorrect or corrupt. Please redump your keys.</string> | 72 | <string name="install_keys_failure_description">The selected file is incorrect or corrupt. Please redump your keys.</string> |
diff --git a/src/video_core/buffer_cache/buffer_cache.h b/src/video_core/buffer_cache/buffer_cache.h index 2f281b370..251a4a880 100644 --- a/src/video_core/buffer_cache/buffer_cache.h +++ b/src/video_core/buffer_cache/buffer_cache.h | |||
| @@ -715,20 +715,38 @@ void BufferCache<P>::BindHostIndexBuffer() { | |||
| 715 | 715 | ||
| 716 | template <class P> | 716 | template <class P> |
| 717 | void BufferCache<P>::BindHostVertexBuffers() { | 717 | void BufferCache<P>::BindHostVertexBuffers() { |
| 718 | HostBindings host_bindings; | ||
| 719 | bool any_valid{false}; | ||
| 718 | auto& flags = maxwell3d->dirty.flags; | 720 | auto& flags = maxwell3d->dirty.flags; |
| 719 | for (u32 index = 0; index < NUM_VERTEX_BUFFERS; ++index) { | 721 | for (u32 index = 0; index < NUM_VERTEX_BUFFERS; ++index) { |
| 720 | const Binding& binding = channel_state->vertex_buffers[index]; | ||
| 721 | Buffer& buffer = slot_buffers[binding.buffer_id]; | ||
| 722 | TouchBuffer(buffer, binding.buffer_id); | ||
| 723 | SynchronizeBuffer(buffer, binding.cpu_addr, binding.size); | ||
| 724 | if (!flags[Dirty::VertexBuffer0 + index]) { | 722 | if (!flags[Dirty::VertexBuffer0 + index]) { |
| 725 | continue; | 723 | continue; |
| 726 | } | 724 | } |
| 727 | flags[Dirty::VertexBuffer0 + index] = false; | 725 | host_bindings.min_index = std::min(host_bindings.min_index, index); |
| 726 | host_bindings.max_index = std::max(host_bindings.max_index, index); | ||
| 727 | any_valid = true; | ||
| 728 | } | ||
| 728 | 729 | ||
| 729 | const u32 stride = maxwell3d->regs.vertex_streams[index].stride; | 730 | if (any_valid) { |
| 730 | const u32 offset = buffer.Offset(binding.cpu_addr); | 731 | host_bindings.max_index++; |
| 731 | runtime.BindVertexBuffer(index, buffer, offset, binding.size, stride); | 732 | for (u32 index = host_bindings.min_index; index < host_bindings.max_index; index++) { |
| 733 | flags[Dirty::VertexBuffer0 + index] = false; | ||
| 734 | |||
| 735 | const Binding& binding = channel_state->vertex_buffers[index]; | ||
| 736 | Buffer& buffer = slot_buffers[binding.buffer_id]; | ||
| 737 | |||
| 738 | TouchBuffer(buffer, binding.buffer_id); | ||
| 739 | SynchronizeBuffer(buffer, binding.cpu_addr, binding.size); | ||
| 740 | |||
| 741 | const u32 stride = maxwell3d->regs.vertex_streams[index].stride; | ||
| 742 | const u32 offset = buffer.Offset(binding.cpu_addr); | ||
| 743 | |||
| 744 | host_bindings.buffers.push_back(reinterpret_cast<void*>(&buffer)); | ||
| 745 | host_bindings.offsets.push_back(offset); | ||
| 746 | host_bindings.sizes.push_back(binding.size); | ||
| 747 | host_bindings.strides.push_back(stride); | ||
| 748 | } | ||
| 749 | runtime.BindVertexBuffers(host_bindings); | ||
| 732 | } | 750 | } |
| 733 | } | 751 | } |
| 734 | 752 | ||
| @@ -882,15 +900,25 @@ void BufferCache<P>::BindHostTransformFeedbackBuffers() { | |||
| 882 | if (maxwell3d->regs.transform_feedback_enabled == 0) { | 900 | if (maxwell3d->regs.transform_feedback_enabled == 0) { |
| 883 | return; | 901 | return; |
| 884 | } | 902 | } |
| 903 | HostBindings host_bindings; | ||
| 885 | for (u32 index = 0; index < NUM_TRANSFORM_FEEDBACK_BUFFERS; ++index) { | 904 | for (u32 index = 0; index < NUM_TRANSFORM_FEEDBACK_BUFFERS; ++index) { |
| 886 | const Binding& binding = channel_state->transform_feedback_buffers[index]; | 905 | const Binding& binding = channel_state->transform_feedback_buffers[index]; |
| 906 | if (maxwell3d->regs.transform_feedback.controls[index].varying_count == 0 && | ||
| 907 | maxwell3d->regs.transform_feedback.controls[index].stride == 0) { | ||
| 908 | break; | ||
| 909 | } | ||
| 887 | Buffer& buffer = slot_buffers[binding.buffer_id]; | 910 | Buffer& buffer = slot_buffers[binding.buffer_id]; |
| 888 | TouchBuffer(buffer, binding.buffer_id); | 911 | TouchBuffer(buffer, binding.buffer_id); |
| 889 | const u32 size = binding.size; | 912 | const u32 size = binding.size; |
| 890 | SynchronizeBuffer(buffer, binding.cpu_addr, size); | 913 | SynchronizeBuffer(buffer, binding.cpu_addr, size); |
| 891 | 914 | ||
| 892 | const u32 offset = buffer.Offset(binding.cpu_addr); | 915 | const u32 offset = buffer.Offset(binding.cpu_addr); |
| 893 | runtime.BindTransformFeedbackBuffer(index, buffer, offset, size); | 916 | host_bindings.buffers.push_back(reinterpret_cast<void*>(&buffer)); |
| 917 | host_bindings.offsets.push_back(offset); | ||
| 918 | host_bindings.sizes.push_back(binding.size); | ||
| 919 | } | ||
| 920 | if (host_bindings.buffers.size() > 0) { | ||
| 921 | runtime.BindTransformFeedbackBuffers(host_bindings); | ||
| 894 | } | 922 | } |
| 895 | } | 923 | } |
| 896 | 924 | ||
| @@ -1616,6 +1644,8 @@ void BufferCache<P>::DownloadBufferMemory(Buffer& buffer, VAddr cpu_addr, u64 si | |||
| 1616 | 1644 | ||
| 1617 | template <class P> | 1645 | template <class P> |
| 1618 | void BufferCache<P>::DeleteBuffer(BufferId buffer_id, bool do_not_mark) { | 1646 | void BufferCache<P>::DeleteBuffer(BufferId buffer_id, bool do_not_mark) { |
| 1647 | bool dirty_index{false}; | ||
| 1648 | boost::container::small_vector<u64, NUM_VERTEX_BUFFERS> dirty_vertex_buffers; | ||
| 1619 | const auto scalar_replace = [buffer_id](Binding& binding) { | 1649 | const auto scalar_replace = [buffer_id](Binding& binding) { |
| 1620 | if (binding.buffer_id == buffer_id) { | 1650 | if (binding.buffer_id == buffer_id) { |
| 1621 | binding.buffer_id = BufferId{}; | 1651 | binding.buffer_id = BufferId{}; |
| @@ -1624,8 +1654,19 @@ void BufferCache<P>::DeleteBuffer(BufferId buffer_id, bool do_not_mark) { | |||
| 1624 | const auto replace = [scalar_replace](std::span<Binding> bindings) { | 1654 | const auto replace = [scalar_replace](std::span<Binding> bindings) { |
| 1625 | std::ranges::for_each(bindings, scalar_replace); | 1655 | std::ranges::for_each(bindings, scalar_replace); |
| 1626 | }; | 1656 | }; |
| 1627 | scalar_replace(channel_state->index_buffer); | 1657 | |
| 1628 | replace(channel_state->vertex_buffers); | 1658 | if (channel_state->index_buffer.buffer_id == buffer_id) { |
| 1659 | channel_state->index_buffer.buffer_id = BufferId{}; | ||
| 1660 | dirty_index = true; | ||
| 1661 | } | ||
| 1662 | |||
| 1663 | for (u32 index = 0; index < channel_state->vertex_buffers.size(); index++) { | ||
| 1664 | auto& binding = channel_state->vertex_buffers[index]; | ||
| 1665 | if (binding.buffer_id == buffer_id) { | ||
| 1666 | binding.buffer_id = BufferId{}; | ||
| 1667 | dirty_vertex_buffers.push_back(index); | ||
| 1668 | } | ||
| 1669 | } | ||
| 1629 | std::ranges::for_each(channel_state->uniform_buffers, replace); | 1670 | std::ranges::for_each(channel_state->uniform_buffers, replace); |
| 1630 | std::ranges::for_each(channel_state->storage_buffers, replace); | 1671 | std::ranges::for_each(channel_state->storage_buffers, replace); |
| 1631 | replace(channel_state->transform_feedback_buffers); | 1672 | replace(channel_state->transform_feedback_buffers); |
| @@ -1642,20 +1683,21 @@ void BufferCache<P>::DeleteBuffer(BufferId buffer_id, bool do_not_mark) { | |||
| 1642 | delayed_destruction_ring.Push(std::move(slot_buffers[buffer_id])); | 1683 | delayed_destruction_ring.Push(std::move(slot_buffers[buffer_id])); |
| 1643 | slot_buffers.erase(buffer_id); | 1684 | slot_buffers.erase(buffer_id); |
| 1644 | 1685 | ||
| 1645 | NotifyBufferDeletion(); | ||
| 1646 | } | ||
| 1647 | |||
| 1648 | template <class P> | ||
| 1649 | void BufferCache<P>::NotifyBufferDeletion() { | ||
| 1650 | if constexpr (HAS_PERSISTENT_UNIFORM_BUFFER_BINDINGS) { | 1686 | if constexpr (HAS_PERSISTENT_UNIFORM_BUFFER_BINDINGS) { |
| 1651 | channel_state->dirty_uniform_buffers.fill(~u32{0}); | 1687 | channel_state->dirty_uniform_buffers.fill(~u32{0}); |
| 1652 | channel_state->uniform_buffer_binding_sizes.fill({}); | 1688 | channel_state->uniform_buffer_binding_sizes.fill({}); |
| 1653 | } | 1689 | } |
| 1690 | |||
| 1654 | auto& flags = maxwell3d->dirty.flags; | 1691 | auto& flags = maxwell3d->dirty.flags; |
| 1655 | flags[Dirty::IndexBuffer] = true; | 1692 | if (dirty_index) { |
| 1656 | flags[Dirty::VertexBuffers] = true; | 1693 | flags[Dirty::IndexBuffer] = true; |
| 1657 | for (u32 index = 0; index < NUM_VERTEX_BUFFERS; ++index) { | 1694 | } |
| 1658 | flags[Dirty::VertexBuffer0 + index] = true; | 1695 | |
| 1696 | if (dirty_vertex_buffers.size() > 0) { | ||
| 1697 | flags[Dirty::VertexBuffers] = true; | ||
| 1698 | for (auto index : dirty_vertex_buffers) { | ||
| 1699 | flags[Dirty::VertexBuffer0 + index] = true; | ||
| 1700 | } | ||
| 1659 | } | 1701 | } |
| 1660 | channel_state->has_deleted_buffers = true; | 1702 | channel_state->has_deleted_buffers = true; |
| 1661 | } | 1703 | } |
diff --git a/src/video_core/buffer_cache/buffer_cache_base.h b/src/video_core/buffer_cache/buffer_cache_base.h index 60a1f285e..cf359e241 100644 --- a/src/video_core/buffer_cache/buffer_cache_base.h +++ b/src/video_core/buffer_cache/buffer_cache_base.h | |||
| @@ -105,6 +105,15 @@ static constexpr Binding NULL_BINDING{ | |||
| 105 | .buffer_id = NULL_BUFFER_ID, | 105 | .buffer_id = NULL_BUFFER_ID, |
| 106 | }; | 106 | }; |
| 107 | 107 | ||
| 108 | struct HostBindings { | ||
| 109 | boost::container::small_vector<void*, NUM_VERTEX_BUFFERS> buffers; | ||
| 110 | boost::container::small_vector<u64, NUM_VERTEX_BUFFERS> offsets; | ||
| 111 | boost::container::small_vector<u64, NUM_VERTEX_BUFFERS> sizes; | ||
| 112 | boost::container::small_vector<u64, NUM_VERTEX_BUFFERS> strides; | ||
| 113 | u32 min_index{NUM_VERTEX_BUFFERS}; | ||
| 114 | u32 max_index{0}; | ||
| 115 | }; | ||
| 116 | |||
| 108 | class BufferCacheChannelInfo : public ChannelInfo { | 117 | class BufferCacheChannelInfo : public ChannelInfo { |
| 109 | public: | 118 | public: |
| 110 | BufferCacheChannelInfo() = delete; | 119 | BufferCacheChannelInfo() = delete; |
| @@ -519,8 +528,6 @@ private: | |||
| 519 | 528 | ||
| 520 | void DeleteBuffer(BufferId buffer_id, bool do_not_mark = false); | 529 | void DeleteBuffer(BufferId buffer_id, bool do_not_mark = false); |
| 521 | 530 | ||
| 522 | void NotifyBufferDeletion(); | ||
| 523 | |||
| 524 | [[nodiscard]] Binding StorageBufferBinding(GPUVAddr ssbo_addr, u32 cbuf_index, | 531 | [[nodiscard]] Binding StorageBufferBinding(GPUVAddr ssbo_addr, u32 cbuf_index, |
| 525 | bool is_written) const; | 532 | bool is_written) const; |
| 526 | 533 | ||
diff --git a/src/video_core/renderer_opengl/gl_buffer_cache.cpp b/src/video_core/renderer_opengl/gl_buffer_cache.cpp index c419714d4..0cc546a3a 100644 --- a/src/video_core/renderer_opengl/gl_buffer_cache.cpp +++ b/src/video_core/renderer_opengl/gl_buffer_cache.cpp | |||
| @@ -232,6 +232,15 @@ void BufferCacheRuntime::BindVertexBuffer(u32 index, Buffer& buffer, u32 offset, | |||
| 232 | } | 232 | } |
| 233 | } | 233 | } |
| 234 | 234 | ||
| 235 | void BufferCacheRuntime::BindVertexBuffers(VideoCommon::HostBindings& bindings) { | ||
| 236 | for (u32 index = 0; index < bindings.buffers.size(); index++) { | ||
| 237 | BindVertexBuffer( | ||
| 238 | bindings.min_index + index, *reinterpret_cast<Buffer*>(bindings.buffers[index]), | ||
| 239 | static_cast<u32>(bindings.offsets[index]), static_cast<u32>(bindings.sizes[index]), | ||
| 240 | static_cast<u32>(bindings.strides[index])); | ||
| 241 | } | ||
| 242 | } | ||
| 243 | |||
| 235 | void BufferCacheRuntime::BindUniformBuffer(size_t stage, u32 binding_index, Buffer& buffer, | 244 | void BufferCacheRuntime::BindUniformBuffer(size_t stage, u32 binding_index, Buffer& buffer, |
| 236 | u32 offset, u32 size) { | 245 | u32 offset, u32 size) { |
| 237 | if (use_assembly_shaders) { | 246 | if (use_assembly_shaders) { |
| @@ -320,6 +329,15 @@ void BufferCacheRuntime::BindTransformFeedbackBuffer(u32 index, Buffer& buffer, | |||
| 320 | static_cast<GLintptr>(offset), static_cast<GLsizeiptr>(size)); | 329 | static_cast<GLintptr>(offset), static_cast<GLsizeiptr>(size)); |
| 321 | } | 330 | } |
| 322 | 331 | ||
| 332 | void BufferCacheRuntime::BindTransformFeedbackBuffers(VideoCommon::HostBindings& bindings) { | ||
| 333 | for (u32 index = 0; index < bindings.buffers.size(); index++) { | ||
| 334 | glBindBufferRange(GL_TRANSFORM_FEEDBACK_BUFFER, index, | ||
| 335 | reinterpret_cast<Buffer*>(bindings.buffers[index])->Handle(), | ||
| 336 | static_cast<GLintptr>(bindings.offsets[index]), | ||
| 337 | static_cast<GLsizeiptr>(bindings.sizes[index])); | ||
| 338 | } | ||
| 339 | } | ||
| 340 | |||
| 323 | void BufferCacheRuntime::BindTextureBuffer(Buffer& buffer, u32 offset, u32 size, | 341 | void BufferCacheRuntime::BindTextureBuffer(Buffer& buffer, u32 offset, u32 size, |
| 324 | PixelFormat format) { | 342 | PixelFormat format) { |
| 325 | *texture_handles++ = buffer.View(offset, size, format); | 343 | *texture_handles++ = buffer.View(offset, size, format); |
diff --git a/src/video_core/renderer_opengl/gl_buffer_cache.h b/src/video_core/renderer_opengl/gl_buffer_cache.h index a24991585..e4e000284 100644 --- a/src/video_core/renderer_opengl/gl_buffer_cache.h +++ b/src/video_core/renderer_opengl/gl_buffer_cache.h | |||
| @@ -7,7 +7,7 @@ | |||
| 7 | #include <span> | 7 | #include <span> |
| 8 | 8 | ||
| 9 | #include "common/common_types.h" | 9 | #include "common/common_types.h" |
| 10 | #include "video_core/buffer_cache/buffer_cache.h" | 10 | #include "video_core/buffer_cache/buffer_cache_base.h" |
| 11 | #include "video_core/buffer_cache/memory_tracker_base.h" | 11 | #include "video_core/buffer_cache/memory_tracker_base.h" |
| 12 | #include "video_core/rasterizer_interface.h" | 12 | #include "video_core/rasterizer_interface.h" |
| 13 | #include "video_core/renderer_opengl/gl_device.h" | 13 | #include "video_core/renderer_opengl/gl_device.h" |
| @@ -87,6 +87,7 @@ public: | |||
| 87 | void BindIndexBuffer(Buffer& buffer, u32 offset, u32 size); | 87 | void BindIndexBuffer(Buffer& buffer, u32 offset, u32 size); |
| 88 | 88 | ||
| 89 | void BindVertexBuffer(u32 index, Buffer& buffer, u32 offset, u32 size, u32 stride); | 89 | void BindVertexBuffer(u32 index, Buffer& buffer, u32 offset, u32 size, u32 stride); |
| 90 | void BindVertexBuffers(VideoCommon::HostBindings& bindings); | ||
| 90 | 91 | ||
| 91 | void BindUniformBuffer(size_t stage, u32 binding_index, Buffer& buffer, u32 offset, u32 size); | 92 | void BindUniformBuffer(size_t stage, u32 binding_index, Buffer& buffer, u32 offset, u32 size); |
| 92 | 93 | ||
| @@ -99,6 +100,7 @@ public: | |||
| 99 | bool is_written); | 100 | bool is_written); |
| 100 | 101 | ||
| 101 | void BindTransformFeedbackBuffer(u32 index, Buffer& buffer, u32 offset, u32 size); | 102 | void BindTransformFeedbackBuffer(u32 index, Buffer& buffer, u32 offset, u32 size); |
| 103 | void BindTransformFeedbackBuffers(VideoCommon::HostBindings& bindings); | ||
| 102 | 104 | ||
| 103 | void BindTextureBuffer(Buffer& buffer, u32 offset, u32 size, | 105 | void BindTextureBuffer(Buffer& buffer, u32 offset, u32 size, |
| 104 | VideoCore::Surface::PixelFormat format); | 106 | VideoCore::Surface::PixelFormat format); |
diff --git a/src/video_core/renderer_vulkan/vk_blit_screen.cpp b/src/video_core/renderer_vulkan/vk_blit_screen.cpp index aa8e54bdc..acb143fc7 100644 --- a/src/video_core/renderer_vulkan/vk_blit_screen.cpp +++ b/src/video_core/renderer_vulkan/vk_blit_screen.cpp | |||
| @@ -37,10 +37,6 @@ | |||
| 37 | #include "video_core/vulkan_common/vulkan_memory_allocator.h" | 37 | #include "video_core/vulkan_common/vulkan_memory_allocator.h" |
| 38 | #include "video_core/vulkan_common/vulkan_wrapper.h" | 38 | #include "video_core/vulkan_common/vulkan_wrapper.h" |
| 39 | 39 | ||
| 40 | #ifdef ANDROID | ||
| 41 | extern u32 GetAndroidScreenRotation(); | ||
| 42 | #endif | ||
| 43 | |||
| 44 | namespace Vulkan { | 40 | namespace Vulkan { |
| 45 | 41 | ||
| 46 | namespace { | 42 | namespace { |
| @@ -78,47 +74,6 @@ struct ScreenRectVertex { | |||
| 78 | } | 74 | } |
| 79 | }; | 75 | }; |
| 80 | 76 | ||
| 81 | #ifdef ANDROID | ||
| 82 | |||
| 83 | std::array<f32, 4 * 4> MakeOrthographicMatrix(f32 width, f32 height) { | ||
| 84 | constexpr u32 ROTATION_0 = 0; | ||
| 85 | constexpr u32 ROTATION_90 = 1; | ||
| 86 | constexpr u32 ROTATION_180 = 2; | ||
| 87 | constexpr u32 ROTATION_270 = 3; | ||
| 88 | |||
| 89 | // clang-format off | ||
| 90 | switch (GetAndroidScreenRotation()) { | ||
| 91 | case ROTATION_0: | ||
| 92 | // Desktop | ||
| 93 | return { 2.f / width, 0.f, 0.f, 0.f, | ||
| 94 | 0.f, 2.f / height, 0.f, 0.f, | ||
| 95 | 0.f, 0.f, 1.f, 0.f, | ||
| 96 | -1.f, -1.f, 0.f, 1.f}; | ||
| 97 | case ROTATION_180: | ||
| 98 | // Reverse desktop | ||
| 99 | return {-2.f / width, 0.f, 0.f, 0.f, | ||
| 100 | 0.f, -2.f / height, 0.f, 0.f, | ||
| 101 | 0.f, 0.f, 1.f, 0.f, | ||
| 102 | 1.f, 1.f, 0.f, 1.f}; | ||
| 103 | case ROTATION_270: | ||
| 104 | // Reverse landscape | ||
| 105 | return { 0.f, -2.f / width, 0.f, 0.f, | ||
| 106 | 2.f / height, 0.f, 0.f, 0.f, | ||
| 107 | 0.f, 0.f, 1.f, 0.f, | ||
| 108 | -1.f, 1.f, 0.f, 1.f}; | ||
| 109 | case ROTATION_90: | ||
| 110 | default: | ||
| 111 | // Landscape | ||
| 112 | return { 0.f, 2.f / width, 0.f, 0.f, | ||
| 113 | -2.f / height, 0.f, 0.f, 0.f, | ||
| 114 | 0.f, 0.f, 1.f, 0.f, | ||
| 115 | 1.f, -1.f, 0.f, 1.f}; | ||
| 116 | } | ||
| 117 | // clang-format on | ||
| 118 | } | ||
| 119 | |||
| 120 | #else | ||
| 121 | |||
| 122 | std::array<f32, 4 * 4> MakeOrthographicMatrix(f32 width, f32 height) { | 77 | std::array<f32, 4 * 4> MakeOrthographicMatrix(f32 width, f32 height) { |
| 123 | // clang-format off | 78 | // clang-format off |
| 124 | return { 2.f / width, 0.f, 0.f, 0.f, | 79 | return { 2.f / width, 0.f, 0.f, 0.f, |
| @@ -128,8 +83,6 @@ std::array<f32, 4 * 4> MakeOrthographicMatrix(f32 width, f32 height) { | |||
| 128 | // clang-format on | 83 | // clang-format on |
| 129 | } | 84 | } |
| 130 | 85 | ||
| 131 | #endif | ||
| 132 | |||
| 133 | u32 GetBytesPerPixel(const Tegra::FramebufferConfig& framebuffer) { | 86 | u32 GetBytesPerPixel(const Tegra::FramebufferConfig& framebuffer) { |
| 134 | using namespace VideoCore::Surface; | 87 | using namespace VideoCore::Surface; |
| 135 | return BytesPerBlock(PixelFormatFromGPUPixelFormat(framebuffer.pixel_format)); | 88 | return BytesPerBlock(PixelFormatFromGPUPixelFormat(framebuffer.pixel_format)); |
diff --git a/src/video_core/renderer_vulkan/vk_buffer_cache.cpp b/src/video_core/renderer_vulkan/vk_buffer_cache.cpp index daa128399..d72d99899 100644 --- a/src/video_core/renderer_vulkan/vk_buffer_cache.cpp +++ b/src/video_core/renderer_vulkan/vk_buffer_cache.cpp | |||
| @@ -7,7 +7,6 @@ | |||
| 7 | #include <span> | 7 | #include <span> |
| 8 | #include <vector> | 8 | #include <vector> |
| 9 | 9 | ||
| 10 | #include "video_core/buffer_cache/buffer_cache.h" | ||
| 11 | #include "video_core/renderer_vulkan/maxwell_to_vk.h" | 10 | #include "video_core/renderer_vulkan/maxwell_to_vk.h" |
| 12 | #include "video_core/renderer_vulkan/vk_buffer_cache.h" | 11 | #include "video_core/renderer_vulkan/vk_buffer_cache.h" |
| 13 | #include "video_core/renderer_vulkan/vk_scheduler.h" | 12 | #include "video_core/renderer_vulkan/vk_scheduler.h" |
| @@ -502,6 +501,40 @@ void BufferCacheRuntime::BindVertexBuffer(u32 index, VkBuffer buffer, u32 offset | |||
| 502 | } | 501 | } |
| 503 | } | 502 | } |
| 504 | 503 | ||
| 504 | void BufferCacheRuntime::BindVertexBuffers(VideoCommon::HostBindings& bindings) { | ||
| 505 | boost::container::small_vector<VkBuffer, 32> buffer_handles; | ||
| 506 | for (u32 index = 0; index < bindings.buffers.size(); index++) { | ||
| 507 | auto& buffer = *reinterpret_cast<Buffer*>(bindings.buffers[index]); | ||
| 508 | auto handle = buffer.Handle(); | ||
| 509 | if (handle == VK_NULL_HANDLE) { | ||
| 510 | bindings.offsets[index] = 0; | ||
| 511 | bindings.sizes[index] = VK_WHOLE_SIZE; | ||
| 512 | if (!device.HasNullDescriptor()) { | ||
| 513 | ReserveNullBuffer(); | ||
| 514 | handle = *null_buffer; | ||
| 515 | } | ||
| 516 | } | ||
| 517 | buffer_handles.push_back(handle); | ||
| 518 | } | ||
| 519 | if (device.IsExtExtendedDynamicStateSupported()) { | ||
| 520 | scheduler.Record([bindings = bindings, | ||
| 521 | buffer_handles = buffer_handles](vk::CommandBuffer cmdbuf) { | ||
| 522 | cmdbuf.BindVertexBuffers2EXT( | ||
| 523 | bindings.min_index, bindings.max_index - bindings.min_index, buffer_handles.data(), | ||
| 524 | reinterpret_cast<const VkDeviceSize*>(bindings.offsets.data()), | ||
| 525 | reinterpret_cast<const VkDeviceSize*>(bindings.sizes.data()), | ||
| 526 | reinterpret_cast<const VkDeviceSize*>(bindings.strides.data())); | ||
| 527 | }); | ||
| 528 | } else { | ||
| 529 | scheduler.Record([bindings = bindings, | ||
| 530 | buffer_handles = buffer_handles](vk::CommandBuffer cmdbuf) { | ||
| 531 | cmdbuf.BindVertexBuffers( | ||
| 532 | bindings.min_index, bindings.max_index - bindings.min_index, buffer_handles.data(), | ||
| 533 | reinterpret_cast<const VkDeviceSize*>(bindings.offsets.data())); | ||
| 534 | }); | ||
| 535 | } | ||
| 536 | } | ||
| 537 | |||
| 505 | void BufferCacheRuntime::BindTransformFeedbackBuffer(u32 index, VkBuffer buffer, u32 offset, | 538 | void BufferCacheRuntime::BindTransformFeedbackBuffer(u32 index, VkBuffer buffer, u32 offset, |
| 506 | u32 size) { | 539 | u32 size) { |
| 507 | if (!device.IsExtTransformFeedbackSupported()) { | 540 | if (!device.IsExtTransformFeedbackSupported()) { |
| @@ -523,6 +556,25 @@ void BufferCacheRuntime::BindTransformFeedbackBuffer(u32 index, VkBuffer buffer, | |||
| 523 | }); | 556 | }); |
| 524 | } | 557 | } |
| 525 | 558 | ||
| 559 | void BufferCacheRuntime::BindTransformFeedbackBuffers(VideoCommon::HostBindings& bindings) { | ||
| 560 | if (!device.IsExtTransformFeedbackSupported()) { | ||
| 561 | // Already logged in the rasterizer | ||
| 562 | return; | ||
| 563 | } | ||
| 564 | boost::container::small_vector<VkBuffer, 4> buffer_handles; | ||
| 565 | for (u32 index = 0; index < bindings.buffers.size(); index++) { | ||
| 566 | auto& buffer = *reinterpret_cast<Buffer*>(bindings.buffers[index]); | ||
| 567 | buffer_handles.push_back(buffer.Handle()); | ||
| 568 | } | ||
| 569 | scheduler.Record( | ||
| 570 | [bindings = bindings, buffer_handles = buffer_handles](vk::CommandBuffer cmdbuf) { | ||
| 571 | cmdbuf.BindTransformFeedbackBuffersEXT( | ||
| 572 | 0, static_cast<u32>(buffer_handles.size()), buffer_handles.data(), | ||
| 573 | reinterpret_cast<const VkDeviceSize*>(bindings.offsets.data()), | ||
| 574 | reinterpret_cast<const VkDeviceSize*>(bindings.sizes.data())); | ||
| 575 | }); | ||
| 576 | } | ||
| 577 | |||
| 526 | void BufferCacheRuntime::ReserveNullBuffer() { | 578 | void BufferCacheRuntime::ReserveNullBuffer() { |
| 527 | if (null_buffer) { | 579 | if (null_buffer) { |
| 528 | return; | 580 | return; |
diff --git a/src/video_core/renderer_vulkan/vk_buffer_cache.h b/src/video_core/renderer_vulkan/vk_buffer_cache.h index 92b4f7859..92d3e9f32 100644 --- a/src/video_core/renderer_vulkan/vk_buffer_cache.h +++ b/src/video_core/renderer_vulkan/vk_buffer_cache.h | |||
| @@ -18,6 +18,7 @@ namespace Vulkan { | |||
| 18 | class Device; | 18 | class Device; |
| 19 | class DescriptorPool; | 19 | class DescriptorPool; |
| 20 | class Scheduler; | 20 | class Scheduler; |
| 21 | struct HostVertexBinding; | ||
| 21 | 22 | ||
| 22 | class BufferCacheRuntime; | 23 | class BufferCacheRuntime; |
| 23 | 24 | ||
| @@ -96,8 +97,10 @@ public: | |||
| 96 | void BindQuadIndexBuffer(PrimitiveTopology topology, u32 first, u32 count); | 97 | void BindQuadIndexBuffer(PrimitiveTopology topology, u32 first, u32 count); |
| 97 | 98 | ||
| 98 | void BindVertexBuffer(u32 index, VkBuffer buffer, u32 offset, u32 size, u32 stride); | 99 | void BindVertexBuffer(u32 index, VkBuffer buffer, u32 offset, u32 size, u32 stride); |
| 100 | void BindVertexBuffers(VideoCommon::HostBindings& bindings); | ||
| 99 | 101 | ||
| 100 | void BindTransformFeedbackBuffer(u32 index, VkBuffer buffer, u32 offset, u32 size); | 102 | void BindTransformFeedbackBuffer(u32 index, VkBuffer buffer, u32 offset, u32 size); |
| 103 | void BindTransformFeedbackBuffers(VideoCommon::HostBindings& bindings); | ||
| 101 | 104 | ||
| 102 | std::span<u8> BindMappedUniformBuffer([[maybe_unused]] size_t stage, | 105 | std::span<u8> BindMappedUniformBuffer([[maybe_unused]] size_t stage, |
| 103 | [[maybe_unused]] u32 binding_index, u32 size) { | 106 | [[maybe_unused]] u32 binding_index, u32 size) { |
diff --git a/src/video_core/renderer_vulkan/vk_swapchain.cpp b/src/video_core/renderer_vulkan/vk_swapchain.cpp index afcf34fba..d3cddac69 100644 --- a/src/video_core/renderer_vulkan/vk_swapchain.cpp +++ b/src/video_core/renderer_vulkan/vk_swapchain.cpp | |||
| @@ -231,7 +231,12 @@ void Swapchain::CreateSwapchain(const VkSurfaceCapabilitiesKHR& capabilities, bo | |||
| 231 | .imageSharingMode = VK_SHARING_MODE_EXCLUSIVE, | 231 | .imageSharingMode = VK_SHARING_MODE_EXCLUSIVE, |
| 232 | .queueFamilyIndexCount = 0, | 232 | .queueFamilyIndexCount = 0, |
| 233 | .pQueueFamilyIndices = nullptr, | 233 | .pQueueFamilyIndices = nullptr, |
| 234 | #ifdef ANDROID | ||
| 235 | // On Android, do not allow surface rotation to deviate from the frontend. | ||
| 236 | .preTransform = VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR, | ||
| 237 | #else | ||
| 234 | .preTransform = capabilities.currentTransform, | 238 | .preTransform = capabilities.currentTransform, |
| 239 | #endif | ||
| 235 | .compositeAlpha = alpha_flags, | 240 | .compositeAlpha = alpha_flags, |
| 236 | .presentMode = present_mode, | 241 | .presentMode = present_mode, |
| 237 | .clipped = VK_FALSE, | 242 | .clipped = VK_FALSE, |