From fab23c9aeb5b1b8cbdaedd16f5155b5b5454cedb Mon Sep 17 00:00:00 2001 From: uddish-code <80019910+uddish-code@users.noreply.github.com> Date: Wed, 18 Nov 2026 16:20:33 +0000 Subject: [PATCH 1/2] Fix Mali-G615 r44p1 viewport index reporting Issue: #72 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- server/server_driverid.c | 25 +++++++++++++++++++++++++ server/server_emu.c | 5 +++++ server/server_promote.c | 8 ++++++++ server/vkb_server.h | 1 + 4 files changed, 39 insertions(+) diff --git a/server/server_driverid.c b/server/server_driverid.c index f121223..98c7c6e 100644 --- a/server/server_driverid.c +++ b/server/server_driverid.c @@ -112,6 +112,31 @@ int vkb_arm_driver(const vkb_dispatch *dt, VkPhysicalDevice pd, uint32_t inst_ap return vkb_driver_is_arm(&p, vkb_driver_id(dt, pd, inst_api)); } +/* Mali-G615 r44p1 ignores gl_ViewportIndex written from a vertex shader (MaliBridge issue #72). + * Keep this narrow: it must be Arm's proprietary driver, not a similarly named Mesa/PanVK device, + * and the r44p1 build must be identified from driverInfo or the encoded driverVersion. */ +int vkb_mali_g615_r44p1(const vkb_dispatch *dt, VkPhysicalDevice pd, uint32_t inst_api) +{ + VkPhysicalDeviceProperties p; + if (!dt || !dt->vkGetPhysicalDeviceProperties) return 0; + dt->vkGetPhysicalDeviceProperties(pd, &p); + if (!strstr(p.deviceName, "Mali-G615")) return 0; + + uint32_t driver_id = vkb_driver_id(dt, pd, inst_api); + if (!vkb_driver_is_arm(&p, driver_id)) return 0; + + VkPhysicalDeviceDriverProperties dp = {VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DRIVER_PROPERTIES}; + if (dt->vkGetPhysicalDeviceProperties2 && inst_api >= VK_API_VERSION_1_1) { + VkPhysicalDeviceProperties2 p2 = {VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2, &dp}; + dt->vkGetPhysicalDeviceProperties2(pd, &p2); + } + if (strstr(dp.driverInfo, "r44p1")) return 1; + + uint32_t r = p.driverVersion >> 22; + uint32_t patch = (p.driverVersion >> 12) & 0x3ffu; + return r == 44 && patch == 1; +} + const char *vkb_driver_id_name(uint32_t id) { switch (id) { diff --git a/server/server_emu.c b/server/server_emu.c index 3cdfcea..a3d6bc3 100644 --- a/server/server_emu.c +++ b/server/server_emu.c @@ -810,6 +810,11 @@ uint32_t vkb_emu_detect(const vkb_dispatch *idt, VkPhysicalDevice pd, uint32_t * uint32_t emu = 0; VkPhysicalDeviceProperties props; idt->vkGetPhysicalDeviceProperties(pd, &props); + if (vkb_mali_g615_r44p1(idt, pd, VK_API_VERSION_1_3)) { + VKB_ONCE(VKB_LOG_INFO, + "multi-viewport: Mali-G615 r44p1 ignores a vertex shader's ViewportIndex; reporting multiViewport off"); + f.multiViewport = VK_FALSE; + } /* vkd3d-proton (every D3D12 game) wants vertexAttributeInstanceRateZeroDivisor too. Mali-G925 on * Android 16 has the KHR extension without it (and without supportsNonZeroFirstInstance): such a * divisor is taken as missing and emulated whole - the emulation does both, at any firstInstance. */ diff --git a/server/server_promote.c b/server/server_promote.c index f1aa53e..4c892dc 100644 --- a/server/server_promote.c +++ b/server/server_promote.c @@ -613,6 +613,7 @@ typedef struct promo_gpu { uint32_t drv_api; /* the driver's (or VKBRIDGE_FAKE_API's) */ uint32_t offered; /* the version the app sees: drv_api when nothing is promoted */ uint32_t spv_max; /* the SPIR-V version the driver takes */ + int viewport_index_broken; /* Mali-G615 r44p1 ignores VS BuiltIn ViewportIndex */ int shuffle; /* subgroup shuffles in the driver: dynamic-id broadcasts lowered to them */ uint32_t lanes; /* without shuffles: the largest subgroup, each dynamic-id broadcast a chain over its lanes */ int active; /* translation wrappers on (VKBRIDGE_PROMOTE_API not 0, driver below 1.3) */ @@ -682,6 +683,9 @@ static void fill_core_features(const translate *x, const promo_gpu *g, VkBaseOut if (r->ext_off == NONE) v = exts_has(x->exts, feat_structs[r->ef].ext); else if (x->slots[r->ef].p) v = *(const VkBool32 *)((const uint8_t *)x->slots[r->ef].p + r->ext_off); if (r->ef == EF_PRIVATE) v = VK_TRUE; /* the client's own (descriptor.c) */ + if (g && g->viewport_index_broken && r->ef == EF_VPLAYER && + r->core_off == offsetof(VkPhysicalDeviceVulkan12Features, shaderOutputViewportIndex)) + v = VK_FALSE; *(VkBool32 *)((uint8_t *)c + r->core_off) = v; } /* A shuffle where the driver has them, else a chain of constant-lane broadcasts (spirv_downgrade.h). */ @@ -753,6 +757,7 @@ static void record_plain(const vkb_dispatch *d, VkPhysicalDevice pd) g.drv_api = driver_api(p.apiVersion); g.offered = g.drv_api; snprintf(g.name, sizeof(g.name), "%s", p.deviceName); + g.viewport_index_broken = vkb_mali_g615_r44p1(d, pd, p.apiVersion); g.push = p.limits.maxPushConstantsSize; g.int64 = f.shaderInt64 != 0; pthread_mutex_lock(&gpus_lock); @@ -771,6 +776,8 @@ void vkb_promote_decide(const vkb_dispatch *d, VkPhysicalDevice pd) memset(&g, 0, sizeof(g)); VkPhysicalDeviceIDProperties id = {VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ID_PROPERTIES}; VkPhysicalDeviceSubgroupProperties sg = {VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SUBGROUP_PROPERTIES, &id}; + VkPhysicalDeviceDriverProperties dp = {VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DRIVER_PROPERTIES}; + id.pNext = &dp; VkPhysicalDeviceProperties2 p2 = {VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2, &sg}; d->vkGetPhysicalDeviceProperties2(pd, &p2); memcpy(g.uuid, id.deviceUUID, VK_UUID_SIZE); @@ -778,6 +785,7 @@ void vkb_promote_decide(const vkb_dispatch *d, VkPhysicalDevice pd) g.drv_api = driver_api(p2.properties.apiVersion); g.offered = g.drv_api; snprintf(g.name, sizeof(g.name), "%s", p2.properties.deviceName); + g.viewport_index_broken = vkb_mali_g615_r44p1(d, pd, p2.properties.apiVersion); g.push = p2.properties.limits.maxPushConstantsSize; VkPhysicalDeviceFeatures2 base = {VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2}; d->vkGetPhysicalDeviceFeatures2(pd, &base); diff --git a/server/vkb_server.h b/server/vkb_server.h index 4783882..fbc8812 100644 --- a/server/vkb_server.h +++ b/server/vkb_server.h @@ -593,6 +593,7 @@ uint32_t vkb_steam_api_cap(const vkb_srv_table *t, VkPhysicalDevice pd); uint32_t vkb_driver_id(const vkb_dispatch *dt, VkPhysicalDevice pd, uint32_t inst_api); int vkb_driver_is_arm(const VkPhysicalDeviceProperties *p, uint32_t driver_id); int vkb_arm_driver(const vkb_dispatch *dt, VkPhysicalDevice pd, uint32_t inst_api); +int vkb_mali_g615_r44p1(const vkb_dispatch *dt, VkPhysicalDevice pd, uint32_t inst_api); /* issue #72 */ const char *vkb_driver_id_name(uint32_t id); void vkb_driver_log(const vkb_dispatch *dt, VkPhysicalDevice pd, uint32_t inst_api); /* the self-test's line */ PFN_vkGetInstanceProcAddr vkb_driverid_imitate_gipa(PFN_vkGetInstanceProcAddr gipa); /* VKBRIDGE_FAKE_DRIVER (host tests) */ From 7df45f3ebc78e00ef463481e5dcfef0bec47c864 Mon Sep 17 00:00:00 2001 From: uddish-code <80019910+uddish-code@users.noreply.github.com> Date: Wed, 18 Nov 2026 16:40:30 +0000 Subject: [PATCH 2/2] Fix Mali-G615 viewport feature reporting Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- common/vkb_caps.c | 1 + common/vkb_proto.h | 3 ++- server/server_driverid.c | 7 +++++-- server/server_emu.c | 4 +++- server/server_promote.c | 15 ++++++++++++++- 5 files changed, 25 insertions(+), 5 deletions(-) diff --git a/common/vkb_caps.c b/common/vkb_caps.c index 4f3d40d..1a7f329 100644 --- a/common/vkb_caps.c +++ b/common/vkb_caps.c @@ -335,6 +335,7 @@ void vkb_caps_patch_features(const vkb_pd_caps *caps, VkPhysicalDeviceFeatures * set_feature(caps, VKB_EMU_DUAL_SRC, &f->dualSrcBlend); set_feature(caps, VKB_EMU_FILL_MODE, &f->fillModeNonSolid); set_feature(caps, VKB_EMU_MULTI_VIEWPORT, &f->multiViewport); + if (caps->missing & VKB_CAP_HIDE_MULTI_VIEWPORT) f->multiViewport = VK_FALSE; set_feature(caps, VKB_EMU_MULTI_DRAW, &f->multiDrawIndirect); } diff --git a/common/vkb_proto.h b/common/vkb_proto.h index 17ed8d5..f62c552 100644 --- a/common/vkb_proto.h +++ b/common/vkb_proto.h @@ -74,6 +74,7 @@ static inline VkFormat vkb_bgr10_rgba(VkFormat f) * (Mali r18-r26, Vulkan 1.1: Zink requires it; server_emu_imageless.c) */ #define VKB_EMU_MEM_BUDGET (1u << 26) /* VK_EXT_memory_budget answered by the server where the driver has none (every Mali): * DXVK and vkd3d-proton clients only (server_memory.c memb_fill) */ +#define VKB_CAP_HIDE_MULTI_VIEWPORT (1u << 27) /* report multiViewport and shaderOutputViewportIndex unavailable, even when emulated */ #define VKB_EMU_ROBUST2_ACCESS (1u << 19) /* robustBufferAccess2/robustImageAccess2 reported where the driver's robustness2 * has nullDescriptor only (Mali-G715 r54p3); core robustness on instead (DXVK 3) */ @@ -87,7 +88,7 @@ typedef struct vkb_server_pd_info { uint32_t emu; /* VKB_EMU_* the server will perform */ uint32_t emu_available; /* VKB_EMU_* the server could perform */ uint32_t real_api_version; - uint32_t missing; /* VKB_EMU_* features the GPU lacks (emulated or not) */ + uint32_t missing; /* VKB_EMU_* features the GPU lacks (emulated or not), plus VKB_CAP_* report masks */ uint32_t client_knobs; /* VKB_KNOB_*: the client's switches from the server (per-game presets) */ uint32_t cached_types; /* server memory types whose shared pages can be CPU-cached (cached readback); 0: none */ uint32_t cached_flags; /* VKB_CACHED_*: who may use them */ diff --git a/server/server_driverid.c b/server/server_driverid.c index 98c7c6e..d027d04 100644 --- a/server/server_driverid.c +++ b/server/server_driverid.c @@ -126,11 +126,14 @@ int vkb_mali_g615_r44p1(const vkb_dispatch *dt, VkPhysicalDevice pd, uint32_t in if (!vkb_driver_is_arm(&p, driver_id)) return 0; VkPhysicalDeviceDriverProperties dp = {VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DRIVER_PROPERTIES}; - if (dt->vkGetPhysicalDeviceProperties2 && inst_api >= VK_API_VERSION_1_1) { + uint32_t api = p.apiVersion < inst_api ? p.apiVersion : inst_api; + if (dt->vkGetPhysicalDeviceProperties2 && inst_api >= VK_API_VERSION_1_1 && + (api >= VK_API_VERSION_1_2 || has_driver_properties(dt, pd))) { VkPhysicalDeviceProperties2 p2 = {VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2, &dp}; dt->vkGetPhysicalDeviceProperties2(pd, &p2); } - if (strstr(dp.driverInfo, "r44p1")) return 1; + for (const char *s = dp.driverInfo; (s = strstr(s, "r44p1")); s += 5) + if (s[5] < '0' || s[5] > '9') return 1; uint32_t r = p.driverVersion >> 22; uint32_t patch = (p.driverVersion >> 12) & 0x3ffu; diff --git a/server/server_emu.c b/server/server_emu.c index a3d6bc3..2df1880 100644 --- a/server/server_emu.c +++ b/server/server_emu.c @@ -810,7 +810,8 @@ uint32_t vkb_emu_detect(const vkb_dispatch *idt, VkPhysicalDevice pd, uint32_t * uint32_t emu = 0; VkPhysicalDeviceProperties props; idt->vkGetPhysicalDeviceProperties(pd, &props); - if (vkb_mali_g615_r44p1(idt, pd, VK_API_VERSION_1_3)) { + int viewport_index_broken = vkb_mali_g615_r44p1(idt, pd, VK_API_VERSION_1_3); + if (viewport_index_broken) { VKB_ONCE(VKB_LOG_INFO, "multi-viewport: Mali-G615 r44p1 ignores a vertex shader's ViewportIndex; reporting multiViewport off"); f.multiViewport = VK_FALSE; @@ -998,6 +999,7 @@ uint32_t vkb_emu_detect(const vkb_dispatch *idt, VkPhysicalDevice pd, uint32_t * if (!f.dualSrcBlend) miss |= VKB_EMU_DUAL_SRC; if (!f.fillModeNonSolid) miss |= VKB_EMU_FILL_MODE; if (!f.multiViewport) miss |= VKB_EMU_MULTI_VIEWPORT; + if (viewport_index_broken) miss |= VKB_CAP_HIDE_MULTI_VIEWPORT; if (!f.multiDrawIndirect) miss |= VKB_EMU_MULTI_DRAW; if (emu & VKB_EMU_MAINT6) miss |= VKB_EMU_MAINT6; if (emu & VKB_EMU_PUSH_DESC) miss |= VKB_EMU_PUSH_DESC; diff --git a/server/server_promote.c b/server/server_promote.c index 4c892dc..9c3f96b 100644 --- a/server/server_promote.c +++ b/server/server_promote.c @@ -737,6 +737,15 @@ static void q_props(void *ctx, void *head) q->d->vkGetPhysicalDeviceProperties2(q->pd, head); } +static void mask_viewport_index_features(const promo_gpu *g, VkPhysicalDeviceFeatures2 *f) +{ + if (!g || !g->viewport_index_broken) return; + f->features.multiViewport = VK_FALSE; + for (VkBaseOutStructure *b = (VkBaseOutStructure *)f->pNext; b; b = b->pNext) + if (b->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES) + ((VkPhysicalDeviceVulkan12Features *)b)->shaderOutputViewportIndex = VK_FALSE; +} + static void append(char *buf, size_t cap, const char *s) { size_t l = strlen(buf); @@ -1021,6 +1030,7 @@ static VKAPI_ATTR void VKAPI_CALL pr_GetPhysicalDeviceFeatures2(VkPhysicalDevice const promo_gpu *g = gpu_of(t, pd); if (!g || !g->active) { t->real.vkGetPhysicalDeviceFeatures2(pd, f); + mask_viewport_index_features(g, f); return; } ext_list el; @@ -1029,6 +1039,7 @@ static VKAPI_ATTR void VKAPI_CALL pr_GetPhysicalDeviceFeatures2(VkPhysicalDevice if (!x) { free(el.e); t->real.vkGetPhysicalDeviceFeatures2(pd, f); + mask_viewport_index_features(g, f); return; } x->drv = g->drv_api; @@ -1036,6 +1047,7 @@ static VKAPI_ATTR void VKAPI_CALL pr_GetPhysicalDeviceFeatures2(VkPhysicalDevice query_ctx q = {&t->real, pd}; chain_query(x, f, q_features, &q); fill_core_features(x, g, x->core); + mask_viewport_index_features(g, f); if (!BELOW(g->offered, V13)) { VkBaseOutStructure *pv = find_in_chain(f, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PRIVATE_DATA_FEATURES); if (pv) ((VkPhysicalDevicePrivateDataFeatures *)pv)->privateData = VK_TRUE; /* the client's own */ @@ -1050,7 +1062,8 @@ void vkb_promote_instance_install(vkb_srv_table *t) int any = 0; pthread_mutex_lock(&gpus_lock); const promo_gpu *list = t->promote_ui ? gpus_ui : gpus; - for (int i = 0; i < ngpus; i++) any |= list[i].offered != list[i].real_api || list[i].active; /* VKBRIDGE_FAKE_API alone too */ + for (int i = 0; i < ngpus; i++) + any |= list[i].offered != list[i].real_api || list[i].active || list[i].viewport_index_broken; pthread_mutex_unlock(&gpus_lock); if (!any) return; t->dt.vkGetPhysicalDeviceProperties = pr_GetPhysicalDeviceProperties;