const struct anv_color_attachment_view *cview =
(const struct anv_color_attachment_view *) aview;
- const struct anv_surface_view *sview = &cview->surface_view;
+ const struct anv_image_view *iview = &cview->image_view;
- bt_map[a] = sview->surface_state.offset + state_offset;
- add_surface_state_reloc(cmd_buffer, sview->surface_state,
- sview->bo, sview->offset);
+ bt_map[a] = iview->surface_state.offset + state_offset;
+ add_surface_state_reloc(cmd_buffer, iview->surface_state,
+ iview->bo, iview->offset);
}
if (layout == NULL)
struct anv_descriptor *desc =
&d->set->descriptors[surface_slots[b].index];
- if (desc->type != ANV_DESCRIPTOR_TYPE_SURFACE_VIEW)
- continue;
+ const struct anv_state *surface_state;
+ struct anv_bo *bo;
+ uint32_t bo_offset;
- const struct anv_surface_view *sview = desc->surface_view;
+ switch (desc->type) {
+ case ANV_DESCRIPTOR_TYPE_EMPTY:
+ case ANV_DESCRIPTOR_TYPE_SAMPLER:
+ continue;
+ case ANV_DESCRIPTOR_TYPE_BUFFER_VIEW:
+ surface_state = &desc->buffer_view->surface_state;
+ bo = desc->buffer_view->bo;
+ bo_offset = desc->buffer_view->offset;
+ break;
+ case ANV_DESCRIPTOR_TYPE_IMAGE_VIEW:
+ surface_state = &desc->image_view->surface_state;
+ bo = desc->image_view->bo;
+ bo_offset = desc->image_view->offset;
+ break;
+ }
- bt_map[start + b] = sview->surface_state.offset + state_offset;
- add_surface_state_reloc(cmd_buffer, sview->surface_state,
- sview->bo, sview->offset);
+ bt_map[start + b] = surface_state->offset + state_offset;
+ add_surface_state_reloc(cmd_buffer, *surface_state, bo, bo_offset);
}
}
if (bview == NULL)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
- bview->surface_view = (struct anv_surface_view) {
+ *bview = (struct anv_buffer_view) {
.bo = buffer->bo,
.offset = buffer->offset + pCreateInfo->offset,
.surface_state = anv_state_pool_alloc(&device->surface_state_pool, 64, 64),
ANV_FROM_HANDLE(anv_device, device, _device);
ANV_FROM_HANDLE(anv_buffer_view, bview, _bview);
- anv_surface_view_fini(device, &bview->surface_view);
+ anv_state_pool_free(&device->surface_state_pool, bview->surface_state);
anv_device_free(device, bview);
return VK_SUCCESS;
write->pDescriptors[j].imageView);
set->descriptors[write->destBinding + j] = (struct anv_descriptor) {
- .type = ANV_DESCRIPTOR_TYPE_SURFACE_VIEW,
- .surface_view = &iview->surface_view,
+ .type = ANV_DESCRIPTOR_TYPE_IMAGE_VIEW,
+ .image_view = iview,
};
}
break;
write->pDescriptors[j].bufferView);
set->descriptors[write->destBinding + j] = (struct anv_descriptor) {
- .type = ANV_DESCRIPTOR_TYPE_SURFACE_VIEW,
- .surface_view = &bview->surface_view,
+ .type = ANV_DESCRIPTOR_TYPE_BUFFER_VIEW,
+ .buffer_view = bview,
};
}
stub_return(VK_UNSUPPORTED);
}
-void
-anv_surface_view_fini(struct anv_device *device,
- struct anv_surface_view *sview)
-{
- anv_state_pool_free(&device->surface_state_pool, sview->surface_state);
-}
-
VkResult
anv_validate_CreateImageView(VkDevice _device,
const VkImageViewCreateInfo *pCreateInfo,
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);
+}
+
VkResult
anv_DestroyImageView(VkDevice _device, VkImageView _iview)
{
ANV_FROM_HANDLE(anv_device, device, _device);
ANV_FROM_HANDLE(anv_image_view, iview, _iview);
- anv_surface_view_fini(device, &iview->surface_view);
+ anv_image_view_fini(device, iview);
anv_device_free(device, iview);
return VK_SUCCESS;
struct anv_color_attachment_view *cview =
(struct anv_color_attachment_view *) aview;
- anv_surface_view_fini(device, &cview->surface_view);
+ anv_image_view_fini(device, &cview->image_view);
}
anv_device_free(device, aview);
{
struct anv_device *device = cmd_buffer->device;
struct anv_attachment_view *dest_aview = &dest_cview->attachment_view;
- struct anv_surface_view *dest_sview = &dest_cview->surface_view;
+ struct anv_image_view *dest_iview = &dest_cview->image_view;
VkDescriptorPool dummy_desc_pool = { .handle = 1 };
struct blit_vb_data {
.attachmentCount = 1,
.pAttachments = &(VkAttachmentDescription) {
.sType = VK_STRUCTURE_TYPE_ATTACHMENT_DESCRIPTION,
- .format = dest_sview->format->vk_format,
+ .format = dest_iview->format->vk_format,
.loadOp = VK_ATTACHMENT_LOAD_OP_LOAD,
.storeOp = VK_ATTACHMENT_STORE_OP_STORE,
.initialLayout = VK_IMAGE_LAYOUT_GENERAL,
cmd_buffer);
struct anv_attachment_view *aview = &cview.attachment_view;
- struct anv_surface_view *sview = &cview.surface_view;
+ struct anv_image_view *iview = &cview.image_view;
VkFramebuffer fb;
anv_CreateFramebuffer(anv_device_to_handle(cmd_buffer->device),
.attachmentCount = 1,
.pAttachments = &(VkAttachmentDescription) {
.sType = VK_STRUCTURE_TYPE_ATTACHMENT_DESCRIPTION,
- .format = sview->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,
enum anv_descriptor_type {
ANV_DESCRIPTOR_TYPE_EMPTY = 0,
+ ANV_DESCRIPTOR_TYPE_BUFFER_VIEW,
+ ANV_DESCRIPTOR_TYPE_IMAGE_VIEW,
ANV_DESCRIPTOR_TYPE_SAMPLER,
- ANV_DESCRIPTOR_TYPE_SURFACE_VIEW,
};
struct anv_descriptor {
union {
+ struct anv_buffer_view *buffer_view;
+ struct anv_image_view *image_view;
struct anv_sampler *sampler;
- struct anv_surface_view *surface_view;
};
enum anv_descriptor_type type;
};
};
-struct anv_surface_view {
+struct anv_buffer_view {
struct anv_state surface_state; /**< RENDER_SURFACE_STATE */
struct anv_bo *bo;
- uint32_t offset; /**< VkBufferCreateInfo::offset */
- uint32_t range; /**< VkBufferCreateInfo::range */
- const struct anv_format *format; /**< VkBufferCreateInfo::format */
-};
-
-struct anv_buffer_view {
- struct anv_surface_view surface_view;
+ uint32_t offset; /**< Offset into bo. */
+ uint32_t range; /**< VkBufferViewCreateInfo::range */
+ const struct anv_format *format; /**< VkBufferViewCreateInfo::format */
};
struct anv_image_view {
- struct anv_surface_view surface_view;
+ struct anv_state surface_state; /**< RENDER_SURFACE_STATE */
+ struct anv_bo *bo;
+ uint32_t offset; /**< Offset into bo. */
+ const struct anv_format *format; /**< VkImageViewCreateInfo::format */
VkExtent3D extent;
};
struct anv_color_attachment_view {
struct anv_attachment_view attachment_view;
- struct anv_surface_view surface_view;
+ struct anv_image_view image_view;
};
struct anv_depth_stencil_view {
void gen8_fill_buffer_surface_state(void *state, const struct anv_format *format,
uint32_t offset, uint32_t range);
-void anv_surface_view_fini(struct anv_device *device,
- struct anv_surface_view *sview);
-
struct anv_sampler {
uint32_t state[4];
};
const struct anv_format *format =
anv_format_for_vk_format(pCreateInfo->format);
- gen7_fill_buffer_surface_state(bview->surface_view.surface_state.map,
- format, bview->surface_view.offset,
- pCreateInfo->range);
+ gen7_fill_buffer_surface_state(bview->surface_state.map, format,
+ bview->offset, pCreateInfo->range);
*pView = anv_buffer_view_to_handle(bview);
ANV_FROM_HANDLE(anv_image, image, pCreateInfo->image);
const VkImageSubresourceRange *range = &pCreateInfo->subresourceRange;
- struct anv_surface_view *sview = &iview->surface_view;
struct anv_surface *surface =
anv_image_get_surface_for_aspect_mask(image, range->aspectMask);
if (pCreateInfo->viewType != VK_IMAGE_VIEW_TYPE_2D)
anv_finishme("non-2D image views");
- sview->bo = image->bo;
- sview->offset = image->offset + surface->offset;
- sview->format = anv_format_for_vk_format(pCreateInfo->format);
+ iview->bo = image->bo;
+ iview->offset = image->offset + surface->offset;
+ iview->format = anv_format_for_vk_format(pCreateInfo->format);
iview->extent = (VkExtent3D) {
.width = anv_minify(image->extent.width, range->baseMipLevel),
.BlueClearColor = 0,
.AlphaClearColor = 0,
.ResourceMinLOD = 0.0,
- .SurfaceBaseAddress = { NULL, sview->offset },
+ .SurfaceBaseAddress = { NULL, iview->offset },
};
if (cmd_buffer) {
- sview->surface_state =
+ iview->surface_state =
anv_state_stream_alloc(&cmd_buffer->surface_state_stream, 64, 64);
} else {
- sview->surface_state =
+ iview->surface_state =
anv_state_pool_alloc(&device->surface_state_pool, 64, 64);
}
- GEN7_RENDER_SURFACE_STATE_pack(NULL, sview->surface_state.map,
+ GEN7_RENDER_SURFACE_STATE_pack(NULL, iview->surface_state.map,
&surface_state);
}
{
ANV_FROM_HANDLE(anv_image, image, pCreateInfo->image);
struct anv_attachment_view *aview = &cview->attachment_view;
- struct anv_surface_view *sview = &cview->surface_view;
+ struct anv_image_view *iview = &cview->image_view;
struct anv_surface *surface =
anv_image_get_surface_for_color_attachment(image);
anv_assert(pCreateInfo->mipLevel < image->levels);
anv_assert(pCreateInfo->baseArraySlice + pCreateInfo->arraySize <= image->array_size);
- sview->bo = image->bo;
- sview->offset = image->offset + surface->offset;
- sview->format = anv_format_for_vk_format(pCreateInfo->format);
+ iview->bo = image->bo;
+ iview->offset = image->offset + surface->offset;
+ iview->format = anv_format_for_vk_format(pCreateInfo->format);
aview->extent = (VkExtent3D) {
.width = anv_minify(image->extent.width, pCreateInfo->mipLevel),
}
if (cmd_buffer) {
- sview->surface_state =
+ iview->surface_state =
anv_state_stream_alloc(&cmd_buffer->surface_state_stream, 64, 64);
} else {
- sview->surface_state =
+ iview->surface_state =
anv_state_pool_alloc(&device->surface_state_pool, 64, 64);
}
struct GEN7_RENDER_SURFACE_STATE surface_state = {
.SurfaceType = SURFTYPE_2D,
.SurfaceArray = image->array_size > 1,
- .SurfaceFormat = sview->format->surface_format,
+ .SurfaceFormat = iview->format->surface_format,
.SurfaceVerticalAlignment = anv_valign[surface->v_align],
.SurfaceHorizontalAlignment = anv_halign[surface->h_align],
.BlueClearColor = 0,
.AlphaClearColor = 0,
.ResourceMinLOD = 0.0,
- .SurfaceBaseAddress = { NULL, sview->offset },
+ .SurfaceBaseAddress = { NULL, iview->offset },
};
- GEN7_RENDER_SURFACE_STATE_pack(NULL, sview->surface_state.map,
+ GEN7_RENDER_SURFACE_STATE_pack(NULL, iview->surface_state.map,
&surface_state);
}
const struct anv_format *format =
anv_format_for_vk_format(pCreateInfo->format);
- gen8_fill_buffer_surface_state(bview->surface_view.surface_state.map,
- format, bview->surface_view.offset,
- pCreateInfo->range);
+ gen8_fill_buffer_surface_state(bview->surface_state.map, format,
+ bview->offset, pCreateInfo->range);
*pView = anv_buffer_view_to_handle(bview);
ANV_FROM_HANDLE(anv_image, image, pCreateInfo->image);
const VkImageSubresourceRange *range = &pCreateInfo->subresourceRange;
- struct anv_surface_view *sview = &iview->surface_view;
struct anv_surface *surface =
anv_image_get_surface_for_aspect_mask(image, range->aspectMask);
const struct anv_image_view_info view_type_info =
anv_image_view_info_for_vk_image_view_type(pCreateInfo->viewType);
- sview->bo = image->bo;
- sview->offset = image->offset + surface->offset;
- sview->format = format_info;
+ iview->bo = image->bo;
+ iview->offset = image->offset + surface->offset;
+ iview->format = format_info;
iview->extent = (VkExtent3D) {
.width = anv_minify(image->extent.width, range->baseMipLevel),
.ShaderChannelSelectBlue = vk_to_gen_swizzle[pCreateInfo->channels.b],
.ShaderChannelSelectAlpha = vk_to_gen_swizzle[pCreateInfo->channels.a],
.ResourceMinLOD = 0.0,
- .SurfaceBaseAddress = { NULL, sview->offset },
+ .SurfaceBaseAddress = { NULL, iview->offset },
};
if (cmd_buffer) {
- sview->surface_state =
+ iview->surface_state =
anv_state_stream_alloc(&cmd_buffer->surface_state_stream, 64, 64);
} else {
- sview->surface_state =
+ iview->surface_state =
anv_state_pool_alloc(&device->surface_state_pool, 64, 64);
}
- GEN8_RENDER_SURFACE_STATE_pack(NULL, sview->surface_state.map,
+ GEN8_RENDER_SURFACE_STATE_pack(NULL, iview->surface_state.map,
&surface_state);
}
{
ANV_FROM_HANDLE(anv_image, image, pCreateInfo->image);
struct anv_attachment_view *aview = &cview->attachment_view;
- struct anv_surface_view *sview = &cview->surface_view;
+ struct anv_image_view *iview = &cview->image_view;
struct anv_surface *surface =
anv_image_get_surface_for_color_attachment(image);
const struct anv_format *format_info =
anv_assert(pCreateInfo->mipLevel < image->levels);
anv_assert(pCreateInfo->baseArraySlice + pCreateInfo->arraySize <= image->array_size);
- sview->bo = image->bo;
- sview->offset = image->offset + surface->offset;
- sview->format = anv_format_for_vk_format(pCreateInfo->format);
+ iview->bo = image->bo;
+ iview->offset = image->offset + surface->offset;
+ iview->format = anv_format_for_vk_format(pCreateInfo->format);
aview->extent = (VkExtent3D) {
.width = anv_minify(image->extent.width, pCreateInfo->mipLevel),
}
if (cmd_buffer) {
- sview->surface_state =
+ iview->surface_state =
anv_state_stream_alloc(&cmd_buffer->surface_state_stream, 64, 64);
} else {
- sview->surface_state =
+ iview->surface_state =
anv_state_pool_alloc(&device->surface_state_pool, 64, 64);
}
.ShaderChannelSelectBlue = SCS_BLUE,
.ShaderChannelSelectAlpha = SCS_ALPHA,
.ResourceMinLOD = 0.0,
- .SurfaceBaseAddress = { NULL, sview->offset },
+ .SurfaceBaseAddress = { NULL, iview->offset },
};
- GEN8_RENDER_SURFACE_STATE_pack(NULL, sview->surface_state.map,
+ GEN8_RENDER_SURFACE_STATE_pack(NULL, iview->surface_state.map,
&surface_state);
}