This prepares for merging VkAttachmentView into VkImageView.
* put the color attachments into the binding table.
*/
for (uint32_t a = 0; a < attachments; a++) {
- const struct anv_attachment_view *aview =
+ const struct anv_image_view *iview =
fb->attachments[subpass->color_attachments[a]];
- const struct anv_image_view *iview = &aview->image_view;
-
- assert(aview->attachment_type == ANV_ATTACHMENT_VIEW_TYPE_COLOR);
bt_map[a] = iview->surface_state.offset + state_offset;
add_surface_state_reloc(cmd_buffer, iview->surface_state,
/**
* Return NULL if the current subpass has no depthstencil attachment.
*/
-const struct anv_attachment_view *
+const struct anv_image_view *
anv_cmd_buffer_get_depth_stencil_view(const struct anv_cmd_buffer *cmd_buffer)
{
const struct anv_subpass *subpass = cmd_buffer->state.subpass;
if (subpass->depth_stencil_attachment == VK_ATTACHMENT_UNUSED)
return NULL;
- const struct anv_attachment_view *aview =
+ const struct anv_image_view *iview =
fb->attachments[subpass->depth_stencil_attachment];
- assert(aview->attachment_type == ANV_ATTACHMENT_VIEW_TYPE_DEPTH_STENCIL);
+ assert(anv_format_is_depth_or_stencil(iview->format));
- return aview;
+ return iview;
}
assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO);
size_t size = sizeof(*framebuffer) +
- sizeof(struct anv_attachment_view *) * pCreateInfo->attachmentCount;
+ sizeof(struct anv_image_view *) * pCreateInfo->attachmentCount;
framebuffer = anv_device_alloc(device, size, 8,
VK_SYSTEM_ALLOC_TYPE_API_OBJECT);
if (framebuffer == NULL)
framebuffer->attachment_count = pCreateInfo->attachmentCount;
for (uint32_t i = 0; i < pCreateInfo->attachmentCount; i++) {
- ANV_FROM_HANDLE(anv_attachment_view, aview,
- pCreateInfo->pAttachments[i].view);
-
- framebuffer->attachments[i] = aview;
+ VkAttachmentView _aview = pCreateInfo->pAttachments[i].view;
+ VkImageView _iview = { _aview.handle };
+ framebuffer->attachments[i] = anv_image_view_from_handle(_iview);
}
framebuffer->width = pCreateInfo->width;
return VK_SUCCESS;
}
-static void
-anv_image_view_fini(struct anv_device *device,
- struct anv_image_view *iview)
-{
- anv_state_pool_free(&device->surface_state_pool, iview->surface_state);
-}
-
void
anv_DestroyImageView(VkDevice _device, VkImageView _iview)
{
ANV_FROM_HANDLE(anv_device, device, _device);
ANV_FROM_HANDLE(anv_image_view, iview, _iview);
- anv_image_view_fini(device, iview);
+ anv_state_pool_free(&device->surface_state_pool, iview->surface_state);
anv_device_free(device, iview);
}
static void
-anv_depth_stencil_view_init(struct anv_attachment_view *aview,
+anv_depth_stencil_view_init(struct anv_image_view *iview,
const VkAttachmentViewCreateInfo *pCreateInfo)
{
ANV_FROM_HANDLE(anv_image, image, pCreateInfo->image);
- aview->attachment_type = ANV_ATTACHMENT_VIEW_TYPE_DEPTH_STENCIL;
-
/* XXX: We don't handle any of these */
anv_assert(pCreateInfo->mipLevel == 0);
anv_assert(pCreateInfo->baseArraySlice == 0);
anv_assert(pCreateInfo->arraySize == 1);
- aview->image_view.image = image;
- aview->image_view.format = anv_format_for_vk_format(pCreateInfo->format);
+ iview->image = image;
+ iview->format = anv_format_for_vk_format(pCreateInfo->format);
assert(anv_format_is_depth_or_stencil(image->format));
- assert(anv_format_is_depth_or_stencil(aview->image_view.format));
+ assert(anv_format_is_depth_or_stencil(iview->format));
}
struct anv_surface *
}
void
-anv_color_attachment_view_init(struct anv_attachment_view *aview,
+anv_color_attachment_view_init(struct anv_image_view *iview,
struct anv_device *device,
const VkAttachmentViewCreateInfo* pCreateInfo,
struct anv_cmd_buffer *cmd_buffer)
{
switch (device->info.gen) {
case 7:
- gen7_color_attachment_view_init(aview, device, pCreateInfo, cmd_buffer);
+ gen7_color_attachment_view_init(iview, device, pCreateInfo, cmd_buffer);
break;
case 8:
- gen8_color_attachment_view_init(aview, device, pCreateInfo, cmd_buffer);
+ gen8_color_attachment_view_init(iview, device, pCreateInfo, cmd_buffer);
break;
default:
unreachable("unsupported gen\n");
VkAttachmentView *pView)
{
ANV_FROM_HANDLE(anv_device, device, _device);
- struct anv_attachment_view *aview;
+ struct anv_image_view *iview;
assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_ATTACHMENT_VIEW_CREATE_INFO);
- aview = anv_device_alloc(device, sizeof(*aview), 8,
+ iview = anv_device_alloc(device, sizeof(*iview), 8,
VK_SYSTEM_ALLOC_TYPE_API_OBJECT);
- if (aview == NULL)
+ if (iview == NULL)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
const struct anv_format *format =
anv_format_for_vk_format(pCreateInfo->format);
if (anv_format_is_depth_or_stencil(format)) {
- anv_depth_stencil_view_init(aview, pCreateInfo);
+ anv_depth_stencil_view_init(iview, pCreateInfo);
} else {
- anv_color_attachment_view_init(aview, device, pCreateInfo, NULL);
+ anv_color_attachment_view_init(iview, device, pCreateInfo, NULL);
}
- *pView = anv_attachment_view_to_handle(aview);
+ pView->handle = anv_image_view_to_handle(iview).handle;
return VK_SUCCESS;
}
anv_DestroyAttachmentView(VkDevice _device, VkAttachmentView _aview)
{
ANV_FROM_HANDLE(anv_device, device, _device);
- ANV_FROM_HANDLE(anv_attachment_view, aview, _aview);
+ VkImageView _iview = { .handle = _aview.handle };
+ ANV_FROM_HANDLE(anv_image_view, iview, _iview);
- if (aview->attachment_type == ANV_ATTACHMENT_VIEW_TYPE_COLOR) {
- anv_image_view_fini(device, &aview->image_view);
+ /* Depth and stencil render targets have no RENDER_SURFACE_STATE. Instead,
+ * they use 3DSTATE_DEPTH_BUFFER and 3DSTATE_STENCIL_BUFFER.
+ */
+ if (!anv_format_is_depth_or_stencil(iview->format)) {
+ anv_state_pool_free(&device->surface_state_pool, iview->surface_state);
}
- anv_device_free(device, aview);
+ anv_device_free(device, iview);
}
VkOffset3D src_offset,
VkExtent3D src_extent,
struct anv_image *dest_image,
- struct anv_attachment_view *dest_aview,
+ struct anv_image_view *dest_iview,
VkOffset3D dest_offset,
VkExtent3D dest_extent)
{
struct anv_device *device = cmd_buffer->device;
- struct anv_image_view *dest_iview = &dest_aview->image_view;
+
+ VkImageView dest_iview_h = anv_image_view_to_handle(dest_iview);
+ VkAttachmentView dest_aview_h = { .handle = dest_iview_h.handle };
+
VkDescriptorPool dummy_desc_pool = { .handle = 1 };
struct blit_vb_data {
.attachmentCount = 1,
.pAttachments = (VkAttachmentBindInfo[]) {
{
- .view = anv_attachment_view_to_handle(dest_aview),
+ .view = dest_aview_h,
.layout = VK_IMAGE_LAYOUT_GENERAL
}
},
},
cmd_buffer);
- struct anv_attachment_view dest_aview;
- anv_color_attachment_view_init(&dest_aview, cmd_buffer->device,
+ struct anv_image_view dest_iview;
+ anv_color_attachment_view_init(&dest_iview, cmd_buffer->device,
&(VkAttachmentViewCreateInfo) {
.sType = VK_STRUCTURE_TYPE_ATTACHMENT_VIEW_CREATE_INFO,
.image = dest_image,
(VkOffset3D) { 0, 0, 0 },
(VkExtent3D) { width, height, 1 },
anv_image_from_handle(dest_image),
- &dest_aview,
+ &dest_iview,
(VkOffset3D) { 0, 0, 0 },
(VkExtent3D) { width, height, 1 });
if (pRegions[r].extent.depth > 1)
anv_finishme("FINISHME: copy multiple depth layers");
- struct anv_attachment_view dest_aview;
- anv_color_attachment_view_init(&dest_aview, cmd_buffer->device,
+ struct anv_image_view dest_iview;
+ anv_color_attachment_view_init(&dest_iview, cmd_buffer->device,
&(VkAttachmentViewCreateInfo) {
.sType = VK_STRUCTURE_TYPE_ATTACHMENT_VIEW_CREATE_INFO,
.image = destImage,
src_image, &src_iview,
pRegions[r].srcOffset,
pRegions[r].extent,
- dest_image, &dest_aview,
+ dest_image, &dest_iview,
dest_offset,
pRegions[r].extent);
}
if (pRegions[r].destExtent.depth > 1)
anv_finishme("FINISHME: copy multiple depth layers");
- struct anv_attachment_view dest_aview;
- anv_color_attachment_view_init(&dest_aview, cmd_buffer->device,
+ struct anv_image_view dest_iview;
+ anv_color_attachment_view_init(&dest_iview, cmd_buffer->device,
&(VkAttachmentViewCreateInfo) {
.sType = VK_STRUCTURE_TYPE_ATTACHMENT_VIEW_CREATE_INFO,
.image = destImage,
src_image, &src_iview,
pRegions[r].srcOffset,
pRegions[r].srcExtent,
- dest_image, &dest_aview,
+ dest_image, &dest_iview,
dest_offset,
pRegions[r].destExtent);
}
if (pRegions[r].imageExtent.depth > 1)
anv_finishme("FINISHME: copy multiple depth layers");
- struct anv_attachment_view dest_aview;
- anv_color_attachment_view_init(&dest_aview, cmd_buffer->device,
+ struct anv_image_view dest_iview;
+ anv_color_attachment_view_init(&dest_iview, cmd_buffer->device,
&(VkAttachmentViewCreateInfo) {
.sType = VK_STRUCTURE_TYPE_ATTACHMENT_VIEW_CREATE_INFO,
.image = anv_image_to_handle(dest_image),
(VkOffset3D) { 0, 0, 0 },
pRegions[r].imageExtent,
dest_image,
- &dest_aview,
+ &dest_iview,
dest_offset,
pRegions[r].imageExtent);
dest_format,
&pRegions[r]);
- struct anv_attachment_view dest_aview;
- anv_color_attachment_view_init(&dest_aview, cmd_buffer->device,
+ struct anv_image_view dest_iview;
+ anv_color_attachment_view_init(&dest_iview, cmd_buffer->device,
&(VkAttachmentViewCreateInfo) {
.sType = VK_STRUCTURE_TYPE_ATTACHMENT_VIEW_CREATE_INFO,
.image = destImage,
pRegions[r].imageOffset,
pRegions[r].imageExtent,
anv_image_from_handle(destImage),
- &dest_aview,
+ &dest_iview,
(VkOffset3D) { 0, 0, 0 },
pRegions[r].imageExtent);
for (uint32_t r = 0; r < rangeCount; r++) {
for (uint32_t l = 0; l < pRanges[r].mipLevels; l++) {
for (uint32_t s = 0; s < pRanges[r].arraySize; s++) {
- struct anv_attachment_view aview;
- anv_color_attachment_view_init(&aview, cmd_buffer->device,
+ struct anv_image_view iview;
+ anv_color_attachment_view_init(&iview, cmd_buffer->device,
&(VkAttachmentViewCreateInfo) {
.sType = VK_STRUCTURE_TYPE_ATTACHMENT_VIEW_CREATE_INFO,
.image = _image,
},
cmd_buffer);
- struct anv_image_view *iview = &aview.image_view;
+ VkImageView iview_h = anv_image_view_to_handle(&iview);
+ VkAttachmentView aview_h = { .handle = iview_h.handle };
VkFramebuffer fb;
anv_CreateFramebuffer(anv_device_to_handle(cmd_buffer->device),
.attachmentCount = 1,
.pAttachments = (VkAttachmentBindInfo[]) {
{
- .view = anv_attachment_view_to_handle(&aview),
+ .view = aview_h,
.layout = VK_IMAGE_LAYOUT_GENERAL
}
},
- .width = iview->extent.width,
- .height = iview->extent.height,
+ .width = iview.extent.width,
+ .height = iview.extent.height,
.layers = 1
}, &fb);
.attachmentCount = 1,
.pAttachments = &(VkAttachmentDescription) {
.sType = VK_STRUCTURE_TYPE_ATTACHMENT_DESCRIPTION,
- .format = iview->format->vk_format,
+ .format = iview.format->vk_format,
.loadOp = VK_ATTACHMENT_LOAD_OP_LOAD,
.storeOp = VK_ATTACHMENT_STORE_OP_STORE,
.initialLayout = VK_IMAGE_LAYOUT_GENERAL,
.renderArea = {
.offset = { 0, 0, },
.extent = {
- .width = iview->extent.width,
- .height = iview->extent.height,
+ .width = iview.extent.width,
+ .height = iview.extent.height,
},
},
.renderPass = pass,
void anv_cmd_buffer_clear_attachments(struct anv_cmd_buffer *cmd_buffer,
struct anv_render_pass *pass,
const VkClearValue *clear_values);
-const struct anv_attachment_view *
+const struct anv_image_view *
anv_cmd_buffer_get_depth_stencil_view(const struct anv_cmd_buffer *cmd_buffer);
void anv_cmd_buffer_dump(struct anv_cmd_buffer *cmd_buffer);
VkExtent3D extent; /**< Extent of VkImageViewCreateInfo::baseMipLevel. */
};
-enum anv_attachment_view_type {
- ANV_ATTACHMENT_VIEW_TYPE_COLOR,
- ANV_ATTACHMENT_VIEW_TYPE_DEPTH_STENCIL,
-};
-
-struct anv_attachment_view {
- enum anv_attachment_view_type attachment_type;
- struct anv_image_view image_view;
-};
-
struct anv_image_create_info {
const VkImageCreateInfo *vk_info;
bool force_tile_mode;
const VkImageViewCreateInfo* pCreateInfo,
struct anv_cmd_buffer *cmd_buffer);
-void anv_color_attachment_view_init(struct anv_attachment_view *aview,
+void anv_color_attachment_view_init(struct anv_image_view *iview,
struct anv_device *device,
const VkAttachmentViewCreateInfo* pCreateInfo,
struct anv_cmd_buffer *cmd_buffer);
-void gen7_color_attachment_view_init(struct anv_attachment_view *aview,
+void gen7_color_attachment_view_init(struct anv_image_view *iview,
struct anv_device *device,
const VkAttachmentViewCreateInfo* pCreateInfo,
struct anv_cmd_buffer *cmd_buffer);
-void gen8_color_attachment_view_init(struct anv_attachment_view *aview,
+void gen8_color_attachment_view_init(struct anv_image_view *iview,
struct anv_device *device,
const VkAttachmentViewCreateInfo* pCreateInfo,
struct anv_cmd_buffer *cmd_buffer);
VkDynamicViewportState vp_state;
uint32_t attachment_count;
- const struct anv_attachment_view * attachments[0];
+ const struct anv_image_view * attachments[0];
};
struct anv_subpass {
ANV_DEFINE_HANDLE_CASTS(anv_queue, VkQueue)
ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_cmd_pool, VkCmdPool)
-ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_attachment_view, VkAttachmentView)
ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_buffer, VkBuffer)
ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_buffer_view, VkBufferView);
ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_descriptor_set, VkDescriptorSet)
gen7_cmd_buffer_emit_depth_stencil(struct anv_cmd_buffer *cmd_buffer)
{
const struct anv_framebuffer *fb = cmd_buffer->state.framebuffer;
- const struct anv_attachment_view *aview =
+ const struct anv_image_view *iview =
anv_cmd_buffer_get_depth_stencil_view(cmd_buffer);
- const struct anv_image_view *iview = aview ? &aview->image_view : NULL;
const struct anv_image *image = iview ? iview->image : NULL;
const bool has_depth = iview && iview->format->depth_format;
const bool has_stencil = iview && iview->format->has_stencil;
}
void
-gen7_color_attachment_view_init(struct anv_attachment_view *aview,
+gen7_color_attachment_view_init(struct anv_image_view *iview,
struct anv_device *device,
const VkAttachmentViewCreateInfo* pCreateInfo,
struct anv_cmd_buffer *cmd_buffer)
{
ANV_FROM_HANDLE(anv_image, image, pCreateInfo->image);
- struct anv_image_view *iview = &aview->image_view;
struct anv_surface *surface =
anv_image_get_surface_for_color_attachment(image);
- aview->attachment_type = ANV_ATTACHMENT_VIEW_TYPE_COLOR;
-
anv_assert(pCreateInfo->arraySize > 0);
anv_assert(pCreateInfo->mipLevel < image->levels);
anv_assert(pCreateInfo->baseArraySlice + pCreateInfo->arraySize <= image->array_size);
gen8_cmd_buffer_emit_depth_stencil(struct anv_cmd_buffer *cmd_buffer)
{
const struct anv_framebuffer *fb = cmd_buffer->state.framebuffer;
- const struct anv_attachment_view *aview =
+ const struct anv_image_view *iview =
anv_cmd_buffer_get_depth_stencil_view(cmd_buffer);
- const struct anv_image_view *iview = aview ? &aview->image_view : NULL;
const struct anv_image *image = iview ? iview->image : NULL;
const bool has_depth = iview && iview->format->depth_format;
const bool has_stencil = iview && iview->format->has_stencil;
}
void
-gen8_color_attachment_view_init(struct anv_attachment_view *aview,
+gen8_color_attachment_view_init(struct anv_image_view *iview,
struct anv_device *device,
const VkAttachmentViewCreateInfo* pCreateInfo,
struct anv_cmd_buffer *cmd_buffer)
{
ANV_FROM_HANDLE(anv_image, image, pCreateInfo->image);
- struct anv_image_view *iview = &aview->image_view;
struct anv_surface *surface =
anv_image_get_surface_for_color_attachment(image);
const struct anv_format *format_info =
uint32_t depth = 1; /* RENDER_SURFACE_STATE::Depth */
uint32_t rt_view_extent = 1; /* RENDER_SURFACE_STATE::RenderTargetViewExtent */
- aview->attachment_type = ANV_ATTACHMENT_VIEW_TYPE_COLOR;
-
anv_assert(pCreateInfo->arraySize > 0);
anv_assert(pCreateInfo->mipLevel < image->levels);
anv_assert(pCreateInfo->baseArraySlice + pCreateInfo->arraySize <= image->array_size);