From: Chad Versace Date: Mon, 17 Aug 2015 20:20:33 +0000 (-0700) Subject: vk: Pass anv_format to anv_fill_buffer_surface_state() X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c11094ec9a8e6580205e76399aa357fbbad01aed;p=mesa.git vk: Pass anv_format to anv_fill_buffer_surface_state() 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. --- diff --git a/src/vulkan/anv_cmd_buffer.c b/src/vulkan/anv_cmd_buffer.c index 5178f6529ab..5d3d4a4353c 100644 --- a/src/vulkan/anv_cmd_buffer.c +++ b/src/vulkan/anv_cmd_buffer.c @@ -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; diff --git a/src/vulkan/anv_device.c b/src/vulkan/anv_device.c index 0653f8bab16..677e277cdf7 100644 --- a/src/vulkan/anv_device.c +++ b/src/vulkan/anv_device.c @@ -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); diff --git a/src/vulkan/anv_private.h b/src/vulkan/anv_private.h index 89e7a8d778c..3cf6c67e7d8 100644 --- a/src/vulkan/anv_private.h +++ b/src/vulkan/anv_private.h @@ -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,