anv: Gut anv_pipeline_layout
authorJason Ekstrand <jason.ekstrand@intel.com>
Thu, 18 Feb 2016 02:03:21 +0000 (18:03 -0800)
committerJason Ekstrand <jason.ekstrand@intel.com>
Thu, 18 Feb 2016 02:04:40 +0000 (18:04 -0800)
Almost none of the data in anv_pipeline_layout is used anymore thanks to
doing real layout in the pipeline itself.

src/vulkan/anv_descriptor_set.c
src/vulkan/anv_private.h

index d5e6286f3ee47fc5c3026ed2176cfc9f4303cc0f..7a77336602a42be997743bc23b96738372bde09b 100644 (file)
@@ -197,108 +197,36 @@ VkResult anv_CreatePipelineLayout(
     VkPipelineLayout*                           pPipelineLayout)
 {
    ANV_FROM_HANDLE(anv_device, device, _device);
-   struct anv_pipeline_layout l, *layout;
+   struct anv_pipeline_layout *layout;
 
    assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO);
 
-   l.num_sets = pCreateInfo->setLayoutCount;
+   layout = anv_alloc2(&device->alloc, pAllocator, sizeof(*layout), 8,
+                       VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
+   if (layout == NULL)
+      return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
+
+   layout->num_sets = pCreateInfo->setLayoutCount;
 
    unsigned dynamic_offset_count = 0;
 
-   memset(l.stage, 0, sizeof(l.stage));
+   memset(layout->stage, 0, sizeof(layout->stage));
    for (uint32_t set = 0; set < pCreateInfo->setLayoutCount; set++) {
       ANV_FROM_HANDLE(anv_descriptor_set_layout, set_layout,
                       pCreateInfo->pSetLayouts[set]);
-      l.set[set].layout = set_layout;
+      layout->set[set].layout = set_layout;
 
-      l.set[set].dynamic_offset_start = dynamic_offset_count;
+      layout->set[set].dynamic_offset_start = dynamic_offset_count;
       for (uint32_t b = 0; b < set_layout->binding_count; b++) {
          if (set_layout->binding[b].dynamic_offset_index >= 0)
             dynamic_offset_count += set_layout->binding[b].array_size;
-      }
-
-      for (gl_shader_stage s = 0; s < MESA_SHADER_STAGES; s++) {
-         l.set[set].stage[s].surface_start = l.stage[s].surface_count;
-         l.set[set].stage[s].sampler_start = l.stage[s].sampler_count;
-         l.set[set].stage[s].image_start = l.stage[s].image_count;
-
-         for (uint32_t b = 0; b < set_layout->binding_count; b++) {
-            unsigned array_size = set_layout->binding[b].array_size;
-
-            if (set_layout->binding[b].stage[s].surface_index >= 0) {
-               l.stage[s].surface_count += array_size;
-
-               if (set_layout->binding[b].dynamic_offset_index >= 0)
-                  l.stage[s].has_dynamic_offsets = true;
-            }
-
-            if (set_layout->binding[b].stage[s].sampler_index >= 0)
-               l.stage[s].sampler_count += array_size;
-
-            if (set_layout->binding[b].stage[s].image_index >= 0)
-               l.stage[s].image_count += array_size;
+         for (gl_shader_stage s = 0; s < MESA_SHADER_STAGES; s++) {
+            if (set_layout->binding[b].stage[s].surface_index >= 0)
+               layout->stage[s].has_dynamic_offsets = true;
          }
       }
    }
 
-   unsigned num_bindings = 0;
-   for (gl_shader_stage s = 0; s < MESA_SHADER_STAGES; s++) {
-      num_bindings += l.stage[s].surface_count +
-                      l.stage[s].sampler_count +
-                      l.stage[s].image_count;
-   }
-
-   size_t size = sizeof(*layout) + num_bindings * sizeof(layout->entries[0]);
-
-   layout = anv_alloc2(&device->alloc, pAllocator, size, 8,
-                       VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
-   if (layout == NULL)
-      return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
-
-   /* Now we can actually build our surface and sampler maps */
-   struct anv_pipeline_binding *entry = layout->entries;
-   for (gl_shader_stage s = 0; s < MESA_SHADER_STAGES; s++) {
-      l.stage[s].surface_to_descriptor = entry;
-      entry += l.stage[s].surface_count;
-      l.stage[s].sampler_to_descriptor = entry;
-      entry += l.stage[s].sampler_count;
-      entry += l.stage[s].image_count;
-
-      int surface = 0;
-      int sampler = 0;
-      for (uint32_t set = 0; set < pCreateInfo->setLayoutCount; set++) {
-         struct anv_descriptor_set_layout *set_layout = l.set[set].layout;
-
-         for (uint32_t b = 0; b < set_layout->binding_count; b++) {
-            unsigned array_size = set_layout->binding[b].array_size;
-            unsigned set_offset = set_layout->binding[b].descriptor_index;
-
-            if (set_layout->binding[b].stage[s].surface_index >= 0) {
-               assert(surface == l.set[set].stage[s].surface_start +
-                                 set_layout->binding[b].stage[s].surface_index);
-               for (unsigned i = 0; i < array_size; i++) {
-                  l.stage[s].surface_to_descriptor[surface + i].set = set;
-                  l.stage[s].surface_to_descriptor[surface + i].offset = set_offset + i;
-               }
-               surface += array_size;
-            }
-
-            if (set_layout->binding[b].stage[s].sampler_index >= 0) {
-               assert(sampler == l.set[set].stage[s].sampler_start +
-                                 set_layout->binding[b].stage[s].sampler_index);
-               for (unsigned i = 0; i < array_size; i++) {
-                  l.stage[s].sampler_to_descriptor[sampler + i].set = set;
-                  l.stage[s].sampler_to_descriptor[sampler + i].offset = set_offset + i;
-               }
-               sampler += array_size;
-            }
-         }
-      }
-   }
-
-   /* Finally, we're done setting it up, copy into the allocated version */
-   *layout = l;
-
    *pPipelineLayout = anv_pipeline_layout_to_handle(layout);
 
    return VK_SUCCESS;
index 29343397b6ccd0474f3e161ca47a90d0eb2c80ce..06b961495c2d982ad6a52d4db218b0d287a92280 100644 (file)
@@ -986,25 +986,13 @@ struct anv_pipeline_layout {
    struct {
       struct anv_descriptor_set_layout *layout;
       uint32_t dynamic_offset_start;
-      struct {
-         uint32_t surface_start;
-         uint32_t sampler_start;
-         uint32_t image_start;
-      } stage[MESA_SHADER_STAGES];
    } set[MAX_SETS];
 
    uint32_t num_sets;
 
    struct {
       bool has_dynamic_offsets;
-      uint32_t surface_count;
-      struct anv_pipeline_binding *surface_to_descriptor;
-      uint32_t sampler_count;
-      struct anv_pipeline_binding *sampler_to_descriptor;
-      uint32_t image_count;
    } stage[MESA_SHADER_STAGES];
-
-   struct anv_pipeline_binding entries[0];
 };
 
 struct anv_buffer {