summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLiam <byteslice@airmail.cc>2023-01-02 00:34:38 +0100
committerbunnei <bunneidev@gmail.com>2023-06-03 09:05:28 +0200
commitf7a3f1ddf49a2471fd92ee92faea61880285b2d5 (patch)
treee32ec870444e890b124a819b834a705620e123c1
parentdevice_memory: Use smaller virtual reservation size for compatibility with 39-bit paging (diff)
downloadyuzu-f7a3f1ddf49a2471fd92ee92faea61880285b2d5.tar
yuzu-f7a3f1ddf49a2471fd92ee92faea61880285b2d5.tar.gz
yuzu-f7a3f1ddf49a2471fd92ee92faea61880285b2d5.tar.bz2
yuzu-f7a3f1ddf49a2471fd92ee92faea61880285b2d5.tar.lz
yuzu-f7a3f1ddf49a2471fd92ee92faea61880285b2d5.tar.xz
yuzu-f7a3f1ddf49a2471fd92ee92faea61880285b2d5.tar.zst
yuzu-f7a3f1ddf49a2471fd92ee92faea61880285b2d5.zip
Diffstat (limited to '')
-rw-r--r--.gitmodules3
-rw-r--r--externals/CMakeLists.txt4
m---------externals/libadrenotools0
-rw-r--r--src/video_core/CMakeLists.txt4
-rw-r--r--src/video_core/vulkan_common/vulkan_device.cpp30
5 files changed, 41 insertions, 0 deletions
diff --git a/.gitmodules b/.gitmodules
index 75c7b5fe0..ad7a9b970 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -49,3 +49,6 @@
[submodule "cpp-jwt"]
path = externals/cpp-jwt
url = https://github.com/arun11299/cpp-jwt.git
+[submodule "externals/libadrenotools"]
+ path = externals/libadrenotools
+ url = https://github.com/bylaws/libadrenotools
diff --git a/externals/CMakeLists.txt b/externals/CMakeLists.txt
index d78d10147..2bd7b457a 100644
--- a/externals/CMakeLists.txt
+++ b/externals/CMakeLists.txt
@@ -147,3 +147,7 @@ endif()
add_library(stb stb/stb_dxt.cpp)
target_include_directories(stb PUBLIC ./stb)
+
+if (ANDROID)
+ add_subdirectory(libadrenotools)
+endif()
diff --git a/externals/libadrenotools b/externals/libadrenotools
new file mode 160000
+Subproject a6c0947df6b152b350342f5191b3082768e15e3
diff --git a/src/video_core/CMakeLists.txt b/src/video_core/CMakeLists.txt
index 027259f57..05aa5cfe2 100644
--- a/src/video_core/CMakeLists.txt
+++ b/src/video_core/CMakeLists.txt
@@ -345,3 +345,7 @@ endif()
if (YUZU_ENABLE_LTO)
set_property(TARGET video_core PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
endif()
+
+if (ANDROID)
+ target_link_libraries(video_core PRIVATE adrenotools)
+endif()
diff --git a/src/video_core/vulkan_common/vulkan_device.cpp b/src/video_core/vulkan_common/vulkan_device.cpp
index 9ab8e46a1..8847c6aa3 100644
--- a/src/video_core/vulkan_common/vulkan_device.cpp
+++ b/src/video_core/vulkan_common/vulkan_device.cpp
@@ -18,6 +18,10 @@
#include "video_core/vulkan_common/vulkan_device.h"
#include "video_core/vulkan_common/vulkan_wrapper.h"
+#ifdef ANDROID
+#include <adrenotools/bcenabler.h>
+#endif
+
namespace Vulkan {
using namespace Common::Literals;
namespace {
@@ -356,6 +360,32 @@ Device::Device(VkInstance instance_, vk::PhysicalDevice physical_, VkSurfaceKHR
CollectPhysicalMemoryInfo();
CollectToolingInfo();
+#ifdef ANDROID
+ if (is_adreno) {
+ LOG_WARNING(Render_Vulkan, "Adreno drivers have broken VK_EXT_extended_dynamic_state");
+ extensions.extended_dynamic_state = false;
+ loaded_extensions.erase(VK_EXT_EXTENDED_DYNAMIC_STATE_EXTENSION_NAME);
+
+ // Patch the driver to enable BCn textures.
+ const auto major = (properties.properties.driverVersion >> 24) << 2;
+ const auto minor = (properties.properties.driverVersion >> 12) & 0xFFFU;
+ const auto vendor = properties.properties.vendorID;
+ const auto patch_status = adrenotools_get_bcn_type(major, minor, vendor);
+
+ if (patch_status == ADRENOTOOLS_BCN_PATCH) {
+ LOG_INFO(Render_Vulkan, "Patching Adreno driver to support BCn texture formats");
+ if (!adrenotools_patch_bcn(
+ reinterpret_cast<void*>(dld.vkGetPhysicalDeviceFormatProperties))) {
+ LOG_ERROR(Render_Vulkan, "Patch failed! Driver code may now crash");
+ }
+ } else if (patch_status == ADRENOTOOLS_BCN_BLOB) {
+ LOG_INFO(Render_Vulkan, "Adreno driver supports BCn textures without patches");
+ } else {
+ LOG_WARNING(Render_Vulkan, "Adreno driver can't be patched to enable BCn textures");
+ }
+ }
+#endif // ANDROID
+
if (is_nvidia) {
const u32 nv_major_version = (properties.properties.driverVersion >> 22) & 0x3ff;
const auto arch = GetNvidiaArchitecture(physical, supported_extensions);