Put static pointers to vec[234]_types along with the static float_type.
authorEric Anholt <eric@anholt.net>
Thu, 22 Apr 2010 16:47:27 +0000 (09:47 -0700)
committerIan Romanick <ian.d.romanick@intel.com>
Fri, 23 Apr 2010 23:12:44 +0000 (16:12 -0700)
Otherwise you have to type a lot of get_instance.

builtin_function.cpp
builtin_types.h
glsl_types.h
ir_variable.cpp

index a6e1d3703656f3763a4ccf5a47b2d3586a64cd7e..c9383e17cc9ca323e185d4de2e9699a5d9dfad67 100644 (file)
@@ -296,10 +296,6 @@ make_gentype_function(glsl_symbol_table *symtab, exec_list *instructions,
                                       const glsl_type *type))
 {
    ir_function *const f = new ir_function(name);
-   const glsl_type *float_type = glsl_type::float_type;
-   const glsl_type *vec2_type = glsl_type::get_instance(GLSL_TYPE_FLOAT, 2, 1);
-   const glsl_type *vec3_type = glsl_type::get_instance(GLSL_TYPE_FLOAT, 3, 1);
-   const glsl_type *vec4_type = glsl_type::get_instance(GLSL_TYPE_FLOAT, 4, 1);
 
    bool added = symtab->add_function(name, f);
    assert(added);
@@ -307,13 +303,13 @@ make_gentype_function(glsl_symbol_table *symtab, exec_list *instructions,
    instructions->push_tail(f);
 
    generate_function_instance(f, name, instructions, n_args, generate,
-                             float_type, float_type);
+                             glsl_type::float_type, glsl_type::float_type);
    generate_function_instance(f, name, instructions, n_args, generate,
-                             vec2_type, vec2_type);
+                             glsl_type::vec2_type, glsl_type::vec2_type);
    generate_function_instance(f, name, instructions, n_args, generate,
-                             vec3_type, vec3_type);
+                             glsl_type::vec3_type, glsl_type::vec3_type);
    generate_function_instance(f, name, instructions, n_args, generate,
-                             vec4_type, vec4_type);
+                             glsl_type::vec4_type, glsl_type::vec4_type);
 }
 
 static void
@@ -409,9 +405,6 @@ generate_vec_compare_function(glsl_symbol_table *symtab,
                              bool do_bool)
 {
    ir_function *const f = new ir_function(name);
-   const glsl_type *vec2_type = glsl_type::get_instance(GLSL_TYPE_FLOAT, 2, 1);
-   const glsl_type *vec3_type = glsl_type::get_instance(GLSL_TYPE_FLOAT, 3, 1);
-   const glsl_type *vec4_type = glsl_type::get_instance(GLSL_TYPE_FLOAT, 4, 1);
    const glsl_type *ivec2_type = glsl_type::get_instance(GLSL_TYPE_INT, 2, 1);
    const glsl_type *ivec3_type = glsl_type::get_instance(GLSL_TYPE_INT, 3, 1);
    const glsl_type *ivec4_type = glsl_type::get_instance(GLSL_TYPE_INT, 4, 1);
@@ -428,11 +421,11 @@ generate_vec_compare_function(glsl_symbol_table *symtab,
    instructions->push_tail(f);
 
    generate_function_instance(f, name, instructions, 2, generate,
-                             bvec2_type, vec2_type);
+                             bvec2_type, glsl_type::vec2_type);
    generate_function_instance(f, name, instructions, 2, generate,
-                             bvec3_type, vec3_type);
+                             bvec3_type, glsl_type::vec3_type);
    generate_function_instance(f, name, instructions, 2, generate,
-                             bvec4_type, vec4_type);
+                             bvec4_type, glsl_type::vec4_type);
 
    generate_function_instance(f, name, instructions, 2, generate,
                              bvec2_type, ivec2_type);
@@ -482,10 +475,6 @@ generate_length_functions(glsl_symbol_table *symtab, exec_list *instructions)
 {
    const char *name = "length";
    ir_function *const f = new ir_function(name);
-   const glsl_type *float_type = glsl_type::float_type;
-   const glsl_type *vec2_type = glsl_type::get_instance(GLSL_TYPE_FLOAT, 2, 1);
-   const glsl_type *vec3_type = glsl_type::get_instance(GLSL_TYPE_FLOAT, 3, 1);
-   const glsl_type *vec4_type = glsl_type::get_instance(GLSL_TYPE_FLOAT, 4, 1);
 
    bool added = symtab->add_function(name, f);
    assert(added);
@@ -493,13 +482,13 @@ generate_length_functions(glsl_symbol_table *symtab, exec_list *instructions)
    instructions->push_tail(f);
 
    generate_function_instance(f, name, instructions, 1, generate_length,
-                             float_type, float_type);
+                             glsl_type::float_type, glsl_type::float_type);
    generate_function_instance(f, name, instructions, 1, generate_length,
-                             float_type, vec2_type);
+                             glsl_type::float_type, glsl_type::vec2_type);
    generate_function_instance(f, name, instructions, 1, generate_length,
-                             float_type, vec3_type);
+                             glsl_type::float_type, glsl_type::vec3_type);
    generate_function_instance(f, name, instructions, 1, generate_length,
-                             float_type, vec4_type);
+                             glsl_type::float_type, glsl_type::vec4_type);
 }
 
 static void
