vk: Add anv_format reference t anv_surface_view
authorChad Versace <chad.versace@intel.com>
Mon, 17 Aug 2015 20:26:28 +0000 (13:26 -0700)
committerChad Versace <chad.versace@intel.com>
Mon, 17 Aug 2015 21:08:55 +0000 (14:08 -0700)
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.

src/vulkan/anv_cmd_buffer.c
src/vulkan/anv_device.c
src/vulkan/anv_image.c
src/vulkan/anv_meta.c
src/vulkan/anv_private.h

index 5d3d4a4353ce5f7088a3d6c10a35e7a4376c5161..5178f6529abef6c1f751d050759978320349b527 100644 (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;
index 677e277cdf7b304052e9539118b5182919d6974f..0f06f3e5a916081166edec7d1db5aaef9e5d99b8 100644 (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);
index 329955fff593e39d291b19a6b603620f9c2c891d..4c5032cea53a52ae49cdc53be21204569b5e6f6f 100644 (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,
index 7fcabb29069e8119330fdf1c2aabccf83798d8b8..d3dbd6bafc7d612028964b361d3194c6f91e4a86 100644 (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,
index 3cf6c67e7d8e8342d3eaf7f8e6487b707d1d01c5..725f8d885660364ab9162165d3e87bc048be3abd 100644 (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 {