venus: implement all descriptor heap commands

There're potential optimizations available for below:
- vkWriteSamplerDescriptorsEXT
- vkWriteResourceDescriptorsEXT
- vkGetPhysicalDeviceDescriptorSizeEXT
- vkRegisterCustomBorderColorEXT

...and we can revisit if there's perf hit from above for real apps.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/39762>
This commit is contained in:
Yiwei Zhang 2026-02-07 23:06:40 -08:00 committed by Marge Bot
parent 04c0142aaa
commit 485b2b501c
4 changed files with 118 additions and 0 deletions

View file

@ -59,6 +59,7 @@ libvn_files = files(
'vn_command_buffer.c',
'vn_common.c',
'vn_cs.c',
'vn_descriptor_heap.c',
'vn_descriptor_set.c',
'vn_device.c',
'vn_device_memory.c',

View file

@ -2813,3 +2813,24 @@ vn_CmdDrawMeshTasksIndirectCountEXT(VkCommandBuffer commandBuffer,
offset, countBuffer, countBufferOffset, maxDrawCount,
stride);
}
VKAPI_ATTR void VKAPI_CALL
vn_CmdBindResourceHeapEXT(VkCommandBuffer commandBuffer,
const VkBindHeapInfoEXT *pBindInfo)
{
VN_CMD_ENQUEUE(vkCmdBindResourceHeapEXT, commandBuffer, pBindInfo);
}
VKAPI_ATTR void VKAPI_CALL
vn_CmdBindSamplerHeapEXT(VkCommandBuffer commandBuffer,
const VkBindHeapInfoEXT *pBindInfo)
{
VN_CMD_ENQUEUE(vkCmdBindSamplerHeapEXT, commandBuffer, pBindInfo);
}
VKAPI_ATTR void VKAPI_CALL
vn_CmdPushDataEXT(VkCommandBuffer commandBuffer,
const VkPushDataInfoEXT *pPushDataInfo)
{
VN_CMD_ENQUEUE(vkCmdPushDataEXT, commandBuffer, pPushDataInfo);
}

View file

@ -0,0 +1,83 @@
/*
* Copyright 2026 Google LLC
* SPDX-License-Identifier: MIT
*/
#include "venus-protocol/vn_protocol_driver_descriptor_heap.h"
#include "vn_device.h"
/* descriptor heap commands */
VKAPI_ATTR VkResult VKAPI_CALL
vn_WriteSamplerDescriptorsEXT(VkDevice device,
uint32_t samplerCount,
const VkSamplerCreateInfo *pSamplers,
const VkHostAddressRangeEXT *pDescriptors)
{
struct vn_device *dev = vn_device_from_handle(device);
/* TODO move out from primary ring? */
for (uint32_t i = 0; i < samplerCount; i++) {
VkResult result = vn_call_vkWriteSamplerDescriptorMESA(
dev->primary_ring, device, &pSamplers[i], pDescriptors[i].size,
pDescriptors[i].address);
if (result != VK_SUCCESS)
return vn_error(dev->instance, result);
}
return VK_SUCCESS;
}
VKAPI_ATTR VkResult VKAPI_CALL
vn_WriteResourceDescriptorsEXT(VkDevice device,
uint32_t resourceCount,
const VkResourceDescriptorInfoEXT *pResources,
const VkHostAddressRangeEXT *pDescriptors)
{
struct vn_device *dev = vn_device_from_handle(device);
/* TODO move out from primary ring? */
for (uint32_t i = 0; i < resourceCount; i++) {
VkResult result = vn_call_vkWriteResourceDescriptorMESA(
dev->primary_ring, device, &pResources[i], pDescriptors[i].size,
pDescriptors[i].address);
if (result != VK_SUCCESS)
return vn_error(dev->instance, result);
}
return VK_SUCCESS;
}
VKAPI_ATTR VkResult VKAPI_CALL
vn_GetImageOpaqueCaptureDataEXT(VkDevice device,
uint32_t imageCount,
const VkImage *pImages,
VkHostAddressRangeEXT *pDatas)
{
struct vn_device *dev = vn_device_from_handle(device);
return vn_call_vkGetImageOpaqueCaptureDataEXT(dev->primary_ring, device,
imageCount, pImages, pDatas);
}
VKAPI_ATTR VkResult VKAPI_CALL
vn_RegisterCustomBorderColorEXT(
VkDevice device,
const VkSamplerCustomBorderColorCreateInfoEXT *pBorderColor,
VkBool32 requestIndex,
uint32_t *pIndex)
{
struct vn_device *dev = vn_device_from_handle(device);
/* TODO manage indexes to make it async */
return vn_call_vkRegisterCustomBorderColorEXT(
dev->primary_ring, device, pBorderColor, requestIndex, pIndex);
}
VKAPI_ATTR void VKAPI_CALL
vn_UnregisterCustomBorderColorEXT(VkDevice device, uint32_t index)
{
struct vn_device *dev = vn_device_from_handle(device);
vn_async_vkUnregisterCustomBorderColorEXT(dev->primary_ring, device,
index);
}

View file

@ -3059,3 +3059,16 @@ vn_GetPhysicalDeviceMultisamplePropertiesEXT(
vn_call_vkGetPhysicalDeviceMultisamplePropertiesEXT(
ring, physicalDevice, samples, pMultisampleProperties);
}
VKAPI_ATTR VkDeviceSize VKAPI_CALL
vn_GetPhysicalDeviceDescriptorSizeEXT(VkPhysicalDevice physicalDevice,
VkDescriptorType descriptorType)
{
struct vn_physical_device *physical_dev =
vn_physical_device_from_handle(physicalDevice);
struct vn_ring *ring = physical_dev->instance->ring.ring;
/* TODO per-device cache */
return vn_call_vkGetPhysicalDeviceDescriptorSizeEXT(ring, physicalDevice,
descriptorType);
}