Compare commits

...
Author SHA1 Message Date
The412Banner c80014953c fix(venus): report a pipeline the Mali driver refuses instead of losing the context
Venus sent pipeline creates from the device's own thread without waiting and
assumed they succeeded. When the phone's Mali driver refused one, the render
server had no object for its id and the next vkCmdBindPipeline killed the
whole context: Steam's web helper died two seconds after Big Picture appeared
on a Mali-G52 MC2. Under vtest every thread now waits for the result, so the
application gets the driver's error, and the render server logs each refused
pipeline with its VkResult.
2026-11-26 11:51:16 +00:00
5 changed files with 92 additions and 1 deletions

No files matched your search

+6
View File
@@ -199,6 +199,10 @@ App (Kotlin/C):
- `vn_queue_submission_init_syncs` submits only the sync slots it filled.
- Timeline semaphores free all `queue_count + 1` renderer syncs. Upstream freed one too few and leaked a vtest sync each.
- `vn_queue_submit` runs under a per-queue `submit_mutex`. The async present thread raced the app's submits; see Status.
- Pipelines are created synchronously under vtest, on the thread that created the device too.
- Upstream sends that thread's creates without waiting and assumes they succeed. A phone's Mali driver can refuse one, and the render server then has no object for the id.
- The next command that names it, such as `vkCmdBindPipeline`, is fatal to the whole context. A Mali-G52 MC2 lost Steam's web helper this way two seconds after Big Picture appeared.
- Waiting returns the driver's error to the application, and Venus frees the failed handles.
- WSI's CPU readback buffer goes to Mali's hidden cached memory type; see Performance.
- `vn_physical_device`: keeps the renderer's real memory flags, and picks the hidden type under vtest.
- `vn_renderer_vtest.c`: flush and invalidate of incoherent memory are `DMA_BUF_IOCTL_SYNC` on the bo's dma-buf.
@@ -220,6 +224,8 @@ App (Kotlin/C):
- Exports of any memory type go through that allocator.
- Logs what the driver reports, and failed allocations.
`tools/venus/virglrenderer-log-refused-pipeline.patch`: when the driver refuses a graphics or compute pipeline, the render server logs the `VkResult` and the number of pipelines.
`tools/gamescope/patches/0927-shm-buffers-upload-every-commit.patch`:
- Xwayland has no glamor here, so it reuses about three wl_shm buffers with new pixels.
- gamescope cached one texture per buffer, copied at first import.
+42
View File
@@ -0,0 +1,42 @@
import re
from pathlib import Path
import unittest
ROOT = Path(__file__).resolve().parents[2]
VENUS = ROOT / "tools/venus"
def added_lines(patch, path):
lines = []
in_file = False
for line in patch.splitlines():
if line.startswith("diff --git "):
in_file = line.endswith(" b/" + path)
elif in_file and line.startswith("+") and not line.startswith("+++"):
lines.append(line[1:].strip())
return lines
class VenusPatchesTest(unittest.TestCase):
def test_the_build_applies_every_virglrenderer_patch(self):
script = (VENUS / "ci-build.sh").read_text()
applied = set(re.findall(r'apply "\$REPO/tools/venus/(virglrenderer-[^"]+\.patch)"', script))
shipped = {path.name for path in VENUS.glob("virglrenderer-*.patch")}
self.assertEqual(shipped, applied)
def test_pipelines_are_created_synchronously_over_vtest(self):
patch = (VENUS / "mesa-venus-vtest.patch").read_text()
added = added_lines(patch, "src/virtio/vulkan/vn_device.c")
gate = added.index("if (!VN_DEBUG(VTEST))")
self.assertEqual("vn_tls_set_async_pipeline_create();", added[gate + 1])
def test_the_render_server_logs_every_pipeline_the_driver_refuses(self):
patch = (VENUS / "virglrenderer-log-refused-pipeline.patch").read_text()
added = "\n".join(added_lines(patch, "src/venus/vkr_pipeline.c"))
for kind in ("Graphics", "Compute"):
self.assertIn(f'vkr_log("vkCreate{kind}Pipelines failed with %d for %u pipelines"', added)
if __name__ == "__main__":
unittest.main()
+1
View File
@@ -80,6 +80,7 @@ git clone -q --depth 1 -b virglrenderer-1.3.0 https://gitlab.freedesktop.org/vir
git -C virglrenderer apply "$REPO/tools/venus/virglrenderer-android.patch"
git -C virglrenderer apply "$REPO/tools/venus/virglrenderer-destroy-unknown-pipeline.patch"
git -C virglrenderer apply "$REPO/tools/venus/virglrenderer-destroy-mutex-after-objects.patch"
git -C virglrenderer apply "$REPO/tools/venus/virglrenderer-log-refused-pipeline.patch"
cat > compat/log/log.h <<'EOC'
#pragma once
#include <android/log.h>
+11 -1
View File
@@ -1,5 +1,5 @@
diff --git a/src/virtio/vulkan/vn_device.c b/src/virtio/vulkan/vn_device.c
index f42b9f9..6ed3051 100644
index f42b9f9..73f91e9 100644
--- a/src/virtio/vulkan/vn_device.c
+++ b/src/virtio/vulkan/vn_device.c
@@ -45,6 +45,7 @@ vn_queue_fini(struct vn_queue *queue)
@@ -18,6 +18,16 @@ index f42b9f9..6ed3051 100644
if (dev->physical_device->emulate_second_queue ==
queue_info->queueFamilyIndex &&
@@ -613,7 +615,8 @@ vn_CreateDevice(VkPhysicalDevice physicalDevice,
vn_log(instance, "%s", physical_dev->base.vk.properties.driverInfo);
}
- vn_tls_set_async_pipeline_create();
+ if (!VN_DEBUG(VTEST))
+ vn_tls_set_async_pipeline_create();
*pDevice = vn_device_to_handle(dev);
diff --git a/src/virtio/vulkan/vn_device_memory.c b/src/virtio/vulkan/vn_device_memory.c
index 8b6eb4c..be146b6 100644
--- a/src/virtio/vulkan/vn_device_memory.c
@@ -0,0 +1,32 @@
diff --git a/src/venus/vkr_pipeline.c b/src/venus/vkr_pipeline.c
index 76709b9..4dbd0f6 100644
--- a/src/venus/vkr_pipeline.c
+++ b/src/venus/vkr_pipeline.c
@@ -114,8 +114,12 @@ vkr_dispatch_vkCreateGraphicsPipelines(struct vn_dispatch_context *dispatch,
struct vkr_device *dev = vkr_device_from_handle(args->device);
struct object_array arr;
- if (vkr_graphics_pipeline_create_array(ctx, args, &arr) < VK_SUCCESS)
+ const VkResult result = vkr_graphics_pipeline_create_array(ctx, args, &arr);
+ if (result < VK_SUCCESS) {
+ vkr_log("vkCreateGraphicsPipelines failed with %d for %u pipelines", result,
+ args->createInfoCount);
return;
+ }
vkr_pipeline_add_array(ctx, dev, &arr, args->pPipelines);
}
@@ -129,8 +133,12 @@ vkr_dispatch_vkCreateComputePipelines(struct vn_dispatch_context *dispatch,
struct vkr_device *dev = vkr_device_from_handle(args->device);
struct object_array arr;
- if (vkr_compute_pipeline_create_array(ctx, args, &arr) < VK_SUCCESS)
+ const VkResult result = vkr_compute_pipeline_create_array(ctx, args, &arr);
+ if (result < VK_SUCCESS) {
+ vkr_log("vkCreateComputePipelines failed with %d for %u pipelines", result,
+ args->createInfoCount);
return;
+ }
vkr_pipeline_add_array(ctx, dev, &arr, args->pPipelines);
}