i965: Simplify SO_DECL handling.
authorKenneth Graunke <kenneth@whitecape.org>
Tue, 28 Feb 2017 22:05:55 +0000 (14:05 -0800)
committerKenneth Graunke <kenneth@whitecape.org>
Thu, 1 Jun 2017 07:08:29 +0000 (00:08 -0700)
We can initialize structs directly, avoid some temporaries, and cut out
about half of the skip component handling.

Reviewed-by: Rafael Antognolli <rafael.antognolli@intel.com>
src/mesa/drivers/dri/i965/genX_state_upload.c

index 5d45625c1c1d4746aca607f010c8d61b455dce6d..1f05eea4426d1fea27826489395ed15808b80bc8 100644 (file)
@@ -3080,25 +3080,15 @@ genX(upload_3dstate_so_decl_list)(struct brw_context *brw,
    for (unsigned i = 0; i < linked_xfb_info->NumOutputs; i++) {
       const struct gl_transform_feedback_output *output =
          &linked_xfb_info->Outputs[i];
-      struct GENX(SO_DECL) decl = {0};
       const int buffer = output->OutputBuffer;
       const int varying = output->OutputRegister;
-      const unsigned components = output->NumComponents;
-      unsigned component_mask = (1 << components) - 1;
       const unsigned stream_id = output->StreamId;
-      const unsigned decl_buffer_slot = buffer;
       assert(stream_id < MAX_VERTEX_STREAMS);
 
-      component_mask <<= output->ComponentOffset;
-
       buffer_mask[stream_id] |= 1 << buffer;
 
       assert(vue_map->varying_to_slot[varying] >= 0);
 
-      decl.OutputBufferSlot = decl_buffer_slot;
-      decl.RegisterIndex = vue_map->varying_to_slot[varying];
-      decl.ComponentMask = component_mask;
-
       /* Mesa doesn't store entries for gl_SkipComponents in the Outputs[]
        * array.  Instead, it simply increments DstOffset for the following
        * input by the number of components that should be skipped.
@@ -3111,28 +3101,23 @@ genX(upload_3dstate_so_decl_list)(struct brw_context *brw,
        */
       int skip_components = output->DstOffset - next_offset[buffer];
 
-      next_offset[buffer] += skip_components;
-
-      while (skip_components >= 4) {
-         struct GENX(SO_DECL) *d = &so_decl[stream_id][decls[stream_id]++];
-         d->HoleFlag = 1;
-         d->OutputBufferSlot = decl_buffer_slot;
-         d->ComponentMask = 0xf;
+      while (skip_components > 0) {
+         so_decl[stream_id][decls[stream_id]++] = (struct GENX(SO_DECL)) {
+            .HoleFlag = 1,
+            .OutputBufferSlot = output->OutputBuffer,
+            .ComponentMask = (1 << MIN2(skip_components, 4)) - 1,
+         };
          skip_components -= 4;
       }
 
-      if (skip_components > 0) {
-         struct GENX(SO_DECL) *d = &so_decl[stream_id][decls[stream_id]++];
-         d->HoleFlag = 1;
-         d->OutputBufferSlot = decl_buffer_slot;
-         d->ComponentMask = (1 << skip_components) - 1;
-      }
-
-      assert(output->DstOffset == next_offset[buffer]);
+      next_offset[buffer] = output->DstOffset + output->NumComponents;
 
-      next_offset[buffer] += components;
-
-      so_decl[stream_id][decls[stream_id]++] = decl;
+      so_decl[stream_id][decls[stream_id]++] = (struct GENX(SO_DECL)) {
+         .OutputBufferSlot = output->OutputBuffer,
+         .RegisterIndex = vue_map->varying_to_slot[varying],
+         .ComponentMask =
+            ((1 << output->NumComponents) - 1) << output->ComponentOffset,
+      };
 
       if (decls[stream_id] > max_decls)
          max_decls = decls[stream_id];