mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-19 12:56:06 +00:00
Hide host flags on covered host-visible memory types in the bridge
On the Pocket FIT's Qualcomm driver every DXVK title crashed right after
creating its device: DXVK 2.4 builds its per-property memory type table
from the first matching type and skips later device-local ones, so for
HOST_VISIBLE|HOST_COHERENT it chose type 4, which no buffer may use
(buffers report 0x41), and its first upload allocation failed
("DxvkMemoryAllocator: Memory allocation failed ... Mem types: 0,6"),
followed by a null read in d3d11.dll. Newer DXVK fixed the table but
requires maintenance5/6, which this driver lacks.
0014-trim-covered-host-memory-types.patch reports host flags only on
host-visible types that no other host-visible type of the same heap
strictly contains. No buffer or image on this driver uses the trimmed
types (optimal images 0x1, linear images and buffers 0x41).
This commit is contained in:
1 parent
26a9a8ecd6
commit
e7fad94b70
2 files changed
+90
-1
No files matched your search
@@ -4,7 +4,7 @@ The Linux backend uses the installed Qualcomm Vulkan HAL through a pinned libhyb
|
||||
|
||||
## Bridge patch for Android 14 loaders
|
||||
|
||||
The bridge creates the Vulkan instance through Android's `libvulkan.so` and then checks that this instance dispatches to the same HAL it loaded itself. Upstream compares only `vkGetPhysicalDeviceProperties`. Android 14's loader wraps that query (seen on an AYANEO Pocket FIT, Adreno 750, Qualcomm 0.762.24, SDK 34): it resolved into `libvulkan.so` while `vkGetPhysicalDeviceFeatures` resolved to the same `vulkan.adreno.so` entry from both sides, so every session failed with `Android instance and configured HAL use different dispatch implementations` and `vkCreateInstance` -9. `hybris-patches/0012-android-loader-wrapped-queries.patch` accepts the instance when any of five core physical-device queries resolves to the HAL's own entry; another driver matches none. `0013-calibrated-timestamps-khr-alias.patch` answers `vkGetPhysicalDeviceCalibrateableTimeDomainsKHR` and `vkGetCalibratedTimestampsKHR` with the HAL's EXT entries when it has only those (same signatures and time-domain values). The same Pocket FIT driver offers only `VK_EXT_calibrated_timestamps`; Zink called the KHR name, the desktop loader found no ICD entry and aborted (`ICD associated with VkPhysicalDevice does not support GetPhysicalDeviceCalibrateableTimeDomainsKHR`), which took down every OpenGL program, including Steam's update window and the browser's `glxinfo` check. The bridge is rebuilt with wallentx's builder (`tools/hybris` at `4ed93fb9`, patches 0001-0011) plus these patches on DroidDeck-Components.
|
||||
The bridge creates the Vulkan instance through Android's `libvulkan.so` and then checks that this instance dispatches to the same HAL it loaded itself. Upstream compares only `vkGetPhysicalDeviceProperties`. Android 14's loader wraps that query (seen on an AYANEO Pocket FIT, Adreno 750, Qualcomm 0.762.24, SDK 34): it resolved into `libvulkan.so` while `vkGetPhysicalDeviceFeatures` resolved to the same `vulkan.adreno.so` entry from both sides, so every session failed with `Android instance and configured HAL use different dispatch implementations` and `vkCreateInstance` -9. `hybris-patches/0012-android-loader-wrapped-queries.patch` accepts the instance when any of five core physical-device queries resolves to the HAL's own entry; another driver matches none. `0013-calibrated-timestamps-khr-alias.patch` answers `vkGetPhysicalDeviceCalibrateableTimeDomainsKHR` and `vkGetCalibratedTimestampsKHR` with the HAL's EXT entries when it has only those (same signatures and time-domain values). The same Pocket FIT driver offers only `VK_EXT_calibrated_timestamps`; Zink called the KHR name, the desktop loader found no ICD entry and aborted (`ICD associated with VkPhysicalDevice does not support GetPhysicalDeviceCalibrateableTimeDomainsKHR`), which took down every OpenGL program, including Steam's update window and the browser's `glxinfo` check. `0014-trim-covered-host-memory-types.patch` stops reporting host-visible flags on memory types that another host-visible type of the same heap strictly contains (Pocket FIT: types 3-5 next to cached coherent type 6). No buffer or image there may use types 3-5 (buffers report 0x41, optimal images 0x1, linear 0x41), but DXVK 2.4 picks the first type with the requested flags and skipped type 6, so every DXVK title failed its first upload allocation (`DxvkMemoryAllocator: Memory allocation failed ... Mem types: 0,6`, then a null read in d3d11.dll). Indices and heaps are unchanged; `HYBRIS_VULKAN_KEEP_MEMORY_TYPES=1` reports the driver's flags. The bridge is rebuilt with wallentx's builder (`tools/hybris` at `4ed93fb9`, patches 0001-0011) plus these patches on DroidDeck-Components.
|
||||
|
||||
## Imported AdrenoTools Qualcomm packages
|
||||
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
diff --git a/hybris/vulkan/icd/instance.c b/hybris/vulkan/icd/instance.c
|
||||
index 7f30014..b9db254 100644
|
||||
--- a/hybris/vulkan/icd/instance.c
|
||||
+++ b/hybris/vulkan/icd/instance.c
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
+#include <sys/auxv.h>
|
||||
|
||||
/* Driver handles keep their loader-owned dispatch header untouched. */
|
||||
struct physical_state {
|
||||
@@ -285,6 +286,63 @@ static VkResult VKAPI_CALL create_device(VkPhysicalDevice physical,
|
||||
return hybris_icd_create_device(create, resolver, state->generation, physical, info, allocator, device);
|
||||
}
|
||||
|
||||
+/* DXVK before its 2025 memory rework takes the first memory type with the requested property
|
||||
+ * flags and skips later device-local ones. Qualcomm HALs list DEVICE_LOCAL|HOST_VISIBLE types
|
||||
+ * that no buffer or image may use ahead of the cached coherent type that buffers do use, so DXVK
|
||||
+ * found no memory for its upload buffers. Report host flags only on host-visible types that no
|
||||
+ * other host-visible type of the same heap strictly contains; indices and heaps are unchanged. */
|
||||
+static void trim_host_memory_types(VkPhysicalDeviceMemoryProperties *memory)
|
||||
+{
|
||||
+ const char *keep = getauxval(AT_SECURE) ? NULL : getenv("HYBRIS_VULKAN_KEEP_MEMORY_TYPES");
|
||||
+ if (keep && !strcmp(keep, "1")) return;
|
||||
+ const VkMemoryPropertyFlags host = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
|
||||
+ VK_MEMORY_PROPERTY_HOST_COHERENT_BIT | VK_MEMORY_PROPERTY_HOST_CACHED_BIT;
|
||||
+ VkMemoryPropertyFlags original[VK_MAX_MEMORY_TYPES];
|
||||
+ uint32_t count = memory->memoryTypeCount < VK_MAX_MEMORY_TYPES ? memory->memoryTypeCount : VK_MAX_MEMORY_TYPES;
|
||||
+ for (uint32_t i = 0; i < count; ++i) original[i] = memory->memoryTypes[i].propertyFlags;
|
||||
+ for (uint32_t i = 0; i < count; ++i) {
|
||||
+ if (!(original[i] & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT)) continue;
|
||||
+ for (uint32_t j = 0; j < count; ++j) {
|
||||
+ if (j == i || !(original[j] & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT) ||
|
||||
+ memory->memoryTypes[j].heapIndex != memory->memoryTypes[i].heapIndex) continue;
|
||||
+ if ((original[i] & original[j]) == original[i] && original[j] != original[i]) {
|
||||
+ memory->memoryTypes[i].propertyFlags = original[i] & ~host;
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static void VKAPI_CALL memory_properties(VkPhysicalDevice physical, VkPhysicalDeviceMemoryProperties *out)
|
||||
+{
|
||||
+ struct hybris_icd_physical context;
|
||||
+ if (!hybris_icd_lookup_physical(physical, &context)) return;
|
||||
+ PFN_vkGetPhysicalDeviceMemoryProperties query = (PFN_vkGetPhysicalDeviceMemoryProperties)
|
||||
+ context.resolver(context.instance, "vkGetPhysicalDeviceMemoryProperties");
|
||||
+ query(physical, out);
|
||||
+ trim_host_memory_types(out);
|
||||
+}
|
||||
+
|
||||
+static void memory_properties2(VkPhysicalDevice physical, VkPhysicalDeviceMemoryProperties2 *out, const char *name)
|
||||
+{
|
||||
+ struct hybris_icd_physical context;
|
||||
+ if (!hybris_icd_lookup_physical(physical, &context)) return;
|
||||
+ PFN_vkGetPhysicalDeviceMemoryProperties2 query = (PFN_vkGetPhysicalDeviceMemoryProperties2)
|
||||
+ context.resolver(context.instance, name);
|
||||
+ query(physical, out);
|
||||
+ trim_host_memory_types(&out->memoryProperties);
|
||||
+}
|
||||
+
|
||||
+static void VKAPI_CALL memory_properties2_core(VkPhysicalDevice physical, VkPhysicalDeviceMemoryProperties2 *out)
|
||||
+{
|
||||
+ memory_properties2(physical, out, "vkGetPhysicalDeviceMemoryProperties2");
|
||||
+}
|
||||
+
|
||||
+static void VKAPI_CALL memory_properties2_khr(VkPhysicalDevice physical, VkPhysicalDeviceMemoryProperties2 *out)
|
||||
+{
|
||||
+ memory_properties2(physical, out, "vkGetPhysicalDeviceMemoryProperties2KHR");
|
||||
+}
|
||||
+
|
||||
PFN_vkVoidFunction hybris_icd_instance_proc(VkInstance instance, const char *name)
|
||||
{
|
||||
pthread_mutex_lock(&instance_guard);
|
||||
@@ -310,6 +368,12 @@ PFN_vkVoidFunction hybris_icd_instance_proc(VkInstance instance, const char *nam
|
||||
PFN_vkVoidFunction image = backend ? hybris_icd_swapchain_image_proc(name) : NULL;
|
||||
if (image) return image;
|
||||
/* Preserve the HAL's command scope and extension gating. */
|
||||
+ if (backend && !strcmp(name, "vkGetPhysicalDeviceMemoryProperties"))
|
||||
+ return (PFN_vkVoidFunction)memory_properties;
|
||||
+ if (backend && !strcmp(name, "vkGetPhysicalDeviceMemoryProperties2"))
|
||||
+ return (PFN_vkVoidFunction)memory_properties2_core;
|
||||
+ if (backend && !strcmp(name, "vkGetPhysicalDeviceMemoryProperties2KHR"))
|
||||
+ return (PFN_vkVoidFunction)memory_properties2_khr;
|
||||
if (backend && !strcmp(name, "vkDestroyInstance"))
|
||||
return (PFN_vkVoidFunction)destroy_instance;
|
||||
if (backend && !strcmp(name, "vkEnumeratePhysicalDevices"))
|
||||
Reference in new issue
Block a user