summaryrefslogtreecommitdiffstats
path: root/src/vulkan
diff options
context:
space:
mode:
authorChad Versace <[email protected]>2015-08-17 13:26:28 -0700
committerChad Versace <[email protected]>2015-08-17 14:08:55 -0700
commit60c4ac57f28c655cd7b40b7f5be966f95c982a0b (patch)
tree5c760e8fc0c4ad903a9eceacd08031e6723fb863 /src/vulkan
parentc11094ec9a8e6580205e76399aa357fbbad01aed (diff)
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.
Diffstat (limited to 'src/vulkan')
-rw-r--r--src/vulkan/anv_cmd_buffer.c5
-rw-r--r--src/vulkan/anv_device.c5
-rw-r--r--src/vulkan/anv_image.c13
-rw-r--r--src/vulkan/anv_meta.c4
-rw-r--r--src/vulkan/anv_private.h2
5 files changed, 10 insertions, 19 deletions
diff --git a/src/vulkan/anv_cmd_buffer.c b/src/vulkan/anv_cmd_buffer.c
index 5d3d4a4353c..5178f6529ab 100644
--- a/src/vulkan/anv_cmd_buffer.c
+++ b/src/vulkan/anv_cmd_buffer.c
@@ -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;
diff --git a/src/vulkan/anv_device.c b/src/vulkan/anv_device.c
index 677e277cdf7..0f06f3e5a91 100644
--- a/src/vulkan/anv_device.c
+++ b/src/vulkan/anv_device.c
@@ -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);
diff --git a/src/vulkan/anv_image.c b/src/vulkan/anv_image.c
index 329955fff59..4c5032cea53 100644
--- a/src/vulkan/anv_image.c
+++ b/src/vulkan/anv_image.c
@@ -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,
diff --git a/src/vulkan/anv_meta.c b/src/vulkan/anv_meta.c
index 7fcabb29069..d3dbd6bafc7 100644
--- a/src/vulkan/anv_meta.c
+++ b/src/vulkan/anv_meta.c
@@ -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,
diff --git a/src/vulkan/anv_private.h b/src/vulkan/anv_private.h
index 3cf6c67e7d8..725f8d88566 100644
--- a/src/vulkan/anv_private.h
+++ b/src/vulkan/anv_private.h
@@ -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 {