@@ -524,10 +513,6 @@ generate_dot_functions(glsl_symbol_table *symtab, exec_list *instructions)
 {
    const char *name = "dot";
    ir_function *const f = new ir_function(name);
-   const glsl_type *float_type = glsl_type::float_type;
-   const glsl_type *vec2_type = glsl_type::get_instance(GLSL_TYPE_FLOAT, 2, 1);
-   const glsl_type *vec3_type = glsl_type::get_instance(GLSL_TYPE_FLOAT, 3, 1);
-   const glsl_type *vec4_type = glsl_type::get_instance(GLSL_TYPE_FLOAT, 4, 1);
 
    bool added = symtab->add_function(name, f);
    assert(added);
@@ -535,13 +520,13 @@ generate_dot_functions(glsl_symbol_table *symtab, exec_list *instructions)
    instructions->push_tail(f);
 
    generate_function_instance(f, name, instructions, 2, generate_dot,
-                             float_type, float_type);
+                             glsl_type::float_type, glsl_type::float_type);
    generate_function_instance(f, name, instructions, 2, generate_dot,
-                             float_type, vec2_type);
+                             glsl_type::float_type, glsl_type::vec2_type);
    generate_function_instance(f, name, instructions, 2, generate_dot,
-                             float_type, vec3_type);
+                             glsl_type::float_type, glsl_type::vec3_type);
    generate_function_instance(f, name, instructions, 2, generate_dot,
-                             float_type, vec4_type);
+                             glsl_type::float_type, glsl_type::vec4_type);
 }
 
 static void
index 73910fd4af0f0a242a2ae68c5a8ec149360f7edf..7f97d6fa86d04d3e1413ccfcbc3fb873c3a40e15 100644 (file)
@@ -66,6 +66,9 @@ static const struct glsl_type builtin_core_types[] = {
 const glsl_type *const glsl_type::bool_type  = & builtin_core_types[0];
 const glsl_type *const glsl_type::int_type   = & builtin_core_types[4];
 const glsl_type *const glsl_type::float_type = & builtin_core_types[8];
+const glsl_type *const glsl_type::vec2_type = & builtin_core_types[9];
+const glsl_type *const glsl_type::vec3_type = & builtin_core_types[10];
+const glsl_type *const glsl_type::vec4_type = & builtin_core_types[11];
 const glsl_type *const glsl_type::mat2_type = & builtin_core_types[12];
 const glsl_type *const glsl_type::mat3_type = & builtin_core_types[13];
 const glsl_type *const glsl_type::mat4_type = & builtin_core_types[14];
index 33b1c98158d08aad30a4b6a155689c98a06a4e84..c6288683013091e392ad30c6ffb79936fc46efca 100644 (file)
@@ -110,6 +110,9 @@ struct glsl_type {
    static const glsl_type *const int_type;
    static const glsl_type *const uint_type;
    static const glsl_type *const float_type;
+   static const glsl_type *const vec2_type;
+   static const glsl_type *const vec3_type;
+   static const glsl_type *const vec4_type;
    static const glsl_type *const bool_type;
    /*@}*/
 
index a2c0803e55a44de7e590682712303cd73f5b62a6..ba91d566dfc9841e914f70fd7721b631fc8e624e 100644 (file)
@@ -137,10 +137,8 @@ generate_110_vs_variables(exec_list *instructions,
     * FINISHME: value of GL_MAX_TEXTURE_COORDS.  GL_MAX_TEXTURE_COORDS must be
     * FINISHME: at least 2, so hard-code 2 for now.
     */
-   const glsl_type *const vec4_type =
-      glsl_type::get_instance(GLSL_TYPE_FLOAT, 4, 1);
    const glsl_type *const vec4_array_type =
-      glsl_type::get_array_instance(vec4_type, 2);
+      glsl_type::get_array_instance(glsl_type::vec4_type, 2);
 
    add_variable("gl_TexCoord", ir_var_out, vec4_array_type, instructions,
                symtab);
@@ -219,10 +217,8 @@ generate_110_fs_variables(exec_list *instructions,
     * FINISHME: value of GL_MAX_TEXTURE_COORDS.  GL_MAX_TEXTURE_COORDS must be
     * FINISHME: at least 2, so hard-code 2 for now.
     */
-   const glsl_type *const vec4_type =
-      glsl_type::get_instance(GLSL_TYPE_FLOAT, 4, 1);
    const glsl_type *const vec4_array_type =
-      glsl_type::get_array_instance(vec4_type, 2);
+      glsl_type::get_array_instance(glsl_type::vec4_type, 2);
 
    add_variable("gl_TexCoord", ir_var_in, vec4_array_type, instructions,
                symtab);
@@ -237,10 +233,8 @@ generate_ARB_draw_buffers_fs_variables(exec_list *instructions,
     * FINISHME: value of GL_MAX_DRAW_BUFFERS.  GL_MAX_DRAW_BUFFERS must be
     * FINISHME: at least 1, so hard-code 1 for now.
     */
-   const glsl_type *const vec4_type =
-      glsl_type::get_instance(GLSL_TYPE_FLOAT, 4, 1);
    const glsl_type *const vec4_array_type =
-      glsl_type::get_array_instance(vec4_type, 1);
+      glsl_type::get_array_instance(glsl_type::vec4_type, 1);
 
    ir_variable *const fd =
       add_variable("gl_FragData", ir_var_out, vec4_array_type, instructions,