vk: Add anv_format reference to anv_render_pass_attachment
authorChad Versace <chad.versace@intel.com>
Mon, 17 Aug 2015 21:03:52 +0000 (14:03 -0700)
committerChad Versace <chad.versace@intel.com>
Mon, 17 Aug 2015 21:08:55 +0000 (14:08 -0700)
Change type of anv_render_pass_attachment::format from VkFormat to const
struct anv_format*.  This elimiates the repetitive lookups into the
VkFormat -> anv_format table when looping over attachments during
anv_cmd_buffer_clear_attachments().

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

index 0f06f3e5a916081166edec7d1db5aaef9e5d99b8..145d16f485e5d23c3cbb86636fa41f575c99dfe2 100644 (file)
@@ -2229,7 +2229,8 @@ VkResult anv_CreateRenderPass(
    pass->attachments = anv_device_alloc(device, size, 8,
                                         VK_SYSTEM_ALLOC_TYPE_API_OBJECT);
    for (uint32_t i = 0; i < pCreateInfo->attachmentCount; i++) {
-      pass->attachments[i].format = pCreateInfo->pAttachments[i].format;
+      pass->attachments[i].format =
+         anv_format_for_vk_format(pCreateInfo->pAttachments[i].format);
       pass->attachments[i].samples = pCreateInfo->pAttachments[i].samples;
       pass->attachments[i].load_op = pCreateInfo->pAttachments[i].loadOp;
       pass->attachments[i].stencil_load_op = pCreateInfo->pAttachments[i].stencilLoadOp;
index 9b971a18ac2c81c3e02a02f6496917bf749fa289..f5d00a0f8ffa507d0b504ed204067367fd393db5 100644 (file)
@@ -218,19 +218,6 @@ anv_format_for_vk_format(VkFormat format)
    return &anv_formats[format];
 }
 
-bool
-anv_is_vk_format_depth_or_stencil(VkFormat format)
-{
-   const struct anv_format *format_info =
-      anv_format_for_vk_format(format);
-
-   if (format_info->depth_format != UNSUPPORTED &&
-       format_info->depth_format != 0)
-      return true;
-
-   return format_info->has_stencil;
-}
-
 // Format capabilities
 
 struct surface_format_info {
index 3b706c6844336d47b50aac77e30d5311e177614d..0152fef9ffb57725ff0e907b199cae86925cf870 100644 (file)
@@ -689,7 +689,10 @@ anv_CreateAttachmentView(VkDevice _device,
 
    assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_ATTACHMENT_VIEW_CREATE_INFO);
 
-   if (anv_is_vk_format_depth_or_stencil(pCreateInfo->format)) {
+   const struct anv_format *format =
+      anv_format_for_vk_format(pCreateInfo->format);
+
+   if (anv_format_is_depth_or_stencil(format)) {
       struct anv_depth_stencil_view *view =
          anv_device_alloc(device, sizeof(*view), 8,
                           VK_SYSTEM_ALLOC_TYPE_API_OBJECT);
index d3dbd6bafc7d612028964b361d3194c6f91e4a86..8808d312db46f584ff70f3d20b370bb12a606ed9 100644 (file)
@@ -269,7 +269,7 @@ anv_cmd_buffer_clear_attachments(struct anv_cmd_buffer *cmd_buffer,
    int num_clear_layers = 0;
    for (uint32_t i = 0; i < pass->attachment_count; i++) {
       if (pass->attachments[i].load_op == VK_ATTACHMENT_LOAD_OP_CLEAR) {
-         if (anv_is_vk_format_depth_or_stencil(pass->attachments[i].format)) {
+         if (anv_format_is_depth_or_stencil(pass->attachments[i].format)) {
             anv_finishme("Can't clear depth-stencil yet");
             continue;
          }
@@ -286,7 +286,7 @@ anv_cmd_buffer_clear_attachments(struct anv_cmd_buffer *cmd_buffer,
    int layer = 0;
    for (uint32_t i = 0; i < pass->attachment_count; i++) {
       if (pass->attachments[i].load_op == VK_ATTACHMENT_LOAD_OP_CLEAR &&
-          !anv_is_vk_format_depth_or_stencil(pass->attachments[i].format)) {
+          !anv_format_is_depth_or_stencil(pass->attachments[i].format)) {
          instance_data[layer] = (struct clear_instance_data) {
             .vue_header = {
                .RTAIndex = i,
index ee2700254cd6abc2b896d706e5ffd1b72a32f0e3..1b2cfc6fa0cfc4c2a1e146adb2e6d27f4cdcd548 100644 (file)
@@ -888,7 +888,12 @@ extern const struct anv_format *const anv_format_s8_uint;
 
 const struct anv_format *
 anv_format_for_vk_format(VkFormat format);
-bool anv_is_vk_format_depth_or_stencil(VkFormat format);
+
+static inline bool
+anv_format_is_depth_or_stencil(const struct anv_format *format)
+{
+   return format->depth_format || format->has_stencil;
+}
 
 /**
  * A proxy for the color surfaces, depth surfaces, and stencil surfaces.
@@ -1042,7 +1047,7 @@ struct anv_subpass {
 };
 
 struct anv_render_pass_attachment {
-   VkFormat                                     format;
+   const struct anv_format                      *format;
    uint32_t                                     samples;
    VkAttachmentLoadOp                           load_op;
    VkAttachmentLoadOp                           stencil_load_op;