vk: Define struct anv_image_view, anv_buffer_view
Follow the pattern of anv_attachment_view. We need these structs to implement the type-safety that arrived in the 0.132 header.
This commit is contained in:
parent
43241a24bc
commit
8213be790e
|
@ -1722,15 +1722,17 @@ VkResult anv_CreateBufferView(
|
|||
{
|
||||
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 =
|
||||
|
@ -1741,20 +1743,20 @@ VkResult anv_CreateBufferView(
|
|||
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;
|
||||
}
|
||||
|
@ -2131,8 +2133,9 @@ VkResult anv_UpdateDescriptorSets(
|
|||
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;
|
||||
|
||||
|
@ -2150,8 +2153,9 @@ VkResult anv_UpdateDescriptorSets(
|
|||
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:
|
||||
|
|
|
@ -333,13 +333,15 @@ anv_surface_view_fini(struct anv_device *device,
|
|||
}
|
||||
|
||||
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 =
|
||||
|
@ -537,7 +539,7 @@ anv_CreateImageView(VkDevice _device,
|
|||
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);
|
||||
|
@ -546,19 +548,19 @@ anv_CreateImageView(VkDevice _device,
|
|||
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -762,7 +762,7 @@ do_buffer_copy(struct anv_cmd_buffer *cmd_buffer,
|
|||
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,
|
||||
|
@ -798,7 +798,7 @@ do_buffer_copy(struct anv_cmd_buffer *cmd_buffer,
|
|||
cmd_buffer);
|
||||
|
||||
meta_emit_blit(cmd_buffer,
|
||||
&src_view,
|
||||
&src_view.view,
|
||||
(VkOffset3D) { 0, 0, 0 },
|
||||
(VkExtent3D) { width, height, 1 },
|
||||
&dest_view,
|
||||
|
@ -902,7 +902,7 @@ void anv_CmdCopyImage(
|
|||
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,
|
||||
|
@ -938,7 +938,7 @@ void anv_CmdCopyImage(
|
|||
cmd_buffer);
|
||||
|
||||
meta_emit_blit(cmd_buffer,
|
||||
&src_view,
|
||||
&src_view.view,
|
||||
pRegions[r].srcOffset,
|
||||
pRegions[r].extent,
|
||||
&dest_view,
|
||||
|
@ -970,7 +970,7 @@ void anv_CmdBlitImage(
|
|||
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,
|
||||
|
@ -1006,7 +1006,7 @@ void anv_CmdBlitImage(
|
|||
cmd_buffer);
|
||||
|
||||
meta_emit_blit(cmd_buffer,
|
||||
&src_view,
|
||||
&src_view.view,
|
||||
pRegions[r].srcOffset,
|
||||
pRegions[r].srcExtent,
|
||||
&dest_view,
|
||||
|
@ -1066,7 +1066,7 @@ void anv_CmdCopyBufferToImage(
|
|||
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,
|
||||
|
@ -1102,7 +1102,7 @@ void anv_CmdCopyBufferToImage(
|
|||
cmd_buffer);
|
||||
|
||||
meta_emit_blit(cmd_buffer,
|
||||
&src_view,
|
||||
&src_view.view,
|
||||
(VkOffset3D) { 0, 0, 0 },
|
||||
pRegions[r].imageExtent,
|
||||
&dest_view,
|
||||
|
@ -1137,7 +1137,7 @@ void anv_CmdCopyImageToBuffer(
|
|||
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,
|
||||
|
@ -1200,7 +1200,7 @@ void anv_CmdCopyImageToBuffer(
|
|||
cmd_buffer);
|
||||
|
||||
meta_emit_blit(cmd_buffer,
|
||||
&src_view,
|
||||
&src_view.view,
|
||||
pRegions[r].imageOffset,
|
||||
pRegions[r].imageExtent,
|
||||
&dest_view,
|
||||
|
|
|
@ -854,6 +854,15 @@ struct anv_surface_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,
|
||||
|
@ -894,7 +903,7 @@ VkResult anv_image_create(VkDevice _device,
|
|||
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);
|
||||
|
@ -995,6 +1004,8 @@ ANV_DEFINE_CASTS(anv_pipeline, VkPipeline)
|
|||
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)
|
||||
|
|
Loading…
Reference in New Issue