mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-31 07:40:11 +01:00
venus: use STACK_ARRAY to simplify BindBufferMemory2
Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28532>
This commit is contained in:
parent
02985e37ed
commit
7f75ebfda7
1 changed files with 9 additions and 22 deletions
|
|
@ -451,37 +451,24 @@ vn_BindBufferMemory2(VkDevice device,
|
|||
uint32_t bindInfoCount,
|
||||
const VkBindBufferMemoryInfo *pBindInfos)
|
||||
{
|
||||
struct vn_device *dev = vn_device_from_handle(device);
|
||||
const VkAllocationCallbacks *alloc = &dev->base.base.alloc;
|
||||
STACK_ARRAY(VkBindBufferMemoryInfo, bind_infos, bindInfoCount);
|
||||
typed_memcpy(bind_infos, pBindInfos, bindInfoCount);
|
||||
|
||||
VkBindBufferMemoryInfo *local_infos = NULL;
|
||||
for (uint32_t i = 0; i < bindInfoCount; i++) {
|
||||
const VkBindBufferMemoryInfo *info = &pBindInfos[i];
|
||||
VkBindBufferMemoryInfo *info = &bind_infos[i];
|
||||
struct vn_device_memory *mem =
|
||||
vn_device_memory_from_handle(info->memory);
|
||||
if (!mem->base_memory)
|
||||
continue;
|
||||
|
||||
if (!local_infos) {
|
||||
const size_t size = sizeof(*local_infos) * bindInfoCount;
|
||||
local_infos = vk_alloc(alloc, size, VN_DEFAULT_ALIGN,
|
||||
VK_SYSTEM_ALLOCATION_SCOPE_COMMAND);
|
||||
if (!local_infos)
|
||||
return vn_error(dev->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||
|
||||
memcpy(local_infos, pBindInfos, size);
|
||||
if (mem->base_memory) {
|
||||
info->memory = vn_device_memory_to_handle(mem->base_memory);
|
||||
info->memoryOffset += mem->base_offset;
|
||||
}
|
||||
|
||||
local_infos[i].memory = vn_device_memory_to_handle(mem->base_memory);
|
||||
local_infos[i].memoryOffset += mem->base_offset;
|
||||
}
|
||||
if (local_infos)
|
||||
pBindInfos = local_infos;
|
||||
|
||||
struct vn_device *dev = vn_device_from_handle(device);
|
||||
vn_async_vkBindBufferMemory2(dev->primary_ring, device, bindInfoCount,
|
||||
pBindInfos);
|
||||
bind_infos);
|
||||
|
||||
vk_free(alloc, local_infos);
|
||||
STACK_ARRAY_FINISH(bind_infos);
|
||||
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue