vk/image: Add explicit constructors for buffer/image view types

This commit is contained in:
Jason Ekstrand 2015-07-10 12:25:30 -07:00
parent 18340883e3
commit b94b8dfad5
3 changed files with 62 additions and 20 deletions

View File

@ -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(

View File

@ -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,13 +666,21 @@ 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,
@ -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;
}

View File

@ -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) \