[Mesa-dev] [PATCH 2/7] translate_sse: Rename translate_buffer_variant to translate_group.

Andreas Hartmetz ahartmetz at gmail.com
Sun Apr 13 13:29:33 PDT 2014


From: Andreas Hartmetz <andreas.hartmetz at kdab.com>

It is a better description of what goes on and it's shorter, too.
---
 src/gallium/auxiliary/translate/translate_sse.c | 86 ++++++++++++-------------
 1 file changed, 43 insertions(+), 43 deletions(-)

diff --git a/src/gallium/auxiliary/translate/translate_sse.c b/src/gallium/auxiliary/translate/translate_sse.c
index 24d8017..e25d450 100644
--- a/src/gallium/auxiliary/translate/translate_sse.c
+++ b/src/gallium/auxiliary/translate/translate_sse.c
@@ -61,7 +61,7 @@ struct translate_buffer
  * This describes a group of trivially compatible translations.
  * ptr is only used at runtime (not code generation time).
  */
-struct translate_buffer_variant
+struct translate_group
 {
    unsigned buffer_index;
    unsigned instance_divisor;
@@ -115,11 +115,11 @@ struct translate_sse
    unsigned nr_buffers;
 
    /* Multiple buffer variants can map to a single buffer. */
-   struct translate_buffer_variant buffer_variant[TRANSLATE_MAX_ATTRIBS];
-   unsigned nr_buffer_variants;
+   struct translate_group group[TRANSLATE_MAX_ATTRIBS];
+   unsigned nr_groups;
 
    /* Multiple elements can map to a single buffer variant. */
-   unsigned element_to_buffer_variant[TRANSLATE_MAX_ATTRIBS];
+   unsigned element_to_group[TRANSLATE_MAX_ATTRIBS];
 
    boolean use_instancing;
    unsigned instance_id;
@@ -1085,17 +1085,17 @@ init_inputs(struct translate_sse *p, unsigned index_size)
    struct x86_reg start_instance =
       x86_make_disp(p->machine_EDI, get_offset(p, &p->start_instance));
 
-   for (i = 0; i < p->nr_buffer_variants; i++) {
-      struct translate_buffer_variant *variant = &p->buffer_variant[i];
-      struct translate_buffer *buffer = &p->buffer[variant->buffer_index];
+   for (i = 0; i < p->nr_groups; i++) {
+      struct translate_group *group = &p->group[i];
+      struct translate_buffer *buffer = &p->buffer[group->buffer_index];
 
-      if (!index_size || variant->instance_divisor) {
+      if (!index_size || group->instance_divisor) {
          struct x86_reg buf_max_index =
             x86_make_disp(p->machine_EDI, get_offset(p, &buffer->max_index));
          struct x86_reg buf_stride =
             x86_make_disp(p->machine_EDI, get_offset(p, &buffer->stride));
          struct x86_reg buf_ptr =
-            x86_make_disp(p->machine_EDI, get_offset(p, &variant->ptr));
+            x86_make_disp(p->machine_EDI, get_offset(p, &group->ptr));
          struct x86_reg buf_base_ptr =
             x86_make_disp(p->machine_EDI, get_offset(p, &buffer->base_ptr));
          struct x86_reg elt = p->idx_ESI;
@@ -1104,13 +1104,13 @@ init_inputs(struct translate_sse *p, unsigned index_size)
          /* Calculate pointer to first attrib:
           *   base_ptr + stride * index, where index depends on instance divisor
           */
-         if (variant->instance_divisor) {
+         if (group->instance_divisor) {
             /* Start with instance = instance_id
              * which is true if divisor is 1.
              */
             x86_mov(p->func, tmp_EAX, instance_id);
 
-            if (variant->instance_divisor != 1) {
+            if (group->instance_divisor != 1) {
                struct x86_reg tmp_EDX = p->tmp2_EDX;
                struct x86_reg tmp_ECX = p->src_ECX;
 
@@ -1118,7 +1118,7 @@ init_inputs(struct translate_sse *p, unsigned index_size)
                 *       instance divisor is power of two.
                 */
                x86_xor(p->func, tmp_EDX, tmp_EDX);
-               x86_mov_reg_imm(p->func, tmp_ECX, variant->instance_divisor);
+               x86_mov_reg_imm(p->func, tmp_ECX, group->instance_divisor);
                x86_div(p->func, tmp_ECX);       /* EAX = EDX:EAX / ECX */
 
                /* instance = (instance_id - start_instance) / divisor + 
@@ -1153,7 +1153,7 @@ init_inputs(struct translate_sse *p, unsigned index_size)
          /* In the linear case, keep the buffer pointer instead of the
           * index number.
           */
-         if (!index_size && p->nr_buffer_variants == 1) {
+         if (!index_size && p->nr_groups == 1) {
             x64_rexw(p->func);
             x86_mov(p->func, elt, tmp_EAX);
          }
@@ -1175,14 +1175,14 @@ get_buffer_ptr(struct translate_sse *p,
    if (var_idx == ELEMENT_BUFFER_INSTANCE_ID) {
       return x86_make_disp(p->machine_EDI, get_offset(p, &p->instance_id));
    }
-   if (!index_size && p->nr_buffer_variants == 1) {
+   if (!index_size && p->nr_groups == 1) {
       return p->idx_ESI;
    }
-   else if (!index_size || p->buffer_variant[var_idx].instance_divisor) {
+   else if (!index_size || p->group[var_idx].instance_divisor) {
       struct x86_reg ptr = p->src_ECX;
       struct x86_reg buf_ptr =
          x86_make_disp(p->machine_EDI,
-                       get_offset(p, &p->buffer_variant[var_idx].ptr));
+                       get_offset(p, &p->group[var_idx].ptr));
 
       x64_rexw(p->func);
       x86_mov(p->func, ptr, buf_ptr);
@@ -1190,17 +1190,17 @@ get_buffer_ptr(struct translate_sse *p,
    }
    else {
       struct x86_reg ptr = p->src_ECX;
-      const struct translate_buffer_variant *variant =
-         &p->buffer_variant[var_idx];
+      const struct translate_group *group =
+         &p->group[var_idx];
       struct x86_reg buf_stride =
          x86_make_disp(p->machine_EDI,
-                       get_offset(p, &p->buffer[variant->buffer_index].stride));
+                       get_offset(p, &p->buffer[group->buffer_index].stride));
       struct x86_reg buf_base_ptr =
          x86_make_disp(p->machine_EDI,
-                  get_offset(p, &p->buffer[variant->buffer_index].base_ptr));
+                  get_offset(p, &p->buffer[group->buffer_index].base_ptr));
       struct x86_reg buf_max_index =
          x86_make_disp(p->machine_EDI,
-                  get_offset(p, &p->buffer[variant->buffer_index].max_index));
+                  get_offset(p, &p->buffer[group->buffer_index].max_index));
 
       /* Calculate pointer to current attrib:
        */
@@ -1234,11 +1234,11 @@ get_buffer_ptr(struct translate_sse *p,
 static boolean
 incr_inputs(struct translate_sse *p, unsigned index_size)
 {
-   if (!index_size && p->nr_buffer_variants == 1) {
+   if (!index_size && p->nr_groups == 1) {
       struct x86_reg stride =
          x86_make_disp(p->machine_EDI, get_offset(p, &p->buffer[0].stride));
 
-      if (p->buffer_variant[0].instance_divisor == 0) {
+      if (p->group[0].instance_divisor == 0) {
          x64_rexw(p->func);
          x86_add(p->func, p->idx_ESI, stride);
          sse_prefetchnta(p->func, x86_make_disp(p->idx_ESI, 192));
@@ -1249,15 +1249,15 @@ incr_inputs(struct translate_sse *p, unsigned index_size)
 
       /* Is this worthwhile??
        */
-      for (i = 0; i < p->nr_buffer_variants; i++) {
-         struct translate_buffer_variant *variant = &p->buffer_variant[i];
+      for (i = 0; i < p->nr_groups; i++) {
+         struct translate_group *group = &p->group[i];
          struct x86_reg buf_ptr = x86_make_disp(p->machine_EDI,
-                                                get_offset(p, &variant->ptr));
+                                                get_offset(p, &group->ptr));
       struct x86_reg buf_stride =
          x86_make_disp(p->machine_EDI,
-                       get_offset(p, &p->buffer[variant->buffer_index].stride));
+                       get_offset(p, &p->buffer[group->buffer_index].stride));
 
-         if (variant->instance_divisor == 0) {
+         if (group->instance_divisor == 0) {
             x86_mov(p->func, p->tmp_EAX, buf_stride);
             x64_rexw(p->func);
             x86_add(p->func, p->tmp_EAX, buf_ptr);
@@ -1380,18 +1380,18 @@ build_vertex_emit(struct translate_sse *p,
    label = x86_get_label(p->func);
    {
       struct x86_reg elt = !index_size ? p->idx_ESI : x86_deref(p->idx_ESI);
-      int last_variant = -1;
+      int last_group = -1;
       struct x86_reg vb;
 
       for (j = 0; j < p->translate.key.nr_elements; j++) {
          const struct translate_element *a = &p->translate.key.element[j];
-         unsigned variant = p->element_to_buffer_variant[j];
+         unsigned group = p->element_to_group[j];
 
          /* Figure out source pointer address:
           */
-         if (variant != last_variant) {
-            last_variant = variant;
-            vb = get_buffer_ptr(p, index_size, variant, elt);
+         if (group != last_group) {
+            last_group = group;
+            vb = get_buffer_ptr(p, index_size, group, elt);
          }
 
          if (!translate_attr(p, a,
@@ -1515,28 +1515,28 @@ translate_sse2_create(const struct translate_key *key)
          }
 
          /*
-          * Map vertex element to vertex buffer variant.
+          * Map vertex element to vertex buffer group.
           */
-         for (j = 0; j < p->nr_buffer_variants; j++) {
-            if (p->buffer_variant[j].buffer_index ==
+         for (j = 0; j < p->nr_groups; j++) {
+            if (p->group[j].buffer_index ==
                 key->element[i].input_buffer
-                && p->buffer_variant[j].instance_divisor ==
+                && p->group[j].instance_divisor ==
                 key->element[i].instance_divisor) {
                break;
             }
          }
-         if (j == p->nr_buffer_variants) {
-            p->buffer_variant[j].buffer_index = key->element[i].input_buffer;
-            p->buffer_variant[j].instance_divisor =
+         if (j == p->nr_groups) {
+            p->group[j].buffer_index = key->element[i].input_buffer;
+            p->group[j].instance_divisor =
                key->element[i].instance_divisor;
-            p->nr_buffer_variants++;
+            p->nr_groups++;
          }
-         p->element_to_buffer_variant[i] = j;
+         p->element_to_group[i] = j;
       }
       else {
          assert(key->element[i].type == TRANSLATE_ELEMENT_INSTANCE_ID);
 
-         p->element_to_buffer_variant[i] = ELEMENT_BUFFER_INSTANCE_ID;
+         p->element_to_group[i] = ELEMENT_BUFFER_INSTANCE_ID;
       }
    }
 
-- 
1.9.1



More information about the mesa-dev mailing list