vk: Add anv_format reference t anv_surface_view

Change type of anv_surface_view::format from VkFormat to const struct
anv_format*. This reduces the number of lookups in the VkFormat ->
anv_format table.
This commit is contained in:
Chad Versace 2015-08-17 13:26:28 -07:00
parent c11094ec9a
commit 60c4ac57f2
5 changed files with 10 additions and 19 deletions

View File

@ -506,9 +506,6 @@ cmd_buffer_emit_binding_table(struct anv_cmd_buffer *cmd_buffer,
if (!view)
continue;
const struct anv_format *format =
anv_format_for_vk_format(view->format);
struct anv_state state =
anv_cmd_buffer_alloc_surface_state(cmd_buffer, 64, 64);
@ -521,7 +518,7 @@ cmd_buffer_emit_binding_table(struct anv_cmd_buffer *cmd_buffer,
d->dynamic_offsets[surface_slots[b].dynamic_slot];
offset = view->offset + dynamic_offset;
anv_fill_buffer_surface_state(state.map, format, offset,
anv_fill_buffer_surface_state(state.map, view->format, offset,
view->range - dynamic_offset);
} else {
offset = view->offset;

View File

@ -1388,11 +1388,10 @@ VkResult anv_CreateBufferView(
view->offset = buffer->offset + pCreateInfo->offset;
view->surface_state =
anv_state_pool_alloc(&device->surface_state_pool, 64, 64);
view->format = pCreateInfo->format;
view->format = anv_format_for_vk_format(pCreateInfo->format);
view->range = pCreateInfo->range;
anv_fill_buffer_surface_state(view->surface_state.map,
anv_format_for_vk_format(pCreateInfo->format),
anv_fill_buffer_surface_state(view->surface_state.map, view->format,
view->offset, pCreateInfo->range);
*pView = anv_buffer_view_to_handle(bview);

View File

@ -343,9 +343,6 @@ anv_image_view_init(struct anv_image_view *iview,
struct anv_surface_view *view = &iview->view;
struct anv_surface *surface;
const struct anv_format *format_info =
anv_format_for_vk_format(pCreateInfo->format);
const struct anv_image_view_info *view_type_info
= &anv_image_view_info_table[pCreateInfo->viewType];
@ -369,7 +366,7 @@ anv_image_view_init(struct anv_image_view *iview,
view->bo = image->bo;
view->offset = image->offset + surface->offset;
view->format = pCreateInfo->format;
view->format = anv_format_for_vk_format(pCreateInfo->format);
iview->extent = (VkExtent3D) {
.width = anv_minify(image->extent.width, range->baseMipLevel),
@ -396,7 +393,7 @@ anv_image_view_init(struct anv_image_view *iview,
struct GEN8_RENDER_SURFACE_STATE surface_state = {
.SurfaceType = view_type_info->surface_type,
.SurfaceArray = image->array_size > 1,
.SurfaceFormat = format_info->surface_format,
.SurfaceFormat = view->format->surface_format,
.SurfaceVerticalAlignment = anv_valign[surface->v_align],
.SurfaceHorizontalAlignment = anv_halign[surface->h_align],
.TileMode = surface->tile_mode,
@ -572,8 +569,6 @@ anv_color_attachment_view_init(struct anv_color_attachment_view *aview,
ANV_FROM_HANDLE(anv_image, image, pCreateInfo->image);
struct anv_surface_view *view = &aview->view;
struct anv_surface *surface = &image->primary_surface;
const struct anv_format *format_info =
anv_format_for_vk_format(pCreateInfo->format);
aview->base.attachment_type = ANV_ATTACHMENT_VIEW_TYPE_COLOR;
@ -583,7 +578,7 @@ anv_color_attachment_view_init(struct anv_color_attachment_view *aview,
view->bo = image->bo;
view->offset = image->offset + surface->offset;
view->format = pCreateInfo->format;
view->format = anv_format_for_vk_format(pCreateInfo->format);
aview->base.extent = (VkExtent3D) {
.width = anv_minify(image->extent.width, pCreateInfo->mipLevel),
@ -609,7 +604,7 @@ anv_color_attachment_view_init(struct anv_color_attachment_view *aview,
struct GEN8_RENDER_SURFACE_STATE surface_state = {
.SurfaceType = SURFTYPE_2D,
.SurfaceArray = image->array_size > 1,
.SurfaceFormat = format_info->surface_format,
.SurfaceFormat = view->format->surface_format,
.SurfaceVerticalAlignment = anv_valign[surface->v_align],
.SurfaceHorizontalAlignment = anv_halign[surface->h_align],
.TileMode = surface->tile_mode,

View File

@ -637,7 +637,7 @@ meta_emit_blit(struct anv_cmd_buffer *cmd_buffer,
.attachmentCount = 1,
.pAttachments = &(VkAttachmentDescription) {
.sType = VK_STRUCTURE_TYPE_ATTACHMENT_DESCRIPTION,
.format = dest->view.format,
.format = dest->view.format->vk_format,
.loadOp = VK_ATTACHMENT_LOAD_OP_LOAD,
.storeOp = VK_ATTACHMENT_STORE_OP_STORE,
.initialLayout = VK_IMAGE_LAYOUT_GENERAL,
@ -1289,7 +1289,7 @@ void anv_CmdClearColorImage(
.attachmentCount = 1,
.pAttachments = &(VkAttachmentDescription) {
.sType = VK_STRUCTURE_TYPE_ATTACHMENT_DESCRIPTION,
.format = view.view.format,
.format = view.view.format->vk_format,
.loadOp = VK_ATTACHMENT_LOAD_OP_LOAD,
.storeOp = VK_ATTACHMENT_STORE_OP_STORE,
.initialLayout = VK_IMAGE_LAYOUT_GENERAL,

View File

@ -941,7 +941,7 @@ struct anv_surface_view {
struct anv_bo *bo;
uint32_t offset; /**< VkBufferCreateInfo::offset */
uint32_t range; /**< VkBufferCreateInfo::range */
VkFormat format; /**< VkBufferCreateInfo::format */
const struct anv_format *format; /**< VkBufferCreateInfo::format */
};
struct anv_buffer_view {