2023-03-07 17:02:34 +01:00
|
|
|
/*
|
|
|
|
|
* Copyright © 2016 Red Hat.
|
|
|
|
|
* Copyright © 2016 Bas Nieuwenhuizen
|
|
|
|
|
*
|
|
|
|
|
* based in part on anv driver which is:
|
|
|
|
|
* Copyright © 2015 Intel Corporation
|
|
|
|
|
*
|
2024-04-05 16:28:39 +02:00
|
|
|
* SPDX-License-Identifier: MIT
|
2023-03-07 17:02:34 +01:00
|
|
|
*/
|
|
|
|
|
|
2024-04-01 15:52:30 +02:00
|
|
|
#include "radv_buffer.h"
|
2024-04-04 14:29:07 +02:00
|
|
|
#include "radv_device.h"
|
2024-04-01 17:26:43 +02:00
|
|
|
#include "radv_device_memory.h"
|
2024-12-13 12:29:47 +01:00
|
|
|
#include "radv_dgc.h"
|
2024-04-04 14:29:07 +02:00
|
|
|
#include "radv_entrypoints.h"
|
|
|
|
|
#include "radv_instance.h"
|
|
|
|
|
#include "radv_physical_device.h"
|
2024-04-02 14:05:21 +02:00
|
|
|
#include "radv_rmv.h"
|
2023-03-07 17:02:34 +01:00
|
|
|
|
2023-03-21 08:38:11 +01:00
|
|
|
#include "vk_common_entrypoints.h"
|
2023-01-16 17:04:47 +01:00
|
|
|
#include "vk_debug_utils.h"
|
2024-04-04 14:29:07 +02:00
|
|
|
#include "vk_log.h"
|
2023-03-07 17:02:34 +01:00
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
radv_destroy_buffer(struct radv_device *device, const VkAllocationCallbacks *pAllocator, struct radv_buffer *buffer)
|
|
|
|
|
{
|
2024-04-10 08:43:34 +02:00
|
|
|
struct radv_physical_device *pdev = radv_device_physical(device);
|
|
|
|
|
struct radv_instance *instance = radv_physical_device_instance(pdev);
|
|
|
|
|
|
2024-03-25 15:16:27 +01:00
|
|
|
if ((buffer->vk.create_flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT) && buffer->bo)
|
2023-01-16 17:04:47 +01:00
|
|
|
radv_bo_destroy(device, &buffer->vk.base, buffer->bo);
|
2023-03-07 17:02:34 +01:00
|
|
|
|
2025-03-05 17:29:48 +01:00
|
|
|
if (buffer->vk.device_address)
|
|
|
|
|
vk_address_binding_report(&instance->vk, &buffer->vk.base, buffer->vk.device_address, buffer->range,
|
2024-04-10 08:43:34 +02:00
|
|
|
VK_DEVICE_ADDRESS_BINDING_TYPE_UNBIND_EXT);
|
|
|
|
|
|
2023-03-07 17:02:34 +01:00
|
|
|
radv_rmv_log_resource_destroy(device, (uint64_t)radv_buffer_to_handle(buffer));
|
2025-02-11 16:51:19 +01:00
|
|
|
vk_buffer_finish(&buffer->vk);
|
2023-03-07 17:02:34 +01:00
|
|
|
vk_free2(&device->vk.alloc, pAllocator, buffer);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
VkResult
|
|
|
|
|
radv_create_buffer(struct radv_device *device, const VkBufferCreateInfo *pCreateInfo,
|
|
|
|
|
const VkAllocationCallbacks *pAllocator, VkBuffer *pBuffer, bool is_internal)
|
|
|
|
|
{
|
|
|
|
|
struct radv_buffer *buffer;
|
|
|
|
|
|
|
|
|
|
assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO);
|
|
|
|
|
|
2024-01-30 11:06:24 -08:00
|
|
|
#if DETECT_OS_ANDROID
|
2023-03-07 17:02:34 +01:00
|
|
|
/* reject buffers that are larger than maxBufferSize on Android, which
|
|
|
|
|
* might not have VK_KHR_maintenance4
|
|
|
|
|
*/
|
|
|
|
|
if (pCreateInfo->size > RADV_MAX_MEMORY_ALLOCATION_SIZE)
|
|
|
|
|
return vk_error(device, VK_ERROR_OUT_OF_DEVICE_MEMORY);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
buffer = vk_alloc2(&device->vk.alloc, pAllocator, sizeof(*buffer), 8, VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
|
|
|
|
|
if (buffer == NULL)
|
|
|
|
|
return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY);
|
|
|
|
|
|
|
|
|
|
vk_buffer_init(&device->vk, &buffer->vk, pCreateInfo);
|
|
|
|
|
buffer->bo = NULL;
|
2024-04-12 12:58:17 +02:00
|
|
|
buffer->range = 0;
|
2023-03-07 17:02:34 +01:00
|
|
|
|
2024-09-12 12:27:56 +02:00
|
|
|
uint64_t replay_address = 0;
|
|
|
|
|
const VkBufferOpaqueCaptureAddressCreateInfo *replay_info =
|
|
|
|
|
vk_find_struct_const(pCreateInfo->pNext, BUFFER_OPAQUE_CAPTURE_ADDRESS_CREATE_INFO);
|
|
|
|
|
if (replay_info && replay_info->opaqueCaptureAddress)
|
|
|
|
|
replay_address = replay_info->opaqueCaptureAddress;
|
|
|
|
|
|
|
|
|
|
if (pCreateInfo->flags & VK_BUFFER_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT)
|
2025-03-05 17:29:48 +01:00
|
|
|
buffer->vk.device_address = replay_address;
|
2024-09-12 12:27:56 +02:00
|
|
|
|
2023-03-07 17:02:34 +01:00
|
|
|
if (pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT) {
|
|
|
|
|
enum radeon_bo_flag flags = RADEON_FLAG_VIRTUAL;
|
|
|
|
|
if (pCreateInfo->flags & VK_BUFFER_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT)
|
|
|
|
|
flags |= RADEON_FLAG_REPLAYABLE;
|
2024-09-06 09:21:30 +02:00
|
|
|
if (buffer->vk.usage &
|
|
|
|
|
(VK_BUFFER_USAGE_2_RESOURCE_DESCRIPTOR_BUFFER_BIT_EXT | VK_BUFFER_USAGE_2_SAMPLER_DESCRIPTOR_BUFFER_BIT_EXT))
|
2023-12-03 15:30:02 +00:00
|
|
|
flags |= RADEON_FLAG_32BIT;
|
2023-03-07 17:02:34 +01:00
|
|
|
|
2023-01-16 17:04:47 +01:00
|
|
|
VkResult result = radv_bo_create(device, &buffer->vk.base, align64(buffer->vk.size, 4096), 4096, 0, flags,
|
|
|
|
|
RADV_BO_PRIORITY_VIRTUAL, replay_address, is_internal, &buffer->bo);
|
2023-03-07 17:02:34 +01:00
|
|
|
if (result != VK_SUCCESS) {
|
|
|
|
|
radv_destroy_buffer(device, pAllocator, buffer);
|
|
|
|
|
return vk_error(device, result);
|
|
|
|
|
}
|
2024-09-12 12:27:56 +02:00
|
|
|
|
2025-03-05 17:29:48 +01:00
|
|
|
buffer->vk.device_address = radv_buffer_get_va(buffer->bo);
|
2023-03-07 17:02:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
*pBuffer = radv_buffer_to_handle(buffer);
|
|
|
|
|
vk_rmv_log_buffer_create(&device->vk, false, *pBuffer);
|
|
|
|
|
if (buffer->bo)
|
|
|
|
|
radv_rmv_log_buffer_bind(device, *pBuffer);
|
|
|
|
|
return VK_SUCCESS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
VKAPI_ATTR VkResult VKAPI_CALL
|
|
|
|
|
radv_CreateBuffer(VkDevice _device, const VkBufferCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator,
|
|
|
|
|
VkBuffer *pBuffer)
|
|
|
|
|
{
|
2024-04-02 18:06:21 +02:00
|
|
|
VK_FROM_HANDLE(radv_device, device, _device);
|
2023-03-07 17:02:34 +01:00
|
|
|
return radv_create_buffer(device, pCreateInfo, pAllocator, pBuffer, false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
VKAPI_ATTR void VKAPI_CALL
|
|
|
|
|
radv_DestroyBuffer(VkDevice _device, VkBuffer _buffer, const VkAllocationCallbacks *pAllocator)
|
|
|
|
|
{
|
2024-04-02 18:06:21 +02:00
|
|
|
VK_FROM_HANDLE(radv_device, device, _device);
|
|
|
|
|
VK_FROM_HANDLE(radv_buffer, buffer, _buffer);
|
2023-03-07 17:02:34 +01:00
|
|
|
|
|
|
|
|
if (!buffer)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
radv_destroy_buffer(device, pAllocator, buffer);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
VKAPI_ATTR VkResult VKAPI_CALL
|
|
|
|
|
radv_BindBufferMemory2(VkDevice _device, uint32_t bindInfoCount, const VkBindBufferMemoryInfo *pBindInfos)
|
|
|
|
|
{
|
2024-04-02 18:06:21 +02:00
|
|
|
VK_FROM_HANDLE(radv_device, device, _device);
|
2023-01-16 17:04:47 +01:00
|
|
|
struct radv_physical_device *pdev = radv_device_physical(device);
|
|
|
|
|
struct radv_instance *instance = radv_physical_device_instance(pdev);
|
2023-03-07 17:02:34 +01:00
|
|
|
|
|
|
|
|
for (uint32_t i = 0; i < bindInfoCount; ++i) {
|
2024-04-02 18:06:21 +02:00
|
|
|
VK_FROM_HANDLE(radv_device_memory, mem, pBindInfos[i].memory);
|
|
|
|
|
VK_FROM_HANDLE(radv_buffer, buffer, pBindInfos[i].buffer);
|
2024-12-02 10:46:31 +01:00
|
|
|
VkBindMemoryStatus *status = (void *)vk_find_struct_const(&pBindInfos[i], BIND_MEMORY_STATUS);
|
2023-09-18 09:58:18 +02:00
|
|
|
|
|
|
|
|
if (status)
|
|
|
|
|
*status->pResult = VK_SUCCESS;
|
2023-03-07 17:02:34 +01:00
|
|
|
|
2024-04-12 12:58:17 +02:00
|
|
|
VkBufferMemoryRequirementsInfo2 info = {
|
|
|
|
|
.sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_REQUIREMENTS_INFO_2,
|
|
|
|
|
.buffer = pBindInfos[i].buffer,
|
|
|
|
|
};
|
|
|
|
|
VkMemoryRequirements2 reqs = {
|
|
|
|
|
.sType = VK_STRUCTURE_TYPE_MEMORY_REQUIREMENTS_2,
|
|
|
|
|
};
|
2023-03-07 17:02:34 +01:00
|
|
|
|
2024-04-12 12:58:17 +02:00
|
|
|
vk_common_GetBufferMemoryRequirements2(_device, &info, &reqs);
|
2023-03-07 17:02:34 +01:00
|
|
|
|
2024-04-12 12:58:17 +02:00
|
|
|
if (mem->alloc_size) {
|
2023-03-07 17:02:34 +01:00
|
|
|
if (pBindInfos[i].memoryOffset + reqs.memoryRequirements.size > mem->alloc_size) {
|
2023-09-18 09:58:18 +02:00
|
|
|
if (status)
|
|
|
|
|
*status->pResult = VK_ERROR_UNKNOWN;
|
2023-03-07 17:02:34 +01:00
|
|
|
return vk_errorf(device, VK_ERROR_UNKNOWN, "Device memory object too small for the buffer.\n");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
buffer->bo = mem->bo;
|
2025-03-05 17:29:48 +01:00
|
|
|
buffer->vk.device_address = radv_buffer_get_va(mem->bo) + pBindInfos[i].memoryOffset;
|
2024-04-12 12:58:17 +02:00
|
|
|
buffer->range = reqs.memoryRequirements.size;
|
2024-04-10 08:43:34 +02:00
|
|
|
|
2023-03-07 17:02:34 +01:00
|
|
|
radv_rmv_log_buffer_bind(device, pBindInfos[i].buffer);
|
2023-01-16 17:04:47 +01:00
|
|
|
|
2025-03-05 17:29:48 +01:00
|
|
|
vk_address_binding_report(&instance->vk, &buffer->vk.base, buffer->vk.device_address, buffer->range,
|
2025-02-10 10:26:49 +01:00
|
|
|
VK_DEVICE_ADDRESS_BINDING_TYPE_BIND_EXT);
|
2023-03-07 17:02:34 +01:00
|
|
|
}
|
|
|
|
|
return VK_SUCCESS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
radv_get_buffer_memory_requirements(struct radv_device *device, VkDeviceSize size, VkBufferCreateFlags flags,
|
2024-12-02 10:42:20 +01:00
|
|
|
VkBufferUsageFlags2 usage, VkMemoryRequirements2 *pMemoryRequirements)
|
2023-03-07 17:02:34 +01:00
|
|
|
{
|
2024-03-28 14:42:10 +01:00
|
|
|
const struct radv_physical_device *pdev = radv_device_physical(device);
|
2025-05-13 09:24:41 +02:00
|
|
|
const struct radv_instance *instance = radv_physical_device_instance(pdev);
|
2024-03-28 14:42:10 +01:00
|
|
|
|
2023-03-07 17:02:34 +01:00
|
|
|
pMemoryRequirements->memoryRequirements.memoryTypeBits =
|
2024-03-28 14:42:10 +01:00
|
|
|
((1u << pdev->memory_properties.memoryTypeCount) - 1u) & ~pdev->memory_types_32bit;
|
2023-03-07 17:02:34 +01:00
|
|
|
|
|
|
|
|
/* Force 32-bit address-space for descriptor buffers usage because they are passed to shaders
|
|
|
|
|
* through 32-bit pointers.
|
|
|
|
|
*/
|
2024-08-30 22:19:52 +02:00
|
|
|
if (usage & (VK_BUFFER_USAGE_2_RESOURCE_DESCRIPTOR_BUFFER_BIT_EXT |
|
|
|
|
|
VK_BUFFER_USAGE_2_SAMPLER_DESCRIPTOR_BUFFER_BIT_EXT | VK_BUFFER_USAGE_2_PREPROCESS_BUFFER_BIT_EXT))
|
2024-03-28 14:42:10 +01:00
|
|
|
pMemoryRequirements->memoryRequirements.memoryTypeBits = pdev->memory_types_32bit;
|
2023-03-07 17:02:34 +01:00
|
|
|
|
2024-12-13 12:29:47 +01:00
|
|
|
if (flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT) {
|
2025-05-13 09:24:41 +02:00
|
|
|
if (instance->drirc.force_64k_sparse_alignment)
|
|
|
|
|
pMemoryRequirements->memoryRequirements.alignment = 65536;
|
|
|
|
|
else
|
|
|
|
|
pMemoryRequirements->memoryRequirements.alignment = 4096;
|
2024-12-13 12:29:47 +01:00
|
|
|
} else {
|
|
|
|
|
if (usage & VK_BUFFER_USAGE_2_PREPROCESS_BUFFER_BIT_EXT)
|
|
|
|
|
pMemoryRequirements->memoryRequirements.alignment = radv_dgc_get_buffer_alignment(device);
|
|
|
|
|
else
|
|
|
|
|
pMemoryRequirements->memoryRequirements.alignment = 16;
|
|
|
|
|
}
|
2023-03-07 17:02:34 +01:00
|
|
|
|
|
|
|
|
/* Top level acceleration structures need the bottom 6 bits to store
|
|
|
|
|
* the root ids of instances. The hardware also needs bvh nodes to
|
|
|
|
|
* be 64 byte aligned.
|
|
|
|
|
*/
|
2023-07-28 09:17:14 +02:00
|
|
|
if (usage & VK_BUFFER_USAGE_2_ACCELERATION_STRUCTURE_STORAGE_BIT_KHR)
|
2023-03-07 17:02:34 +01:00
|
|
|
pMemoryRequirements->memoryRequirements.alignment = MAX2(pMemoryRequirements->memoryRequirements.alignment, 64);
|
|
|
|
|
|
|
|
|
|
pMemoryRequirements->memoryRequirements.size = align64(size, pMemoryRequirements->memoryRequirements.alignment);
|
|
|
|
|
|
|
|
|
|
vk_foreach_struct (ext, pMemoryRequirements->pNext) {
|
|
|
|
|
switch (ext->sType) {
|
|
|
|
|
case VK_STRUCTURE_TYPE_MEMORY_DEDICATED_REQUIREMENTS: {
|
|
|
|
|
VkMemoryDedicatedRequirements *req = (VkMemoryDedicatedRequirements *)ext;
|
|
|
|
|
req->requiresDedicatedAllocation = false;
|
|
|
|
|
req->prefersDedicatedAllocation = req->requiresDedicatedAllocation;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-12-02 10:42:20 +01:00
|
|
|
static const VkBufferUsageFlagBits2
|
2023-07-28 09:17:14 +02:00
|
|
|
radv_get_buffer_usage_flags(const VkBufferCreateInfo *pCreateInfo)
|
|
|
|
|
{
|
2024-12-02 10:42:20 +01:00
|
|
|
const VkBufferUsageFlags2CreateInfo *flags2 =
|
|
|
|
|
vk_find_struct_const(pCreateInfo->pNext, BUFFER_USAGE_FLAGS_2_CREATE_INFO);
|
2023-07-28 09:17:14 +02:00
|
|
|
return flags2 ? flags2->usage : pCreateInfo->usage;
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-07 17:02:34 +01:00
|
|
|
VKAPI_ATTR void VKAPI_CALL
|
|
|
|
|
radv_GetDeviceBufferMemoryRequirements(VkDevice _device, const VkDeviceBufferMemoryRequirements *pInfo,
|
|
|
|
|
VkMemoryRequirements2 *pMemoryRequirements)
|
|
|
|
|
{
|
2024-04-02 18:06:21 +02:00
|
|
|
VK_FROM_HANDLE(radv_device, device, _device);
|
2024-12-02 10:42:20 +01:00
|
|
|
const VkBufferUsageFlagBits2 usage_flags = radv_get_buffer_usage_flags(pInfo->pCreateInfo);
|
2023-03-07 17:02:34 +01:00
|
|
|
|
2023-07-28 09:17:14 +02:00
|
|
|
radv_get_buffer_memory_requirements(device, pInfo->pCreateInfo->size, pInfo->pCreateInfo->flags, usage_flags,
|
|
|
|
|
pMemoryRequirements);
|
2023-03-07 17:02:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
VKAPI_ATTR uint64_t VKAPI_CALL
|
|
|
|
|
radv_GetBufferOpaqueCaptureAddress(VkDevice device, const VkBufferDeviceAddressInfo *pInfo)
|
|
|
|
|
{
|
2024-04-02 18:06:21 +02:00
|
|
|
VK_FROM_HANDLE(radv_buffer, buffer, pInfo->buffer);
|
2025-03-05 17:29:48 +01:00
|
|
|
return buffer->vk.device_address;
|
2023-03-07 17:02:34 +01:00
|
|
|
}
|
2024-03-25 14:54:08 +01:00
|
|
|
|
|
|
|
|
VkResult
|
2023-01-16 17:04:47 +01:00
|
|
|
radv_bo_create(struct radv_device *device, struct vk_object_base *object, uint64_t size, unsigned alignment,
|
|
|
|
|
enum radeon_bo_domain domain, enum radeon_bo_flag flags, unsigned priority, uint64_t address,
|
|
|
|
|
bool is_internal, struct radeon_winsys_bo **out_bo)
|
2024-03-25 14:54:08 +01:00
|
|
|
{
|
2023-01-16 17:04:47 +01:00
|
|
|
struct radv_physical_device *pdev = radv_device_physical(device);
|
|
|
|
|
struct radv_instance *instance = radv_physical_device_instance(pdev);
|
2024-03-25 14:54:08 +01:00
|
|
|
struct radeon_winsys *ws = device->ws;
|
2024-03-25 15:16:27 +01:00
|
|
|
VkResult result;
|
|
|
|
|
|
|
|
|
|
result = ws->buffer_create(ws, size, alignment, domain, flags, priority, address, out_bo);
|
|
|
|
|
if (result != VK_SUCCESS)
|
|
|
|
|
return result;
|
|
|
|
|
|
|
|
|
|
radv_rmv_log_bo_allocate(device, *out_bo, is_internal);
|
2024-03-25 14:54:08 +01:00
|
|
|
|
2023-01-16 17:04:47 +01:00
|
|
|
vk_address_binding_report(&instance->vk, object ? object : &device->vk.base, radv_buffer_get_va(*out_bo),
|
|
|
|
|
(*out_bo)->size, VK_DEVICE_ADDRESS_BINDING_TYPE_BIND_EXT);
|
2024-03-25 15:16:27 +01:00
|
|
|
return VK_SUCCESS;
|
2024-03-25 14:54:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
2023-01-16 17:04:47 +01:00
|
|
|
radv_bo_destroy(struct radv_device *device, struct vk_object_base *object, struct radeon_winsys_bo *bo)
|
2024-03-25 14:54:08 +01:00
|
|
|
{
|
2023-01-16 17:04:47 +01:00
|
|
|
struct radv_physical_device *pdev = radv_device_physical(device);
|
|
|
|
|
struct radv_instance *instance = radv_physical_device_instance(pdev);
|
2024-03-25 14:54:08 +01:00
|
|
|
struct radeon_winsys *ws = device->ws;
|
|
|
|
|
|
2024-03-25 15:16:27 +01:00
|
|
|
radv_rmv_log_bo_destroy(device, bo);
|
|
|
|
|
|
2023-01-16 17:04:47 +01:00
|
|
|
vk_address_binding_report(&instance->vk, object ? object : &device->vk.base, radv_buffer_get_va(bo), bo->size,
|
|
|
|
|
VK_DEVICE_ADDRESS_BINDING_TYPE_UNBIND_EXT);
|
|
|
|
|
|
2024-03-25 14:54:08 +01:00
|
|
|
ws->buffer_destroy(ws, bo);
|
|
|
|
|
}
|
2024-03-25 16:49:36 +01:00
|
|
|
|
|
|
|
|
VkResult
|
2023-01-16 17:04:47 +01:00
|
|
|
radv_bo_virtual_bind(struct radv_device *device, struct vk_object_base *object, struct radeon_winsys_bo *parent,
|
|
|
|
|
uint64_t offset, uint64_t size, struct radeon_winsys_bo *bo, uint64_t bo_offset)
|
2024-03-25 16:49:36 +01:00
|
|
|
{
|
2023-01-16 17:04:47 +01:00
|
|
|
struct radv_physical_device *pdev = radv_device_physical(device);
|
|
|
|
|
struct radv_instance *instance = radv_physical_device_instance(pdev);
|
2024-03-25 16:49:36 +01:00
|
|
|
struct radeon_winsys *ws = device->ws;
|
|
|
|
|
VkResult result;
|
|
|
|
|
|
|
|
|
|
result = ws->buffer_virtual_bind(ws, parent, offset, size, bo, bo_offset);
|
|
|
|
|
if (result != VK_SUCCESS)
|
|
|
|
|
return result;
|
|
|
|
|
|
|
|
|
|
if (bo)
|
|
|
|
|
radv_rmv_log_sparse_add_residency(device, parent, offset);
|
|
|
|
|
else
|
|
|
|
|
radv_rmv_log_sparse_remove_residency(device, parent, offset);
|
|
|
|
|
|
2023-01-16 17:04:47 +01:00
|
|
|
vk_address_binding_report(&instance->vk, object, radv_buffer_get_va(parent) + offset, size,
|
|
|
|
|
bo ? VK_DEVICE_ADDRESS_BINDING_TYPE_BIND_EXT : VK_DEVICE_ADDRESS_BINDING_TYPE_UNBIND_EXT);
|
|
|
|
|
|
2024-03-25 16:49:36 +01:00
|
|
|
return VK_SUCCESS;
|
|
|
|
|
}
|
2024-11-29 09:46:36 +01:00
|
|
|
|
|
|
|
|
VkResult
|
|
|
|
|
radv_bo_from_fd(struct radv_device *device, int fd, unsigned priority, struct radv_device_memory *mem,
|
|
|
|
|
uint64_t *alloc_size)
|
|
|
|
|
{
|
|
|
|
|
struct radv_physical_device *pdev = radv_device_physical(device);
|
|
|
|
|
struct radv_instance *instance = radv_physical_device_instance(pdev);
|
|
|
|
|
struct radeon_winsys *ws = device->ws;
|
|
|
|
|
VkResult result;
|
|
|
|
|
|
|
|
|
|
result = ws->buffer_from_fd(ws, fd, priority, &mem->bo, alloc_size);
|
|
|
|
|
if (result != VK_SUCCESS)
|
|
|
|
|
return result;
|
|
|
|
|
|
|
|
|
|
vk_address_binding_report(&instance->vk, &mem->base, radv_buffer_get_va(mem->bo), mem->bo->size,
|
|
|
|
|
VK_DEVICE_ADDRESS_BINDING_TYPE_BIND_EXT);
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
2024-11-29 09:52:02 +01:00
|
|
|
|
|
|
|
|
VkResult
|
|
|
|
|
radv_bo_from_ptr(struct radv_device *device, void *host_ptr, uint64_t alloc_size, unsigned priority,
|
|
|
|
|
struct radv_device_memory *mem)
|
|
|
|
|
{
|
|
|
|
|
struct radv_physical_device *pdev = radv_device_physical(device);
|
|
|
|
|
struct radv_instance *instance = radv_physical_device_instance(pdev);
|
|
|
|
|
struct radeon_winsys *ws = device->ws;
|
|
|
|
|
VkResult result;
|
|
|
|
|
|
|
|
|
|
result = ws->buffer_from_ptr(ws, host_ptr, alloc_size, priority, &mem->bo);
|
|
|
|
|
if (result != VK_SUCCESS)
|
|
|
|
|
return result;
|
|
|
|
|
|
|
|
|
|
vk_address_binding_report(&instance->vk, &mem->base, radv_buffer_get_va(mem->bo), mem->bo->size,
|
|
|
|
|
VK_DEVICE_ADDRESS_BINDING_TYPE_BIND_EXT);
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|