Mesa (master): mesa/prog: Reuse count_vec4_slots() from ir_to_mesa.

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Jan 15 00:28:40 UTC 2020


Module: Mesa
Branch: master
Commit: 4cabd4812a6b2a15d15cd889778a36956574c9a3
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=4cabd4812a6b2a15d15cd889778a36956574c9a3

Author: Eric Anholt <eric at anholt.net>
Date:   Mon Jan  6 13:19:30 2020 -0800

mesa/prog: Reuse count_vec4_slots() from ir_to_mesa.

Reviewed-by: Kristian H. Kristensen <hoegsberg at google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3297>

---

 src/mesa/program/ir_to_mesa.cpp | 76 +----------------------------------------
 1 file changed, 1 insertion(+), 75 deletions(-)

diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp
index bcf50c505e1..dfc52e718d1 100644
--- a/src/mesa/program/ir_to_mesa.cpp
+++ b/src/mesa/program/ir_to_mesa.cpp
@@ -499,84 +499,10 @@ ir_to_mesa_visitor::src_reg_for_float(float val)
    return src;
 }
 
-static int
-storage_type_size(const struct glsl_type *type, bool bindless)
-{
-   unsigned int i;
-   int size;
-
-   switch (type->base_type) {
-   case GLSL_TYPE_UINT:
-   case GLSL_TYPE_INT:
-   case GLSL_TYPE_UINT8:
-   case GLSL_TYPE_INT8:
-   case GLSL_TYPE_UINT16:
-   case GLSL_TYPE_INT16:
-   case GLSL_TYPE_FLOAT:
-   case GLSL_TYPE_FLOAT16:
-   case GLSL_TYPE_BOOL:
-      if (type->is_matrix()) {
-	 return type->matrix_columns;
-      } else {
-	 /* Regardless of size of vector, it gets a vec4. This is bad
-	  * packing for things like floats, but otherwise arrays become a
-	  * mess.  Hopefully a later pass over the code can pack scalars
-	  * down if appropriate.
-	  */
-	 return 1;
-      }
-      break;
-   case GLSL_TYPE_DOUBLE:
-      if (type->is_matrix()) {
-         if (type->vector_elements > 2)
-            return type->matrix_columns * 2;
-         else
-            return type->matrix_columns;
-      } else {
-         if (type->vector_elements > 2)
-            return 2;
-         else
-            return 1;
-      }
-      break;
-   case GLSL_TYPE_UINT64:
-   case GLSL_TYPE_INT64:
-      if (type->vector_elements > 2)
-         return 2;
-      else
-         return 1;
-   case GLSL_TYPE_ARRAY:
-      assert(type->length > 0);
-      return storage_type_size(type->fields.array, bindless) * type->length;
-   case GLSL_TYPE_STRUCT:
-      size = 0;
-      for (i = 0; i < type->length; i++) {
-	 size += storage_type_size(type->fields.structure[i].type, bindless);
-      }
-      return size;
-   case GLSL_TYPE_SAMPLER:
-   case GLSL_TYPE_IMAGE:
-      if (!bindless)
-         return 0;
-      /* fall through */
-   case GLSL_TYPE_SUBROUTINE:
-      return 1;
-   case GLSL_TYPE_ATOMIC_UINT:
-   case GLSL_TYPE_VOID:
-   case GLSL_TYPE_ERROR:
-   case GLSL_TYPE_INTERFACE:
-   case GLSL_TYPE_FUNCTION:
-      assert(!"Invalid type in type_size");
-      break;
-   }
-
-   return 0;
-}
-
 static int
 type_size(const struct glsl_type *type)
 {
-   return storage_type_size(type, false);
+   return type->count_vec4_slots(false, false);
 }
 
 /**



More information about the mesa-commit mailing list