aboutsummaryrefslogtreecommitdiffstats
path: root/src/amd/vulkan
diff options
context:
space:
mode:
authorBas Nieuwenhuizen <[email protected]>2017-02-04 15:56:20 +0100
committerBas Nieuwenhuizen <[email protected]>2017-03-29 08:50:37 +0200
commit6154efc1931a8ac581991e9b1103201590b590ca (patch)
tree797b616cffb0c8cf6953d841a133adf5a687c23a /src/amd/vulkan
parentef0e505d027d1d4366d9375a2d8a692eb7f89473 (diff)
radv: Implement sparse image creation.
Signed-off-by: Bas Nieuwenhuizen <[email protected]> Reviewed-by: Dave Airlie <[email protected]>
Diffstat (limited to 'src/amd/vulkan')
-rw-r--r--src/amd/vulkan/radv_image.c23
-rw-r--r--src/amd/vulkan/radv_private.h1
2 files changed, 22 insertions, 2 deletions
diff --git a/src/amd/vulkan/radv_image.c b/src/amd/vulkan/radv_image.c
index dfd70a9eab8..3997e81acc1 100644
--- a/src/amd/vulkan/radv_image.c
+++ b/src/amd/vulkan/radv_image.c
@@ -636,6 +636,7 @@ radv_image_create(VkDevice _device,
image->samples = pCreateInfo->samples;
image->tiling = pCreateInfo->tiling;
image->usage = pCreateInfo->usage;
+ image->flags = pCreateInfo->flags;
image->exclusive = pCreateInfo->sharingMode == VK_SHARING_MODE_EXCLUSIVE;
if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) {
@@ -676,6 +677,20 @@ radv_image_create(VkDevice _device,
image->surface.level[0].pitch_bytes = create_info->stride;
image->surface.level[0].slice_size = create_info->stride * image->surface.level[0].nblk_y;
}
+
+ if (pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) {
+ image->alignment = MAX2(image->alignment, 4096);
+ image->size = align64(image->size, image->alignment);
+ image->offset = 0;
+
+ image->bo = device->ws->buffer_create(device->ws, image->size, image->alignment,
+ 0, RADEON_FLAG_VIRTUAL);
+ if (!image->bo) {
+ vk_free2(&device->alloc, alloc, image);
+ return vk_error(VK_ERROR_OUT_OF_DEVICE_MEMORY);
+ }
+ }
+
*pImage = radv_image_to_handle(image);
return VK_SUCCESS;
@@ -872,11 +887,15 @@ radv_DestroyImage(VkDevice _device, VkImage _image,
const VkAllocationCallbacks *pAllocator)
{
RADV_FROM_HANDLE(radv_device, device, _device);
+ RADV_FROM_HANDLE(radv_image, image, _image);
- if (!_image)
+ if (!image)
return;
- vk_free2(&device->alloc, pAllocator, radv_image_from_handle(_image));
+ if (image->flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT)
+ device->ws->buffer_destroy(image->bo);
+
+ vk_free2(&device->alloc, pAllocator, image);
}
void radv_GetImageSubresourceLayout(
diff --git a/src/amd/vulkan/radv_private.h b/src/amd/vulkan/radv_private.h
index c5b00f29f1f..31e08287c9c 100644
--- a/src/amd/vulkan/radv_private.h
+++ b/src/amd/vulkan/radv_private.h
@@ -1070,6 +1070,7 @@ struct radv_image {
uint32_t samples; /**< VkImageCreateInfo::samples */
VkImageUsageFlags usage; /**< Superset of VkImageCreateInfo::usage. */
VkImageTiling tiling; /** VkImageCreateInfo::tiling */
+ VkImageCreateFlags flags; /** VkImageCreateInfo::flags */
VkDeviceSize size;
uint32_t alignment;