vk: Pass anv_format to anv_fill_buffer_surface_state()
authorChad Versace <chad.versace@intel.com>
Mon, 17 Aug 2015 20:20:33 +0000 (13:20 -0700)
committerChad Versace <chad.versace@intel.com>
Mon, 17 Aug 2015 21:08:55 +0000 (14:08 -0700)
This moves the translation of VkFormat to anv_format from
anv_fill_buffer_surface_state() to its caller.

A prep commit to reduce more VkFormat -> anv_format translations.

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

index 5178f6529abef6c1f751d050759978320349b527..5d3d4a4353ce5f7088a3d6c10a35e7a4376c5161 100644 (file)
@@ -506,6 +506,9 @@ 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);
 
@@ -518,7 +521,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, view->format, offset,
+            anv_fill_buffer_surface_state(state.map, format, offset,
                                           view->range - dynamic_offset);
          } else {
             offset = view->offset;
index 0653f8bab16de16581cfb5509c2e82440fb14467..677e277cdf7b304052e9539118b5182919d6974f 100644 (file)
@@ -1318,12 +1318,9 @@ VkResult anv_DestroyBuffer(
 // Buffer view functions
 
 void
-anv_fill_buffer_surface_state(void *state, VkFormat format,
+anv_fill_buffer_surface_state(void *state, const struct anv_format *format,
                               uint32_t offset, uint32_t range)
 {
-   const struct anv_format *info;
-
-   info = anv_format_for_vk_format(format);
    /* This assumes RGBA float format. */
    uint32_t stride = 4;
    uint32_t num_elements = range / stride;
@@ -1331,7 +1328,7 @@ anv_fill_buffer_surface_state(void *state, VkFormat format,
    struct GEN8_RENDER_SURFACE_STATE surface_state = {
       .SurfaceType = SURFTYPE_BUFFER,
       .SurfaceArray = false,
-      .SurfaceFormat = info->surface_format,
+      .SurfaceFormat = format->surface_format,
       .SurfaceVerticalAlignment = VALIGN4,
       .SurfaceHorizontalAlignment = HALIGN4,
       .TileMode = LINEAR,
@@ -1395,7 +1392,7 @@ VkResult anv_CreateBufferView(
    view->range = pCreateInfo->range;
 
    anv_fill_buffer_surface_state(view->surface_state.map,
-                                 pCreateInfo->format,
+                                 anv_format_for_vk_format(pCreateInfo->format),
                                  view->offset, pCreateInfo->range);
 
    *pView = anv_buffer_view_to_handle(bview);
index 89e7a8d778c71a4c26fcf8a2b8bef654361b160c..3cf6c67e7d8e8342d3eaf7f8e6487b707d1d01c5 100644 (file)
@@ -1003,7 +1003,7 @@ void anv_color_attachment_view_init(struct anv_color_attachment_view *view,
                                     struct anv_device *device,
                                     const VkAttachmentViewCreateInfo* pCreateInfo,
                                     struct anv_cmd_buffer *cmd_buffer);
-void anv_fill_buffer_surface_state(void *state, VkFormat format,
+void anv_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,