mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-20 05:16:01 +00:00
perf(vkbridge): async requests with ordering, batched descriptor sets, buffered server reads
- Ordered async protocol: vkb_msg_hdr seq/barrier, per-process ordering gate on the server; void commands and VkResult commands without outputs (submits, resets, binds, vkEndCommandBuffer replay) no longer wait for a reply. VKBRIDGE_SYNC=1 restores synchronous calls for debugging. - Client async queue batched across threads with a ~100us background flusher. - Descriptor sets allocated in batches per (pool, layout); the client keeps the pool's books (layout descriptor counts vs pool sizes) so batches ask only for what fits and a full pool answers OUT_OF_POOL_MEMORY without a round trip. Caches for a destroyed layout are dropped (its handle may be reused). - Server parses requests out of one receive buffer (descriptor FIFO for SCM_RIGHTS) instead of two reads per message. - Server logs async VkResult failures (generated vkb_cmd_result table) and per-command timing with VKBRIDGE_STATS=<s>. - tests/d3d11_bench.c: game-like D3D11 frame (1000 draws, Map DISCARD, rebinds). d3d11_bench 1000 draws on RADV: native 0.30 ms/frame; bridge 26.3 ms (sync) -> 1.43 ms. Host suite 14/14 in plain and Mali-imitation modes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
308b200350
commit
a4bd2eb271
14 files changed
+1247
-314
No files matched your search
@@ -77,6 +77,8 @@ LOCAL_COMMANDS_PREFIX = ('vkCreateDebugUtilsMessengerEXT', 'vkDestroyDebugUtilsM
|
||||
|
||||
# Commands whose client entry point is hand-written (the generated wire stub may still be used).
|
||||
CLIENT_CUSTOM = {
|
||||
'vkAllocateDescriptorSets', 'vkResetDescriptorPool', 'vkDestroyDescriptorPool', 'vkCreateDescriptorPool',
|
||||
'vkCreateDescriptorSetLayout', 'vkDestroyDescriptorSetLayout',
|
||||
'vkCreateInstance', 'vkDestroyInstance', 'vkEnumerateInstanceExtensionProperties',
|
||||
'vkEnumerateInstanceLayerProperties', 'vkEnumerateInstanceVersion', 'vkGetInstanceProcAddr',
|
||||
'vkGetDeviceProcAddr', 'vkEnumeratePhysicalDevices', 'vkEnumeratePhysicalDeviceGroups',
|
||||
@@ -119,6 +121,12 @@ SERVER_CUSTOM = {
|
||||
'vkFlushMappedMemoryRanges', 'vkInvalidateMappedMemoryRanges', 'vkEndCommandBuffer',
|
||||
}
|
||||
|
||||
# VkResult commands sent without waiting (VK_SUCCESS returned at once; a failure is logged by the
|
||||
# server). What an app does next with their objects is ordered after them by the protocol.
|
||||
ASYNC_RESULT = {'vkQueueSubmit', 'vkQueueSubmit2', 'vkResetDescriptorPool', 'vkResetCommandPool',
|
||||
'vkResetCommandBuffer', 'vkResetFences', 'vkResetEvent', 'vkSetEvent', 'vkFreeDescriptorSets',
|
||||
'vkBindBufferMemory', 'vkBindBufferMemory2', 'vkBindImageMemory', 'vkBindImageMemory2'}
|
||||
|
||||
# File descriptors: (struct, member) and (command, param).
|
||||
FD_MEMBERS = {('VkImportMemoryFdInfoKHR', 'fd'), ('VkImportSemaphoreFdInfoKHR', 'fd'),
|
||||
('VkImportFenceFdInfoKHR', 'fd')}
|
||||
@@ -871,6 +879,7 @@ for i, c in enumerate(cmd_ids):
|
||||
hw(f'VKB_CMD_COUNT = {len(cmd_ids)}')
|
||||
hw('};')
|
||||
hw('extern const char *const vkb_cmd_names[VKB_CMD_COUNT];')
|
||||
hw('extern const unsigned char vkb_cmd_result[VKB_CMD_COUNT]; /* returns VkResult (first in the reply) */')
|
||||
hw()
|
||||
hw('/* Every bridged command, by its canonical name (aliases resolve to these). */')
|
||||
hw('typedef struct vkb_dispatch {')
|
||||
@@ -907,6 +916,10 @@ names('const char *const vkb_cmd_names[VKB_CMD_COUNT] = {')
|
||||
for c in cmd_ids:
|
||||
names(f'"{c}",')
|
||||
names('};')
|
||||
names('const unsigned char vkb_cmd_result[VKB_CMD_COUNT] = {')
|
||||
for c in cmd_ids:
|
||||
names(f'{1 if c in reg.commands and reg.commands[c]["ret"] == "VkResult" else 0},')
|
||||
names('};')
|
||||
names('const vkb_ext_desc vkb_exts[VKB_EXT_COUNT] = {')
|
||||
for e in bridged_exts:
|
||||
names(f'{{"{e}", {1 if ext_info[e][0] == "device" else 0}, {1 if e in CLIENT_EXTENSIONS else 0}}},')
|
||||
@@ -1085,6 +1098,19 @@ for c in wire_cmds:
|
||||
cw(f'vkb_cmd_record_end({first});')
|
||||
cw('}')
|
||||
cw()
|
||||
elif ret == 'void' and not outs and not any((c, p.name) in FD_PARAMS for p in params):
|
||||
# Nothing comes back: sent without waiting (ordered by the protocol's sequence numbers).
|
||||
cw('vkb_call_exec_async(&call_);')
|
||||
cw('}')
|
||||
cw()
|
||||
elif c in ASYNC_RESULT and not outs:
|
||||
cw('if (vkb_async_results()) return vkb_call_exec_async(&call_) ? VK_SUCCESS : VK_ERROR_DEVICE_LOST;')
|
||||
cw('if (!vkb_call_exec(&call_)) return VK_ERROR_DEVICE_LOST;')
|
||||
cw('VkResult r_ = (VkResult)vkb_dec_u32(&call_.d);')
|
||||
cw('vkb_call_end(&call_);')
|
||||
cw('return r_;')
|
||||
cw('}')
|
||||
cw()
|
||||
else:
|
||||
cw('if (!vkb_call_exec(&call_)) {')
|
||||
if ret == 'VkResult':
|
||||
|
||||
Reference in new issue
Block a user