summaryrefslogtreecommitdiffstats
path: root/src/amd
diff options
context:
space:
mode:
authorBas Nieuwenhuizen <[email protected]>2017-02-04 11:15:59 +0100
committerBas Nieuwenhuizen <[email protected]>2017-03-29 08:50:33 +0200
commitef0e505d027d1d4366d9375a2d8a692eb7f89473 (patch)
treec6c65c31b7d6671755712421fcedf5b7d7fe2ef3 /src/amd
parent715df30a4e27a76917d6172e68fd7f4c3ff1fb9d (diff)
radv: Implement sparse buffer creation.
Signed-off-by: Bas Nieuwenhuizen <[email protected]> Reviewed-by: Dave Airlie <[email protected]>
Diffstat (limited to 'src/amd')
-rw-r--r--src/amd/vulkan/radv_device.c22
-rw-r--r--src/amd/vulkan/radv_private.h1
2 files changed, 21 insertions, 2 deletions
diff --git a/src/amd/vulkan/radv_device.c b/src/amd/vulkan/radv_device.c
index dcef1da7e3c..adcc63a8172 100644
--- a/src/amd/vulkan/radv_device.c
+++ b/src/amd/vulkan/radv_device.c
@@ -1881,8 +1881,12 @@ void radv_GetBufferMemoryRequirements(
pMemoryRequirements->memoryTypeBits = (1u << RADV_MEM_TYPE_COUNT) - 1;
- pMemoryRequirements->size = buffer->size;
- pMemoryRequirements->alignment = 16;
+ if (buffer->flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT)
+ pMemoryRequirements->alignment = 4096;
+ else
+ pMemoryRequirements->alignment = 16;
+
+ pMemoryRequirements->size = align64(buffer->size, pMemoryRequirements->alignment);
}
void radv_GetImageMemoryRequirements(
@@ -2208,6 +2212,17 @@ VkResult radv_CreateBuffer(
buffer->usage = pCreateInfo->usage;
buffer->bo = NULL;
buffer->offset = 0;
+ buffer->flags = pCreateInfo->flags;
+
+ if (pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT) {
+ buffer->bo = device->ws->buffer_create(device->ws,
+ align64(buffer->size, 4096),
+ 4096, 0, RADEON_FLAG_VIRTUAL);
+ if (!buffer->bo) {
+ vk_free2(&device->alloc, pAllocator, buffer);
+ return vk_error(VK_ERROR_OUT_OF_DEVICE_MEMORY);
+ }
+ }
*pBuffer = radv_buffer_to_handle(buffer);
@@ -2225,6 +2240,9 @@ void radv_DestroyBuffer(
if (!buffer)
return;
+ if (buffer->flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT)
+ device->ws->buffer_destroy(buffer->bo);
+
vk_free2(&device->alloc, pAllocator, buffer);
}
diff --git a/src/amd/vulkan/radv_private.h b/src/amd/vulkan/radv_private.h
index f587ee3ffd8..c5b00f29f1f 100644
--- a/src/amd/vulkan/radv_private.h
+++ b/src/amd/vulkan/radv_private.h
@@ -557,6 +557,7 @@ struct radv_buffer {
VkDeviceSize size;
VkBufferUsageFlags usage;
+ VkBufferCreateFlags flags;
/* Set when bound */
struct radeon_winsys_bo * bo;