st/mesa: get rid of st_glsl_types
authorNicolai Hähnle <nicolai.haehnle@amd.com>
Tue, 4 Jul 2017 08:22:02 +0000 (10:22 +0200)
committerNicolai Hähnle <nicolai.haehnle@amd.com>
Mon, 31 Jul 2017 12:55:30 +0000 (14:55 +0200)
It's a duplicate of glsl_type::count_attribute_slots.

Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
src/compiler/glsl_types.cpp
src/gallium/drivers/freedreno/ir3/ir3_cmdline.c
src/gallium/drivers/freedreno/ir3/ir3_shader.c
src/gallium/drivers/freedreno/ir3/ir3_shader.h
src/gallium/drivers/vc4/vc4_program.c
src/mesa/Makefile.sources
src/mesa/state_tracker/st_glsl_to_nir.cpp
src/mesa/state_tracker/st_glsl_to_tgsi.cpp
src/mesa/state_tracker/st_glsl_types.cpp [deleted file]
src/mesa/state_tracker/st_glsl_types.h [deleted file]

index 188b72f345ac411cc2435488d1874059a5dfd2dd..99cc696c19bfa08f0983e655361b7fbec42b5a29 100644 (file)
@@ -1999,10 +1999,12 @@ glsl_type::count_attribute_slots(bool is_vertex_input) const
    case GLSL_TYPE_ARRAY:
       return this->length * this->fields.array->count_attribute_slots(is_vertex_input);
 
+   case GLSL_TYPE_SUBROUTINE:
+      return 1;
+
    case GLSL_TYPE_FUNCTION:
    case GLSL_TYPE_ATOMIC_UINT:
    case GLSL_TYPE_VOID:
-   case GLSL_TYPE_SUBROUTINE:
    case GLSL_TYPE_ERROR:
       break;
    }
index fdec3f20b0da5904677b8847b1f88aff6e0a8e38..cfcb807de31553887c3f6f5b44ebd0180b54f6a9 100644 (file)
@@ -46,6 +46,7 @@
 
 #include "compiler/glsl/standalone.h"
 #include "compiler/glsl/glsl_to_nir.h"
+#include "compiler/nir_types.h"
 
 static void dump_info(struct ir3_shader_variant *so, const char *str)
 {
@@ -57,8 +58,6 @@ static void dump_info(struct ir3_shader_variant *so, const char *str)
        free(bin);
 }
 
-int st_glsl_type_size(const struct glsl_type *type);
-
 static void
 insert_sorted(struct exec_list *var_list, nir_variable *new_var)
 {
@@ -131,7 +130,7 @@ load_glsl(unsigned num_files, char* const* files, gl_shader_stage stage)
        case MESA_SHADER_VERTEX:
                nir_assign_var_locations(&nir->inputs,
                                &nir->num_inputs,
-                               st_glsl_type_size);
+                               ir3_glsl_type_size);
 
                /* Re-lower global vars, to deal with any dead VS inputs. */
                NIR_PASS_V(nir, nir_lower_global_vars_to_local);
@@ -139,18 +138,18 @@ load_glsl(unsigned num_files, char* const* files, gl_shader_stage stage)
                sort_varyings(&nir->outputs);
                nir_assign_var_locations(&nir->outputs,
                                &nir->num_outputs,
-                               st_glsl_type_size);
+                               ir3_glsl_type_size);
                fixup_varying_slots(&nir->outputs);
                break;
        case MESA_SHADER_FRAGMENT:
                sort_varyings(&nir->inputs);
                nir_assign_var_locations(&nir->inputs,
                                &nir->num_inputs,
-                               st_glsl_type_size);
+                               ir3_glsl_type_size);
                fixup_varying_slots(&nir->inputs);
                nir_assign_var_locations(&nir->outputs,
                                &nir->num_outputs,
-                               st_glsl_type_size);
+                               ir3_glsl_type_size);
                break;
        default:
                errx(1, "unhandled shader stage: %d", stage);
@@ -158,10 +157,10 @@ load_glsl(unsigned num_files, char* const* files, gl_shader_stage stage)
 
        nir_assign_var_locations(&nir->uniforms,
                        &nir->num_uniforms,
-                       st_glsl_type_size);
+                       ir3_glsl_type_size);
 
        NIR_PASS_V(nir, nir_lower_system_values);
-       NIR_PASS_V(nir, nir_lower_io, nir_var_all, st_glsl_type_size, 0);
+       NIR_PASS_V(nir, nir_lower_io, nir_var_all, ir3_glsl_type_size, 0);
        NIR_PASS_V(nir, nir_lower_samplers, prog);
 
        return nir;
index a176f16e722cfd1849f96e3a707b370bc8f4c951..636111b10360c9468f2feadc953f43e8c4f779c5 100644 (file)
 #include "ir3_compiler.h"
 #include "ir3_nir.h"
 
