Non-Adreno round 3: bridge images, Venus GL, shared buffers, Steam GPU drawing

- vkbridge: the memory model skips lazily allocated types. Mali-G615 lists
  DEVICE_LOCAL|LAZILY_ALLOCATED first; taken as the device-local type it left
  images with no memory type (self-test "image clear/draw: setup" FAIL,
  gamescope "No compatible image memory type").
- Session: a bridge self-test that fails images or draws falls back to the
  runtime's driver pair for that session (BL_VKBRIDGE_FALLBACK_ICD); Setup
  and the graphics report say so.
- Venus: the Mali compatibility layer runs in every process but gamescope
  (DROIDDECK_MALI_COMPAT=1), so Zink in Steam and Xwayland gets
  nullDescriptor; null texel-buffer views get stand-ins too. Without
  nullDescriptor the session's GL goes to llvmpipe.
- gamescope 0129: a refused compute pipeline is named with its SPIR-V
  capabilities.
- Compositor: a buffer on two surfaces at once (gamescope's planes while a
  notification is up) is released only when the last one lets go.
- Open driver pairs: processes.txt timeline for the first three minutes;
  Setup "Steam interface: GPU drawing" turns off software web compositing.
This commit is contained in:
The412Banner committed 2026-10-13 08:44:45 -04:00
1 parent 7464bd7697
commit 55b30fbf1d
17 files changed
+282 -18

No files matched your search

