From f457c33f8118401b04e3e963e91416c4bdfd8f32 Mon Sep 17 00:00:00 2001 From: The412Banner <205237651+The412Banner@users.noreply.github.com> Date: Sat, 28 Nov 2026 23:00:31 +0000 Subject: [PATCH] fix(mali-compat): report at most 8 descriptor sets on ARM's driver --- docs/development/mali-venus.md | 6 ++++++ tools/tests/mali_compat_layer_test.c | 8 ++++++++ tools/venus/layer/layer.c | 12 +++++++++--- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/docs/development/mali-venus.md b/docs/development/mali-venus.md index 5cdc4ab39f..7a73af714d 100644 --- a/docs/development/mali-venus.md +++ b/docs/development/mali-venus.md @@ -128,6 +128,12 @@ What it does, per feature: - Pipelines and `vkCmdSetColorBlendEquationEXT` both. - Why alpha: output 0's color is the paint, its alpha is the usual coverage. Per-channel coverage collapses to one value; blending stays plain alpha blending, not tinted by the paint. +Limits the layer lowers: +- `maxBoundDescriptorSets`: at most 8 on ARM's driver (vendor 0x13B5), whatever the driver reports. + - The Mali-G715 driver on a Pixel 9 Pro XL accepts a vkd3d-proton pipeline layout of 10 sets and then crashes the render server in `vkCreatePipelineLayout` (`hal::halp::resource_table_layout::init`, fault address `0x900000018`). + - The function keeps one 32-bit value per set in an 8-entry stack array. Entries 8 and 9 overwrite the first set layout pointer with `0x0000000900000008`, which `init` then reads. + - vkd3d-proton checks `maxBoundDescriptorSets` before it creates a layout (`vkd3d_create_pipeline_layout`), so with 8 it fails that root signature with an error instead. + The SPIR-V version the driver gets: - The phone's own driver compiles the guest's SPIR-V, and its compiler is old: on the MT6897 Mali-G615 (r44p1, "Vulkan 1.3.247") it dies with a null read in `cmpbe_v2_compile_multiple_shaders` diff --git a/tools/tests/mali_compat_layer_test.c b/tools/tests/mali_compat_layer_test.c index 9b29e5c734..2f4d1cf917 100644 --- a/tools/tests/mali_compat_layer_test.c +++ b/tools/tests/mali_compat_layer_test.c @@ -235,6 +235,8 @@ static void VKAPI_CALL mock_properties(VkPhysicalDevice physical, VkPhysicalDevi memset(properties, 0, sizeof(*properties)); strcpy(properties->deviceName, "mock"); properties->limits.maxFragmentDualSrcAttachments = physical == (VkPhysicalDevice)&mock_capable; + properties->vendorID = physical == (VkPhysicalDevice)&mock_capable ? 0x5143u : 0x13B5u; + properties->limits.maxBoundDescriptorSets = 15; } static void VKAPI_CALL mock_properties2(VkPhysicalDevice physical, VkPhysicalDeviceProperties2 *properties) @@ -431,6 +433,11 @@ static void test_lacking_device(void) ((PFN_vkGetPhysicalDeviceProperties)layer_gipa((VkInstance)&mock_instance, "vkGetPhysicalDeviceProperties"))( physical, &properties); assert(properties.limits.maxFragmentDualSrcAttachments == 1); + assert(properties.limits.maxBoundDescriptorSets == 8); + VkPhysicalDeviceProperties2 properties2 = {.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2}; + ((PFN_vkGetPhysicalDeviceProperties2)layer_gipa((VkInstance)&mock_instance, "vkGetPhysicalDeviceProperties2"))( + physical, &properties2); + assert(properties2.properties.limits.maxBoundDescriptorSets == 8); VkDevice device; VkPhysicalDeviceFeatures enabled = {.dualSrcBlend = VK_TRUE}; @@ -492,6 +499,7 @@ static void test_capable_device(void) ((PFN_vkGetPhysicalDeviceProperties)layer_gipa((VkInstance)&mock_instance, "vkGetPhysicalDeviceProperties"))( physical, &properties); assert(properties.limits.maxFragmentDualSrcAttachments == 1); + assert(properties.limits.maxBoundDescriptorSets == 15); VkDevice device; VkPhysicalDeviceFeatures enabled = {.dualSrcBlend = VK_TRUE}; diff --git a/tools/venus/layer/layer.c b/tools/venus/layer/layer.c index 9aeb0bcf0e..5fbaee4992 100644 --- a/tools/venus/layer/layer.c +++ b/tools/venus/layer/layer.c @@ -329,8 +329,14 @@ static uint32_t take_features(VkPhysicalDeviceFeatures *features, uint32_t gaps) return requested; } -static void report_limits(VkPhysicalDeviceLimits *limits, uint32_t gaps) +#define ARM_VENDOR_ID 0x13B5u +#define ARM_PIPELINE_LAYOUT_MAX_SETS 8u + +static void report_limits(VkPhysicalDeviceProperties *properties, uint32_t gaps) { + VkPhysicalDeviceLimits *limits = &properties->limits; + if (properties->vendorID == ARM_VENDOR_ID && limits->maxBoundDescriptorSets > ARM_PIPELINE_LAYOUT_MAX_SETS) + limits->maxBoundDescriptorSets = ARM_PIPELINE_LAYOUT_MAX_SETS; if (gaps & GAP_MULTI_VIEWPORT) limits->maxViewports = 16; if ((gaps & GAP_MULTI_DRAW) && limits->maxDrawIndirectCount < (1u << 30)) @@ -386,7 +392,7 @@ static VKAPI_ATTR void VKAPI_CALL GetPhysicalDeviceProperties(VkPhysicalDevice p { struct instance *inst = instance_from_handle(physical_device); inst->GetPhysicalDeviceProperties(physical_device, properties); - report_limits(&properties->limits, physical_device_gaps(inst, physical_device)); + report_limits(properties, physical_device_gaps(inst, physical_device)); } static VKAPI_ATTR void VKAPI_CALL GetPhysicalDeviceProperties2(VkPhysicalDevice physical_device, @@ -394,7 +400,7 @@ static VKAPI_ATTR void VKAPI_CALL GetPhysicalDeviceProperties2(VkPhysicalDevice { struct instance *inst = instance_from_handle(physical_device); inst->GetPhysicalDeviceProperties2(physical_device, properties); - report_limits(&properties->properties.limits, physical_device_gaps(inst, physical_device)); + report_limits(&properties->properties, physical_device_gaps(inst, physical_device)); if (tracing()) layer_log("trace: vkGetPhysicalDeviceProperties2: %s, Vulkan %u.%u.%u, type %d", properties->properties.deviceName, VK_API_VERSION_MAJOR(properties->properties.apiVersion), VK_API_VERSION_MINOR(properties->properties.apiVersion),