+int
+ir3_glsl_type_size(const struct glsl_type *type)
+{
+       return glsl_count_attribute_slots(type, false);
+}
+
 static void
 delete_variant(struct ir3_shader_variant *v)
 {
index 6c2af6d3664596e59fa5bd59622c028948f87f5e..9984809ea24f74277c28d326149bfaa19c53c8bf 100644 (file)
@@ -36,6 +36,8 @@
 #include "ir3.h"
 #include "disasm.h"
 
+struct glsl_type;
+
 /* driver param indices: */
 enum ir3_driver_param {
        /* compute shader driver params: */
@@ -339,6 +341,9 @@ void ir3_emit_fs_consts(const struct ir3_shader_variant *v, struct fd_ringbuffer
 void ir3_emit_cs_consts(const struct ir3_shader_variant *v, struct fd_ringbuffer *ring,
                struct fd_context *ctx, const struct pipe_grid_info *info);
 
+int
+ir3_glsl_type_size(const struct glsl_type *type);
+
 static inline const char *
 ir3_shader_stage(struct ir3_shader *shader)
 {
index 60eb68e847b03a5f480d7bf1a3c74d7a62af208e..3beac61f3136a44f6a86c0b528e4e04f6520914a 100644 (file)
 #include "tgsi/tgsi_parse.h"
 #include "compiler/nir/nir.h"
 #include "compiler/nir/nir_builder.h"
+#include "compiler/nir_types.h"
 #include "nir/tgsi_to_nir.h"
 #include "vc4_context.h"
 #include "vc4_qpu.h"
 #include "vc4_qir.h"
-#include "mesa/state_tracker/st_glsl_types.h"
 
 static struct qreg
 ntq_get_src(struct vc4_compile *c, nir_src src, int i);
 static void
 ntq_emit_cf_list(struct vc4_compile *c, struct exec_list *list);
 
+static int
+type_size(const struct glsl_type *type)
+{
+   return glsl_count_attribute_slots(type, false);
+}
+
 static void
 resize_qreg_array(struct vc4_compile *c,
                   struct qreg **regs,
@@ -1653,7 +1659,7 @@ static void
 ntq_setup_uniforms(struct vc4_compile *c)
 {
         nir_foreach_variable(var, &c->s->uniforms) {
-                uint32_t vec4_count = st_glsl_type_size(var->type);
+                uint32_t vec4_count = type_size(var->type);
                 unsigned vec4_size = 4 * sizeof(float);
 
                 declare_uniform_range(c, var->data.driver_location * vec4_size,
index a21c9084c4c6cd5a789b3379d4120a91fc2a3201..97c8287acbc0d1edb55999b3e558657a2143af3e 100644 (file)
@@ -507,8 +507,6 @@ STATETRACKER_FILES = \
        state_tracker/st_glsl_to_nir.cpp \
        state_tracker/st_glsl_to_tgsi.cpp \
        state_tracker/st_glsl_to_tgsi.h \
-       state_tracker/st_glsl_types.cpp \
-       state_tracker/st_glsl_types.h \
        state_tracker/st_manager.c \
        state_tracker/st_manager.h \
        state_tracker/st_mesa_to_tgsi.c \
index c8a7464a0080ca3ddf3bef5bf38bd3654d7ce305..dd3d6faa753e0a9b893721f2cdf05737dc470b1f 100644 (file)
@@ -39,7 +39,6 @@
 
 #include "st_context.h"
 #include "st_program.h"
-#include "st_glsl_types.h"
 
 #include "compiler/nir/nir.h"
 #include "compiler/glsl_types.h"
 #include "compiler/glsl/ir.h"
 
 
+static int
+type_size(const struct glsl_type *type)
+{
+   return type->count_attribute_slots(false);
+}
+
 /* Depending on PIPE_CAP_TGSI_TEXCOORD (st->needs_texcoord_semantic) we
  * may need to fix up varying slots so the glsl->nir path is aligned
  * with the anything->tgsi->nir path.
@@ -205,7 +210,7 @@ st_nir_assign_uniform_locations(struct gl_program *prog,
 
       uniform->data.driver_location = loc;
 
-      max = MAX2(max, loc + st_glsl_type_size(uniform->type));
+      max = MAX2(max, loc + type_size(uniform->type));
    }
    *size = max;
 }
@@ -332,17 +337,17 @@ st_finalize_nir(struct st_context *st, struct gl_program *prog, nir_shader *nir)
       sort_varyings(&nir->outputs);
       nir_assign_var_locations(&nir->outputs,
                                &nir->num_outputs,
-                               st_glsl_type_size);
+                               type_size);
       st_nir_fixup_varying_slots(st, &nir->outputs);
    } else if (nir->stage == MESA_SHADER_FRAGMENT) {
       sort_varyings(&nir->inputs);
       nir_assign_var_locations(&nir->inputs,
                                &nir->num_inputs,
-                               st_glsl_type_size);
+                               type_size);
       st_nir_fixup_varying_slots(st, &nir->inputs);
       nir_assign_var_locations(&nir->outputs,
                                &nir->num_outputs,
-                               st_glsl_type_size);
+                               type_size);
    } else if (nir->stage == MESA_SHADER_COMPUTE) {
        /* TODO? */
    } else {
@@ -372,7 +377,7 @@ st_finalize_nir(struct st_context *st, struct gl_program *prog, nir_shader *nir)
                                    &nir->uniforms, &nir->num_uniforms);
 
    NIR_PASS_V(nir, nir_lower_system_values);
-   NIR_PASS_V(nir, nir_lower_io, nir_var_all, st_glsl_type_size,
+   NIR_PASS_V(nir, nir_lower_io, nir_var_all, type_size,
               (nir_lower_io_options)0);
    if (screen->get_param(screen, PIPE_CAP_NIR_SAMPLERS_AS_DEREF))
       NIR_PASS_V(nir, nir_lower_samplers_as_deref, shader_program);
index 3983fe75b8dc0bac6f2c931636d4e76f1f48a3c7..2fca398a517f66e65371e7556755a7d54f59e260 100644 (file)
@@ -52,7 +52,6 @@
 #include "st_program.h"
 #include "st_mesa_to_tgsi.h"
 #include "st_format.h"
-#include "st_glsl_types.h"
 #include "st_nir.h"
 #include "st_shader_cache.h"
 
@@ -1238,13 +1237,13 @@ glsl_to_tgsi_visitor::st_src_reg_for_type(enum glsl_base_type type, int val)
 static int
 attrib_type_size(const struct glsl_type *type, bool is_vs_input)
 {
-   return st_glsl_attrib_type_size(type, is_vs_input);
+   return type->count_attribute_slots(is_vs_input);
 }
 
 static int
 type_size(const struct glsl_type *type)
 {
-   return st_glsl_type_size(type);
+   return type->count_attribute_slots(false);
 }
 
 /**
diff --git a/src/mesa/state_tracker/st_glsl_types.cpp b/src/mesa/state_tracker/st_glsl_types.cpp
deleted file mode 100644 (file)
index 37c3164..0000000
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Copyright (C) 2005-2007  Brian Paul   All Rights Reserved.
- * Copyright (C) 2008  VMware, Inc.   All Rights Reserved.
- * Copyright © 2010 Intel Corporation
- * Copyright © 2011 Bryan Cain
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- */
-
-#include "st_glsl_types.h"
-
-/**
- * Returns type size in units of vec4 slots.
- */
-int
-st_glsl_attrib_type_size(const struct glsl_type *type, bool is_vs_input)
-{
-   unsigned int i;
-   int size;
-
-   switch (type->base_type) {
-   case GLSL_TYPE_UINT:
-   case GLSL_TYPE_INT:
-   case GLSL_TYPE_FLOAT:
-   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 || is_vs_input)
-            return type->matrix_columns;
-         else
-            return type->matrix_columns * 2;
-      } else {
-         /* For doubles if we have a double or dvec2 they fit in one
-          * vec4, else they need 2 vec4s.
-          */
-         if (type->vector_elements <= 2 || is_vs_input)
-            return 1;
-         else
-            return 2;
-      }
-      break;
-   case GLSL_TYPE_UINT64:
-   case GLSL_TYPE_INT64:
-      if (type->vector_elements <= 2 || is_vs_input)
-         return 1;
-      else
-         return 2;
-   case GLSL_TYPE_ARRAY:
-      assert(type->length > 0);
-      return st_glsl_attrib_type_size(type->fields.array, is_vs_input) * type->length;
-   case GLSL_TYPE_STRUCT:
-      size = 0;
-      for (i = 0; i < type->length; i++) {
-         size += st_glsl_attrib_type_size(type->fields.structure[i].type, is_vs_input);
-      }
-      return size;
-   case GLSL_TYPE_SAMPLER:
-   case GLSL_TYPE_IMAGE:
-   case GLSL_TYPE_SUBROUTINE:
-      /* Samplers take up one slot in UNIFORMS[], but they're baked in
-       * at link time.
-       */
-      return 1;
-   case GLSL_TYPE_ATOMIC_UINT:
-   case GLSL_TYPE_INTERFACE:
-   case GLSL_TYPE_VOID:
-   case GLSL_TYPE_ERROR:
-   case GLSL_TYPE_FUNCTION:
-      assert(!"Invalid type in type_size");
-      break;
-   }
-   return 0;
-}
-
-int
-st_glsl_type_size(const struct glsl_type *type)
-{
-   return st_glsl_attrib_type_size(type, false);
-}
diff --git a/src/mesa/state_tracker/st_glsl_types.h b/src/mesa/state_tracker/st_glsl_types.h
deleted file mode 100644 (file)
index 3a39cee..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (C) 2005-2007  Brian Paul   All Rights Reserved.
- * Copyright (C) 2008  VMware, Inc.   All Rights Reserved.
- * Copyright © 2010 Intel Corporation
- * Copyright © 2011 Bryan Cain
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- */
-
-#ifndef __ST_GLSL_TYPES_H__
-#define __ST_GLSL_TYPES_H__
-
-#include "compiler/glsl_types.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-int st_glsl_attrib_type_size(const struct glsl_type *type, bool is_vs_input);
-int st_glsl_type_size(const struct glsl_type *type);
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __ST_GLSL_TYPES_H__ */