From: Jason Ekstrand Date: Tue, 9 Jun 2015 18:08:03 +0000 (-0700) Subject: vk/surface_view: Add a destructor X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=9d6f55dedf92697d551b699e3fe52389b5fb9c27;p=mesa.git vk/surface_view: Add a destructor --- 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 @@ -162,6 +162,21 @@ VkResult anv_GetImageSubresourceInfo( stub_return(VK_UNSUPPORTED); } +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, @@ -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]; };