{
ANV_FROM_HANDLE(anv_device, device, _device);
ANV_FROM_HANDLE(anv_buffer, buffer, pCreateInfo->buffer);
+ struct anv_buffer_view *bview;
struct anv_surface_view *view;
assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_BUFFER_VIEW_CREATE_INFO);
- view = anv_device_alloc(device, sizeof(*view), 8,
- VK_SYSTEM_ALLOC_TYPE_API_OBJECT);
- if (view == NULL)
+ bview = anv_device_alloc(device, sizeof(*view), 8,
+ VK_SYSTEM_ALLOC_TYPE_API_OBJECT);
+ if (bview == NULL)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
+ view = &bview->view;
view->bo = buffer->bo;
view->offset = buffer->offset + pCreateInfo->offset;
view->surface_state =
fill_buffer_surface_state(view->surface_state.map,
pCreateInfo->format, view->offset, pCreateInfo->range);
- *pView = (VkBufferView) view;
+ *pView = anv_buffer_view_to_handle(bview);
return VK_SUCCESS;
}
VkResult anv_DestroyBufferView(
VkDevice _device,
- VkBufferView _view)
+ VkBufferView _bview)
{
ANV_FROM_HANDLE(anv_device, device, _device);
- struct anv_surface_view *view = (struct anv_surface_view *)_view;
+ ANV_FROM_HANDLE(anv_buffer_view, bview, _bview);
- anv_surface_view_fini(device, view);
- anv_device_free(device, view);
+ anv_surface_view_fini(device, &bview->view);
+ anv_device_free(device, bview);
return VK_SUCCESS;
}
case VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE:
case VK_DESCRIPTOR_TYPE_STORAGE_IMAGE:
for (uint32_t j = 0; j < write->count; j++) {
- set->descriptors[write->destBinding + j].view =
- (struct anv_surface_view *)write->pDescriptors[j].imageView;
+ ANV_FROM_HANDLE(anv_image_view, iview,
+ write->pDescriptors[j].imageView);
+ set->descriptors[write->destBinding + j].view = &iview->view;
}
break;
case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC:
case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC:
for (uint32_t j = 0; j < write->count; j++) {
- set->descriptors[write->destBinding + j].view =
- (struct anv_surface_view *)write->pDescriptors[j].bufferView;
+ ANV_FROM_HANDLE(anv_buffer_view, bview,
+ write->pDescriptors[j].bufferView);
+ set->descriptors[write->destBinding + j].view = &bview->view;
}
default:
}
void
-anv_image_view_init(struct anv_surface_view *view,
+anv_image_view_init(struct anv_image_view *iview,
struct anv_device *device,
const VkImageViewCreateInfo* pCreateInfo,
struct anv_cmd_buffer *cmd_buffer)
{
ANV_FROM_HANDLE(anv_image, image, pCreateInfo->image);
+
const VkImageSubresourceRange *range = &pCreateInfo->subresourceRange;
+ struct anv_surface_view *view = &iview->view;
struct anv_surface *surface;
const struct anv_format *format_info =
VkImageView *pView)
{
ANV_FROM_HANDLE(anv_device, device, _device);
- struct anv_surface_view *view;
+ struct anv_image_view *view;
view = anv_device_alloc(device, sizeof(*view), 8,
VK_SYSTEM_ALLOC_TYPE_API_OBJECT);
anv_image_view_init(view, device, pCreateInfo, NULL);
- *pView = (VkImageView) view;
+ *pView = anv_image_view_to_handle(view);
return VK_SUCCESS;
}
VkResult
-anv_DestroyImageView(VkDevice _device, VkImageView _view)
+anv_DestroyImageView(VkDevice _device, VkImageView _iview)
{
ANV_FROM_HANDLE(anv_device, device, _device);
- struct anv_surface_view *view = (struct anv_surface_view *)_view;
+ ANV_FROM_HANDLE(anv_image_view, iview, _iview);
- anv_surface_view_fini(device, view);
- anv_device_free(device, view);
+ anv_surface_view_fini(device, &iview->view);
+ anv_device_free(device, iview);
return VK_SUCCESS;
}
anv_image_from_handle(dest_image)->bo = dest;
anv_image_from_handle(dest_image)->offset = dest_offset;
- struct anv_surface_view src_view;
+ struct anv_image_view src_view;
anv_image_view_init(&src_view, cmd_buffer->device,
&(VkImageViewCreateInfo) {
.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
cmd_buffer);
meta_emit_blit(cmd_buffer,
- &src_view,
+ &src_view.view,
(VkOffset3D) { 0, 0, 0 },
(VkExtent3D) { width, height, 1 },
&dest_view,
meta_prepare_blit(cmd_buffer, &saved_state);
for (unsigned r = 0; r < regionCount; r++) {
- struct anv_surface_view src_view;
+ struct anv_image_view src_view;
anv_image_view_init(&src_view, cmd_buffer->device,
&(VkImageViewCreateInfo) {
.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
cmd_buffer);
meta_emit_blit(cmd_buffer,
- &src_view,
+ &src_view.view,
pRegions[r].srcOffset,
pRegions[r].extent,
&dest_view,
meta_prepare_blit(cmd_buffer, &saved_state);
for (unsigned r = 0; r < regionCount; r++) {
- struct anv_surface_view src_view;
+ struct anv_image_view src_view;
anv_image_view_init(&src_view, cmd_buffer->device,
&(VkImageViewCreateInfo) {
.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
cmd_buffer);
meta_emit_blit(cmd_buffer,
- &src_view,
+ &src_view.view,
pRegions[r].srcOffset,
pRegions[r].srcExtent,
&dest_view,
src_image->bo = src_buffer->bo;
src_image->offset = src_buffer->offset + pRegions[r].bufferOffset;
- struct anv_surface_view src_view;
+ struct anv_image_view src_view;
anv_image_view_init(&src_view, cmd_buffer->device,
&(VkImageViewCreateInfo) {
.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
cmd_buffer);
meta_emit_blit(cmd_buffer,
- &src_view,
+ &src_view.view,
(VkOffset3D) { 0, 0, 0 },
pRegions[r].imageExtent,
&dest_view,
if (pRegions[r].bufferImageHeight != 0)
anv_finishme("bufferImageHeight not supported in CopyBufferToImage");
- struct anv_surface_view src_view;
+ struct anv_image_view src_view;
anv_image_view_init(&src_view, cmd_buffer->device,
&(VkImageViewCreateInfo) {
.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
cmd_buffer);
meta_emit_blit(cmd_buffer,
- &src_view,
+ &src_view.view,
pRegions[r].imageOffset,
pRegions[r].imageExtent,
&dest_view,
VkFormat format;
};
+struct anv_buffer_view {
+ /* FINISHME: Trim unneeded data from this struct. */
+ struct anv_surface_view view;
+};
+
+struct anv_image_view {
+ struct anv_surface_view view;
+};
+
enum anv_attachment_view_type {
ANV_ATTACHMENT_VIEW_TYPE_COLOR,
ANV_ATTACHMENT_VIEW_TYPE_DEPTH_STENCIL,
const struct anv_image_create_info *info,
VkImage *pImage);
-void anv_image_view_init(struct anv_surface_view *view,
+void anv_image_view_init(struct anv_image_view *view,
struct anv_device *device,
const VkImageViewCreateInfo* pCreateInfo,
struct anv_cmd_buffer *cmd_buffer);
ANV_DEFINE_CASTS(anv_image, VkImage)
ANV_DEFINE_CASTS(anv_sampler, VkSampler)
ANV_DEFINE_CASTS(anv_attachment_view, VkAttachmentView)
+ANV_DEFINE_CASTS(anv_buffer_view, VkBufferView);
+ANV_DEFINE_CASTS(anv_image_view, VkImageView);
ANV_DEFINE_CASTS(anv_framebuffer, VkFramebuffer)
ANV_DEFINE_CASTS(anv_render_pass, VkRenderPass)
ANV_DEFINE_CASTS(anv_query_pool, VkQueryPool)