diff options
author | Jason Ekstrand <[email protected]> | 2015-06-09 11:08:03 -0700 |
---|---|---|
committer | Jason Ekstrand <[email protected]> | 2015-06-09 12:36:23 -0700 |
commit | 9d6f55dedf92697d551b699e3fe52389b5fb9c27 (patch) | |
tree | 22fd49e24303d10f6baa5b04eb82e674ce2dffb2 /src | |
parent | e6162c2feff6dee48cd5c1e99e2fe70b5ce07f9f (diff) |
vk/surface_view: Add a destructor
Diffstat (limited to 'src')
-rw-r--r-- | src/vulkan/device.c | 8 | ||||
-rw-r--r-- | src/vulkan/image.c | 19 | ||||
-rw-r--r-- | src/vulkan/private.h | 5 |
3 files changed, 29 insertions, 3 deletions
diff --git a/src/vulkan/device.c b/src/vulkan/device.c index 46c6b10c401..acb0822c3df 100644 --- a/src/vulkan/device.c +++ b/src/vulkan/device.c @@ -1080,10 +1080,7 @@ VkResult anv_DestroyObject( return VK_SUCCESS; case VK_OBJECT_TYPE_BUFFER: - case VK_OBJECT_TYPE_BUFFER_VIEW: case VK_OBJECT_TYPE_IMAGE: - case VK_OBJECT_TYPE_IMAGE_VIEW: - case VK_OBJECT_TYPE_COLOR_ATTACHMENT_VIEW: case VK_OBJECT_TYPE_DEPTH_STENCIL_VIEW: case VK_OBJECT_TYPE_SHADER: case VK_OBJECT_TYPE_PIPELINE_LAYOUT: @@ -1104,6 +1101,9 @@ VkResult anv_DestroyObject( case VK_OBJECT_TYPE_FENCE: case VK_OBJECT_TYPE_QUERY_POOL: case VK_OBJECT_TYPE_FRAMEBUFFER: + case VK_OBJECT_TYPE_BUFFER_VIEW: + case VK_OBJECT_TYPE_IMAGE_VIEW: + case VK_OBJECT_TYPE_COLOR_ATTACHMENT_VIEW: (object->destructor)(device, object, objType); return VK_SUCCESS; @@ -1542,6 +1542,8 @@ VkResult anv_CreateBufferView( if (view == NULL) return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY); + view->base.destructor = anv_surface_view_destroy; + view->bo = buffer->bo; view->offset = buffer->offset + pCreateInfo->offset; view->surface_state = diff --git a/src/vulkan/image.c b/src/vulkan/image.c index 529f7ad9774..83f4a1bf0cb 100644 --- a/src/vulkan/image.c +++ b/src/vulkan/image.c @@ -163,6 +163,21 @@ VkResult anv_GetImageSubresourceInfo( } void +anv_surface_view_destroy(struct anv_device *device, + struct anv_object *obj, VkObjectType obj_type) +{ + struct anv_surface_view *view = (struct anv_surface_view *)obj; + + assert(obj_type == VK_OBJECT_TYPE_BUFFER_VIEW || + obj_type == VK_OBJECT_TYPE_IMAGE_VIEW || + obj_type == VK_OBJECT_TYPE_COLOR_ATTACHMENT_VIEW); + + anv_state_pool_free(&device->surface_state_pool, view->surface_state); + + anv_device_free(device, view); +} + +void anv_image_view_init(struct anv_surface_view *view, struct anv_device *device, const VkImageViewCreateInfo* pCreateInfo, @@ -268,6 +283,8 @@ VkResult anv_CreateImageView( anv_image_view_init(view, device, pCreateInfo, NULL); + view->base.destructor = anv_surface_view_destroy; + *pView = (VkImageView) view; return VK_SUCCESS; @@ -352,6 +369,8 @@ VkResult anv_CreateColorAttachmentView( anv_color_attachment_view_init(view, device, pCreateInfo, NULL); + view->base.destructor = anv_surface_view_destroy; + *pView = (VkColorAttachmentView) view; return VK_SUCCESS; diff --git a/src/vulkan/private.h b/src/vulkan/private.h index 794449c27c6..05016d21792 100644 --- a/src/vulkan/private.h +++ b/src/vulkan/private.h @@ -756,6 +756,8 @@ struct anv_image { }; struct anv_surface_view { + struct anv_object base; + struct anv_state surface_state; struct anv_bo * bo; uint32_t offset; @@ -783,6 +785,9 @@ void anv_color_attachment_view_init(struct anv_surface_view *view, const VkColorAttachmentViewCreateInfo* pCreateInfo, struct anv_cmd_buffer *cmd_buffer); +void anv_surface_view_destroy(struct anv_device *device, + struct anv_object *obj, VkObjectType obj_type); + struct anv_sampler { uint32_t state[4]; }; |