diff options
author | Jason Ekstrand <[email protected]> | 2015-07-10 12:25:30 -0700 |
---|---|---|
committer | Jason Ekstrand <[email protected]> | 2015-07-10 12:26:31 -0700 |
commit | b94b8dfad5ca8168db0436721100254d2e61b4b7 (patch) | |
tree | c1141321eafc74f4ed553f992adf73bfddb9d1d2 /src/vulkan | |
parent | 18340883e3c9736db5ed319dfb036af00c39ba82 (diff) |
vk/image: Add explicit constructors for buffer/image view types
Diffstat (limited to 'src/vulkan')
-rw-r--r-- | src/vulkan/device.c | 29 | ||||
-rw-r--r-- | src/vulkan/image.c | 43 | ||||
-rw-r--r-- | src/vulkan/private.h | 10 |
3 files changed, 62 insertions, 20 deletions
diff --git a/src/vulkan/device.c b/src/vulkan/device.c index 312105a946d..e9c3eebea96 100644 --- a/src/vulkan/device.c +++ b/src/vulkan/device.c @@ -1159,9 +1159,20 @@ VkResult anv_DestroyObject( /* These are just dummys anyway, so we don't need to destroy them */ return VK_SUCCESS; + case VK_OBJECT_TYPE_BUFFER_VIEW: + return anv_DestroyBufferView(_device, _object); + + case VK_OBJECT_TYPE_IMAGE_VIEW: + return anv_DestroyImageView(_device, _object); + + case VK_OBJECT_TYPE_COLOR_ATTACHMENT_VIEW: + return anv_DestroyColorAttachmentView(_device, _object); + + case VK_OBJECT_TYPE_DEPTH_STENCIL_VIEW: + return anv_DestroyDepthStencilView(_device, _object); + case VK_OBJECT_TYPE_BUFFER: case VK_OBJECT_TYPE_IMAGE: - case VK_OBJECT_TYPE_DEPTH_STENCIL_VIEW: case VK_OBJECT_TYPE_SHADER: case VK_OBJECT_TYPE_SHADER_MODULE: case VK_OBJECT_TYPE_PIPELINE_LAYOUT: @@ -1182,9 +1193,6 @@ 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; @@ -1571,8 +1579,6 @@ 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 = @@ -1588,6 +1594,17 @@ VkResult anv_CreateBufferView( return VK_SUCCESS; } +VkResult anv_DestroyBufferView( + VkDevice _device, + VkBufferView _view) +{ + ANV_FROM_HANDLE(anv_device, device, _device); + + anv_surface_view_destroy(device, (struct anv_surface_view *)_view); + + return VK_SUCCESS; +} + // Sampler functions VkResult anv_CreateSampler( diff --git a/src/vulkan/image.c b/src/vulkan/image.c index d63ae1dfed8..5f82ed369cb 100644 --- a/src/vulkan/image.c +++ b/src/vulkan/image.c @@ -317,14 +317,8 @@ VkResult anv_GetImageSubresourceLayout( 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 *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); @@ -544,13 +538,21 @@ anv_CreateImageView(VkDevice _device, anv_image_view_init(view, device, pCreateInfo, NULL); - view->base.destructor = anv_surface_view_destroy; - *pView = (VkImageView) view; return VK_SUCCESS; } +VkResult +anv_DestroyImageView(VkDevice _device, VkImageView _view) +{ + ANV_FROM_HANDLE(anv_device, device, _device); + + anv_surface_view_destroy(device, (struct anv_surface_view *)_view); + + return VK_SUCCESS; +} + void anv_color_attachment_view_init(struct anv_surface_view *view, struct anv_device *device, @@ -664,14 +666,22 @@ anv_CreateColorAttachmentView(VkDevice _device, anv_color_attachment_view_init(view, device, pCreateInfo, NULL); - view->base.destructor = anv_surface_view_destroy; - *pView = (VkColorAttachmentView) view; return VK_SUCCESS; } VkResult +anv_DestroyColorAttachmentView(VkDevice _device, VkColorAttachmentView _view) +{ + ANV_FROM_HANDLE(anv_device, device, _device); + + anv_surface_view_destroy(device, (struct anv_surface_view *)_view); + + return VK_SUCCESS; +} + +VkResult anv_CreateDepthStencilView(VkDevice _device, const VkDepthStencilViewCreateInfo *pCreateInfo, VkDepthStencilView *pView) @@ -711,3 +721,14 @@ anv_CreateDepthStencilView(VkDevice _device, return VK_SUCCESS; } + +VkResult +anv_DestroyDepthStencilView(VkDevice _device, VkDepthStencilView _view) +{ + ANV_FROM_HANDLE(anv_device, device, _device); + ANV_FROM_HANDLE(anv_depth_stencil_view, view, _view); + + anv_device_free(device, view); + + return VK_SUCCESS; +} diff --git a/src/vulkan/private.h b/src/vulkan/private.h index ef4b183056e..91f3e50b5d8 100644 --- a/src/vulkan/private.h +++ b/src/vulkan/private.h @@ -857,8 +857,6 @@ struct anv_image { }; struct anv_surface_view { - struct anv_object base; - struct anv_state surface_state; struct anv_bo * bo; uint32_t offset; @@ -888,7 +886,7 @@ void anv_color_attachment_view_init(struct anv_surface_view *view, struct anv_cmd_buffer *cmd_buffer); void anv_surface_view_destroy(struct anv_device *device, - struct anv_object *obj, VkObjectType obj_type); + struct anv_surface_view *view); struct anv_sampler { uint32_t state[4]; @@ -945,6 +943,12 @@ anv_cmd_buffer_clear(struct anv_cmd_buffer *cmd_buffer, void * anv_lookup_entrypoint(const char *name); +VkResult anv_DestroyImageView(VkDevice device, VkImageView imageView); +VkResult anv_DestroyBufferView(VkDevice device, VkBufferView bufferView); +VkResult anv_DestroyColorAttachmentView(VkDevice device, + VkColorAttachmentView view); +VkResult anv_DestroyDepthStencilView(VkDevice device, VkDepthStencilView view); + #define ANV_DEFINE_CASTS(__anv_type, __VkType) \ static inline struct __anv_type * \ __anv_type ## _from_handle(__VkType _handle) \ |