+4
View File
@@ -74,3 +74,7 @@ app's Wayland-hosted gamescope never reaches, or need a newer gamescope than the
import, so the screen cycled through the first few frames forever while Steam ran on behind them.
Only dma-buf textures are memoized now; a shm buffer is uploaded on every commit. Adreno never
takes this path, since its Xwayland hands over dma-bufs. Also what XWAYLAND_NO_GLAMOR sessions need.
- `0129-log-failing-compute-pipeline.patch`: when `vkCreateComputePipelines` fails, one extra line
per shader type names the pipeline (shader type, layer count, ycbcr/colorspace masks, fp16) and the
SPIR-V capabilities its shader declares. A Mali-G615 through Venus refused all 119 composite
pipelines with VK_ERROR_INITIALIZATION_FAILED and nothing said which feature it objected to.
@@ -0,0 +1,55 @@
diff --git a/src/rendervulkan.cpp b/src/rendervulkan.cpp
index 42b2ec6..103baee 100644
--- a/src/rendervulkan.cpp
+++ b/src/rendervulkan.cpp
@@ -994,6 +994,8 @@ bool CVulkanDevice::createPools()
return true;
}
+static std::string s_shaderCaps[SHADER_TYPE_COUNT];
+
bool CVulkanDevice::createShaders()
{
struct ShaderInfo_t
@@ -1040,6 +1042,25 @@ bool CVulkanDevice::createShaders()
.pCode = shaderInfos[i].spirv,
};
+ // The SPIR-V capabilities each shader declares, for the log when its pipeline is refused.
+ {
+ const uint32_t *pWords = shaderInfos[i].spirv;
+ size_t nWords = shaderInfos[i].size / sizeof(uint32_t);
+ std::string &sCaps = s_shaderCaps[i];
+ sCaps.clear();
+ for ( size_t w = 5; w < nWords; )
+ {
+ uint32_t uLen = pWords[w] >> 16;
+ if ( !uLen )
+ break;
+ if ( ( pWords[w] & 0xffffu ) == 17 /* OpCapability */ && w + 1 < nWords )
+ sCaps += " " + std::to_string( pWords[w + 1] );
+ else if ( ( pWords[w] & 0xffffu ) == 54 /* OpFunction: past the header */ )
+ break;
+ w += uLen;
+ }
+ }
+
VkResult res = vk.CreateShaderModule(device(), &shaderCreateInfo, nullptr, &m_shaderModules[i]);
if ( res != VK_SUCCESS )
{
@@ -1240,6 +1261,15 @@ VkPipeline CVulkanDevice::compilePipeline(uint32_t layerCount, uint32_t ycbcrMas
VkResult res = vk.CreateComputePipelines(device(), VK_NULL_HANDLE, 1, &computePipelineCreateInfo, nullptr, &result);
if (res != VK_SUCCESS) {
vk_errorf( res, "vkCreateComputePipelines failed" );
+ // Which pipeline, once per shader type: a vendor driver through Venus may refuse one variant only.
+ static uint32_t s_uLoggedTypes = 0;
+ if ( !( s_uLoggedTypes & ( 1u << ( (uint32_t)type & 31u ) ) ) )
+ {
+ s_uLoggedTypes |= 1u << ( (uint32_t)type & 31u );
+ vk_log.errorf( " failing compute pipeline: shader type %u, layers %u, ycbcr mask 0x%x, blur layers %u, colorspace mask 0x%x, output eotf %u, itm %u, fp16 %d, SPIR-V capabilities:%s",
+ (uint32_t)type, layerCount, ycbcrMask, blur_layer_count, colorspace_mask, (uint32_t)output_eotf, (uint32_t)itm_enable, m_bSupportsFp16 ? 1 : 0,
+ (uint32_t)type < SHADER_TYPE_COUNT ? s_shaderCaps[type].c_str() : "" );
+ }
return VK_NULL_HANDLE;
}
@@ -162,17 +162,50 @@ if [ "${BL_VKBRIDGE:-0}" = 1 ]; then
unset TU_DEBUG
if [ -z "${BL_INSIDE:-}" ]; then
step "vkbridge self-test"
timeout 60 /usr/local/bin/droiddeck-vkbridge-smoke 2>&1 | sed 's/^/== vkbridge: /'
bl_vkb_smoke=$(timeout 60 /usr/local/bin/droiddeck-vkbridge-smoke 2>&1)
printf '%s\n' "$bl_vkb_smoke" | sed 's/^/== vkbridge: /'
# Images or draws failing the self-test mean gamescope cannot start on the bridge (it
# asserted in CVulkanTexture::BInit): this session falls back to the Mali driver pair the
# app named, and says so (the app shows it in Setup).
if printf '%s\n' "$bl_vkb_smoke" | grep -qE '^FAIL (image clear|draw)' && [ -r "${BL_VKBRIDGE_FALLBACK_ICD:-}" ]; then
export VK_DRIVER_FILES=$BL_VKBRIDGE_FALLBACK_ICD VK_ICD_FILENAMES=$BL_VKBRIDGE_FALLBACK_ICD BL_VKBRIDGE=0
# What the app sets for a pair session (SessionService): the bridge already bound /dev/mali0
# as the stand-in render node, which is what PanVK reports too.
export BL_OPEN_DRIVER=1 BL_DRM_STANDIN=/dev/mali0
[ "${BL_STEAM_GPU_COMPOSITING:-0}" = 1 ] || export BL_STEAM_SOFT_COMPOSITING=1
echo "== vkbridge: self-test failed images or draws; this session uses the PanVK pair instead ($BL_VKBRIDGE_FALLBACK_ICD)"
[ -n "${BL_DEBUG_DIR:-}" ] && echo "$BL_VKBRIDGE_FALLBACK_ICD" > "$BL_DEBUG_DIR/vkbridge-fallback" 2>/dev/null
fi
unset bl_vkb_smoke
if command -v vulkaninfo >/dev/null 2>&1; then
timeout 30 vulkaninfo --summary 2>&1 | sed -n '/^Devices:/,$p' | head -40 | sed 's/^/== vulkaninfo: /'
fi
fi
echo "== vulkan driver: Mali bridge ($bl_vkb_icd, server at $VKBRIDGE_SOCKET)"
[ "${BL_VKBRIDGE:-0}" = 1 ] && echo "== vulkan driver: Mali bridge ($bl_vkb_icd, server at $VKBRIDGE_SOCKET)"
else
echo "== vulkan driver: Mali bridge requested but NOT usable (icd $bl_vkb_icd, socket ${VKBRIDGE_SOCKET:-unset}); this GPU will show a black screen"
fi
unset bl_vkb_icd
fi
# Mali (Venus): Steam's GL and Xwayland's glamor run on Zink, which refuses a device without
# robustness2's nullDescriptor (Mali has none; the Mali compatibility layer stands in for it). When
# the session's Vulkan still lacks it, GL goes to llvmpipe instead: slower, but Steam starts rather
# than sitting at 0% with "glXChooseVisual failed".
if [ "${BL_VENUS:-0}" = 1 ] && [ -z "${BL_INSIDE:-}" ] && command -v vulkaninfo >/dev/null 2>&1; then
if bl_vn_info=$(timeout 30 vulkaninfo 2>/dev/null); then
case $(printf '%s\n' "$bl_vn_info" | grep -m1 'nullDescriptor') in
*true*) echo "== venus: nullDescriptor present (Zink keeps the GPU)" ;;
*)
export GALLIUM_DRIVER=llvmpipe LIBGL_ALWAYS_SOFTWARE=1
unset MESA_LOADER_DRIVER_OVERRIDE LIBGL_KOPPER_DRI2
echo "== venus: no nullDescriptor on this device even with the Mali compatibility layer; Steam's GL and Xwayland use llvmpipe (software)"
;;
esac
else
echo "== venus: vulkaninfo failed or timed out; GL left on Zink"
fi
unset bl_vn_info
fi
# Detailed graphics logs (BL_GAME_LOGS=1: a GPU that is not an Adreno, or Setup's switch): the
# session's own view of Vulkan, with the driver exactly as exported above, once per session. In the
# background with a timeout, so a driver that hangs here never holds the session up.
@@ -213,6 +246,38 @@ nap() {
[ -n "${bl_nap_fd:-}" ] || exec {bl_nap_fd}<> <(:)
read -r -t "$1" -u "$bl_nap_fd" _ 2>/dev/null || :
}
# Which program a driver error came from: Mesa's lines ("radv/amdgpu: The CS has been rejected",
# "ZINK: vkQueueWaitIdle failed") carry no process name. For the first three minutes of an open
# driver pair's session, every process that appears goes into processes.txt with the session log's
# line count at that moment, so an error's line number in session.log points at what had just
# started. Pure bash over /proc (no execs: see nap).
watch_processes() {
local out=$BL_DEBUG_DIR/processes.txt log=$BL_DEBUG_DIR/session.log i p pid comm lines
local -a argv new
local -A seen=()
echo "# seconds session.log-lines pid name command line" > "$out" 2>/dev/null || return 0
for ((i = 0; i < 360; i++)); do
new=()
for p in /proc/[0-9]*; do
pid=${p#/proc/}
[ -n "${seen[$pid]:-}" ] && continue
seen[$pid]=1
read -r comm < "$p/comm" 2>/dev/null || continue
argv=()
mapfile -d '' -t argv < "$p/cmdline" 2>/dev/null
new+=("$pid"$'\t'"$comm"$'\t'"${argv[*]:0:8}")
done
if [ ${#new[@]} -gt 0 ]; then
lines=0
[ -r "$log" ] && { mapfile -t argv < "$log"; lines=${#argv[@]}; argv=(); }
for p in "${new[@]}"; do printf '%s\t%s\t%.200s\n' "$SECONDS" "$lines" "$p"; done >> "$out"
fi
nap 0.5
done
}
if [ "${BL_OPEN_DRIVER:-0}" = 1 ] && [ -z "${BL_INSIDE:-}" ] && [ -n "${BL_DEBUG_DIR:-}" ]; then
watch_processes &
fi
export XDG_DATA_HOME=${XDG_DATA_HOME:-$HOME/.local/share}
export XDG_CONFIG_HOME=${XDG_CONFIG_HOME:-$HOME/.config}
export XDG_CACHE_HOME=${XDG_CACHE_HOME:-$HOME/.cache}
+4
View File
@@ -47,6 +47,10 @@ class VkDmabufQuarantineTest(unittest.TestCase):
helpers += [function(comp, 'send_buffer_release')]
else:
helpers = ['static int __attribute__((unused)) buffer_release_blocked(struct wl_resource *b) { (void)b; return 0; }']
if re.search(r'\bstatic int buffer_shown_elsewhere\(', comp):
# One surface per buffer in these scenarios: never shown elsewhere.
helpers += ['static int buffer_shown_elsewhere(struct wl_resource *b, const struct surface *e) '
'{ (void)b; (void)e; return 0; }']
query = function(vk, 'vkp_completion_unknown') if 'int vkp_completion_unknown(' in vk else \
'int vkp_completion_unknown(void) { return g_dev_state == -3; }'
comp_functions = [function(comp, names[0])] + helpers + [function(comp, n) for n in names[1:]]
+46 -5
View File
@@ -6,7 +6,8 @@
* - robustness2's nullDescriptor: VK_NULL_HANDLE buffers, image views and vertex buffers in
* descriptor writes (plain, template and push) and vertex-buffer binds are replaced with small
* stand-ins the layer owns. robustBufferAccess2 itself maps to robustBufferAccess (layer.c).
* A texel-buffer view stays null: its format is not known here.
* A null texel-buffer view gets an RGBA8 (uniform) or R32_UINT (storage) view of the stand-in
* buffer: its format is not known here, but Zink leaves them unbound and never reads them.
*/
#include <stdlib.h>
#include <string.h>
@@ -72,7 +73,8 @@ static bool null_resources(struct device *dev)
.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO,
.size = NULL_BUFFER_SIZE,
.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT |
VK_BUFFER_USAGE_VERTEX_BUFFER_BIT | VK_BUFFER_USAGE_INDEX_BUFFER_BIT,
VK_BUFFER_USAGE_VERTEX_BUFFER_BIT | VK_BUFFER_USAGE_INDEX_BUFFER_BIT |
VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT | VK_BUFFER_USAGE_STORAGE_TEXEL_BUFFER_BIT,
.sharingMode = VK_SHARING_MODE_EXCLUSIVE,
};
if (dev->CreateBuffer(dev->handle, &binfo, NULL, &dev->null_buffer) != VK_SUCCESS)
@@ -130,6 +132,18 @@ static bool null_resources(struct device *dev)
};
if (dev->CreateImageView(dev->handle, &vinfo, NULL, &dev->null_view) != VK_SUCCESS)
return false;
/* Texel views are optional: a write that needs one and has none keeps its null. */
VkBufferViewCreateInfo tinfo = {
.sType = VK_STRUCTURE_TYPE_BUFFER_VIEW_CREATE_INFO,
.buffer = dev->null_buffer,
.format = VK_FORMAT_R8G8B8A8_UNORM,
.range = VK_WHOLE_SIZE,
};
if (dev->CreateBufferView(dev->handle, &tinfo, NULL, &dev->null_uniform_texel) != VK_SUCCESS)
dev->null_uniform_texel = VK_NULL_HANDLE;
tinfo.format = VK_FORMAT_R32_UINT;
if (dev->CreateBufferView(dev->handle, &tinfo, NULL, &dev->null_storage_texel) != VK_SUCCESS)
dev->null_storage_texel = VK_NULL_HANDLE;
dev->null_ready = 1;
layer_log("nullDescriptor: stand-in buffer and 1x1 image ready");
return true;
@@ -145,6 +159,8 @@ void null_resources_destroy(struct device *dev)
}
}
map_free(&dev->templates);
if (dev->null_uniform_texel) dev->DestroyBufferView(dev->handle, dev->null_uniform_texel, NULL);
if (dev->null_storage_texel) dev->DestroyBufferView(dev->handle, dev->null_storage_texel, NULL);
if (dev->null_view) dev->DestroyImageView(dev->handle, dev->null_view, NULL);
if (dev->null_image) dev->DestroyImage(dev->handle, dev->null_image, NULL);
if (dev->null_image_memory) dev->FreeMemory(dev->handle, dev->null_image_memory, NULL);
@@ -164,6 +180,18 @@ static bool is_image_type(VkDescriptorType t)
t == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER || t == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT;
}
static bool is_texel_type(VkDescriptorType t)
{
return t == VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER || t == VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER;
}
static void fix_texel(struct device *dev, VkDescriptorType t, VkBufferView *view)
{
if (*view != VK_NULL_HANDLE || !null_resources(dev))
return;
*view = t == VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER ? dev->null_storage_texel : dev->null_uniform_texel;
}
static void fix_buffer(struct device *dev, VkDescriptorBufferInfo *info)
{
if (info->buffer != VK_NULL_HANDLE || !null_resources(dev))
@@ -194,6 +222,8 @@ static VkWriteDescriptorSet *fix_writes(struct device *dev, uint32_t count, cons
if (is_image_type(w->descriptorType) && w->pImageInfo && w->pImageInfo[j].imageView == VK_NULL_HANDLE &&
w->descriptorType != VK_DESCRIPTOR_TYPE_SAMPLER)
null_found = true;
if (is_texel_type(w->descriptorType) && w->pTexelBufferView && w->pTexelBufferView[j] == VK_NULL_HANDLE)
null_found = true;
}
if (!null_found)
continue;
@@ -209,6 +239,13 @@ static VkWriteDescriptorSet *fix_writes(struct device *dev, uint32_t count, cons
fix_buffer(dev, &b[j]);
copies[i].pBufferInfo = b;
(*scratch)[(*scratch_count)++] = b;
} else if (is_texel_type(w->descriptorType)) {
VkBufferView *v = malloc(w->descriptorCount * sizeof(*v));
memcpy(v, w->pTexelBufferView, w->descriptorCount * sizeof(*v));
for (uint32_t j = 0; j < w->descriptorCount; j++)
fix_texel(dev, w->descriptorType, &v[j]);
copies[i].pTexelBufferView = v;
(*scratch)[(*scratch_count)++] = v;
} else {
VkDescriptorImageInfo *im = malloc(w->descriptorCount * sizeof(*im));
memcpy(im, w->pImageInfo, w->descriptorCount * sizeof(*im));
@@ -320,13 +357,15 @@ static void *fix_template_data(struct device *dev, VkDescriptorUpdateTemplate tm
const VkDescriptorUpdateTemplateEntry *e = &t->entries[i];
bool buffer = is_buffer_type(e->descriptorType);
bool image = is_image_type(e->descriptorType);
if (!buffer && !image)
bool texel = is_texel_type(e->descriptorType);
if (!buffer && !image && !texel)
continue;
for (uint32_t j = 0; j < e->descriptorCount; j++) {
size_t at = e->offset + (size_t)j * e->stride;
const char *src = (const char *)(copy ? copy : data) + at;
bool null_handle = buffer ? ((const VkDescriptorBufferInfo *)src)->buffer == VK_NULL_HANDLE
: ((const VkDescriptorImageInfo *)src)->imageView == VK_NULL_HANDLE;
bool null_handle = buffer ? ((const VkDescriptorBufferInfo *)src)->buffer == VK_NULL_HANDLE
: texel ? *(const VkBufferView *)src == VK_NULL_HANDLE
: ((const VkDescriptorImageInfo *)src)->imageView == VK_NULL_HANDLE;
if (!null_handle)
continue;
if (!copy) {
@@ -335,6 +374,8 @@ static void *fix_template_data(struct device *dev, VkDescriptorUpdateTemplate tm
}
if (buffer)
fix_buffer(dev, (VkDescriptorBufferInfo *)((char *)copy + at));
else if (texel)
fix_texel(dev, e->descriptorType, (VkBufferView *)((char *)copy + at));
else
fix_image(dev, (VkDescriptorImageInfo *)((char *)copy + at));
}
+12 -4
View File
@@ -1,5 +1,7 @@
#define _GNU_SOURCE
#include "mali_compat.h"
#include <errno.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
@@ -133,13 +135,19 @@ void map_free(struct handle_map *map)
*map = (struct handle_map){0};
}
/* Wine processes only: the Steam client and gamescope run fine without the layer, and their
* Zink would otherwise start using the made-up features too. */
/* Wine processes by default. DROIDDECK_MALI_COMPAT=1 (the app's Venus route) turns it on everywhere
* but gamescope, so Zink in the Steam client and Xwayland gets robustness2's nullDescriptor, which it
* requires; gamescope runs fine on the driver's own features. =all includes gamescope too. */
static bool wanted(void)
{
const char *setting = getenv("DROIDDECK_MALI_COMPAT");
if (setting)
return strcmp(setting, "0") != 0;
if (setting) {
if (strcmp(setting, "0") == 0)
return false;
if (strcmp(setting, "all") == 0)
return true;
return strcmp(program_invocation_short_name, "gamescope") != 0;
}
return getenv("WINEPREFIX") != NULL;
}
+5
View File
@@ -119,6 +119,8 @@ struct instance {
X(GetImageMemoryRequirements) \
X(BindImageMemory) \
X(DestroyImageView) \
X(CreateBufferView) \
X(DestroyBufferView) \
X(UpdateDescriptorSets) \
X(CmdPushDescriptorSet) \
X(CreateDescriptorUpdateTemplate) \
@@ -157,6 +159,9 @@ struct device {
VkImage null_image;
VkDeviceMemory null_image_memory;
VkImageView null_view;
/* Texel-buffer stand-ins: RGBA8 for uniform (sampled) texel buffers, R32_UINT for storage. */
VkBufferView null_uniform_texel;
VkBufferView null_storage_texel;
struct device *next;
};
+7 -2
View File
@@ -30,8 +30,12 @@ static void build_memory_model(vkb_physdev *pd)
int pure_dl = -1;
for (uint32_t t = 0; t < s->memoryTypeCount; t++) {
VkMemoryPropertyFlags f = s->memoryTypes[t].propertyFlags;
/* Not a lazily allocated type (Mali lists one first, for transient attachments): an
* ordinary image cannot use it, and taking it as "the" device-local type left images with
* no memory type at all (self-test "image clear: setup", gamescope "No compatible image
* memory type"). */
if ((f & VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT) && !(f & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT) &&
!(f & VK_MEMORY_PROPERTY_PROTECTED_BIT)) {
!(f & VK_MEMORY_PROPERTY_PROTECTED_BIT) && !(f & VK_MEMORY_PROPERTY_LAZILY_ALLOCATED_BIT)) {
pure_dl = (int)t;
break;
}
@@ -55,7 +59,8 @@ static void build_memory_model(vkb_physdev *pd)
/* A device-local type with no host access, backed by the first device-local type. */
for (uint32_t t = 0; t < s->memoryTypeCount; t++) {
VkMemoryPropertyFlags f = s->memoryTypes[t].propertyFlags;
if ((f & VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT) && !(f & VK_MEMORY_PROPERTY_PROTECTED_BIT)) {
if ((f & VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT) && !(f & VK_MEMORY_PROPERTY_PROTECTED_BIT) &&
!(f & VK_MEMORY_PROPERTY_LAZILY_ALLOCATED_BIT)) {
cands[nc++] = (struct cand){VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, s->memoryTypes[t].heapIndex, t, 0};
break;
}