OSDN Git Service

mesa: move some glsl compiler functions to different files to be more consistant
authorBrian Paul <brian.paul@tungstengraphics.com>
Fri, 12 Dec 2008 17:11:41 +0000 (10:11 -0700)
committerBrian Paul <brianp@vmware.com>
Tue, 6 Jan 2009 16:09:11 +0000 (09:09 -0700)
(cherry picked from commit aeeb9bca2712dbf8540486fc584e214a8af4c7c4)

src/mesa/shader/slang/slang_codegen.c
src/mesa/shader/slang/slang_codegen.h
src/mesa/shader/slang/slang_compile_variable.c
src/mesa/shader/slang/slang_compile_variable.h
src/mesa/shader/slang/slang_typeinfo.c
src/mesa/shader/slang/slang_typeinfo.h

index 42c455e..8a682cd 100644 (file)
@@ -61,6 +61,20 @@ static slang_ir_node *
 _slang_gen_operation(slang_assemble_ctx * A, slang_operation *oper);
 
 
+/**
+ * Retrieves type information about an operation.
+ * Returns GL_TRUE on success.
+ * Returns GL_FALSE otherwise.
+ */
+static GLboolean
+_slang_typeof_operation(const struct slang_assemble_ctx_ * A,
+                        slang_operation * op,
+                        slang_typeinfo * ti)
+{
+   return _slang_typeof_operation_(op, &A->space, ti, A->atoms, A->log);
+}
+
+
 static GLboolean
 is_sampler_type(const slang_fully_specified_type *t)
 {
index ba7ca4c..9489033 100644 (file)
 #include "slang_compile.h"
 
 
+typedef struct slang_assemble_ctx_
+{
+   slang_atom_pool *atoms;
+   slang_name_space space;
+   struct gl_program *program;
+   slang_var_table *vartable;
+   slang_info_log *log;
+   struct slang_label_ *curFuncEndLabel;
+   struct slang_ir_node_ *CurLoop;
+   struct slang_function_ *CurFunction;
+} slang_assemble_ctx;
+
+
 extern GLuint
 _slang_sizeof_type_specifier(const slang_type_specifier *spec);
 
index abe9c55..57fe058 100644 (file)
 #include "slang_mem.h"
 
 
-typedef struct
-{
-   const char *name;
-   slang_type_specifier_type type;
-} type_specifier_type_name;
-
-static const type_specifier_type_name type_specifier_type_names[] = {
-   {"void", SLANG_SPEC_VOID},
-   {"bool", SLANG_SPEC_BOOL},
-   {"bvec2", SLANG_SPEC_BVEC2},
-   {"bvec3", SLANG_SPEC_BVEC3},
-   {"bvec4", SLANG_SPEC_BVEC4},
-   {"int", SLANG_SPEC_INT},
-   {"ivec2", SLANG_SPEC_IVEC2},
-   {"ivec3", SLANG_SPEC_IVEC3},
-   {"ivec4", SLANG_SPEC_IVEC4},
-   {"float", SLANG_SPEC_FLOAT},
-   {"vec2", SLANG_SPEC_VEC2},
-   {"vec3", SLANG_SPEC_VEC3},
-   {"vec4", SLANG_SPEC_VEC4},
-   {"mat2", SLANG_SPEC_MAT2},
-   {"mat3", SLANG_SPEC_MAT3},
-   {"mat4", SLANG_SPEC_MAT4},
-   {"mat2x3", SLANG_SPEC_MAT23},
-   {"mat3x2", SLANG_SPEC_MAT32},
-   {"mat2x4", SLANG_SPEC_MAT24},
-   {"mat4x2", SLANG_SPEC_MAT42},
-   {"mat3x4", SLANG_SPEC_MAT34},
-   {"mat4x3", SLANG_SPEC_MAT43},
-   {"sampler1D", SLANG_SPEC_SAMPLER1D},
-   {"sampler2D", SLANG_SPEC_SAMPLER2D},
-   {"sampler3D", SLANG_SPEC_SAMPLER3D},
-   {"samplerCube", SLANG_SPEC_SAMPLERCUBE},
-   {"sampler1DShadow", SLANG_SPEC_SAMPLER1DSHADOW},
-   {"sampler2DShadow", SLANG_SPEC_SAMPLER2DSHADOW},
-   {"sampler2DRect", SLANG_SPEC_SAMPLER2DRECT},
-   {"sampler2DRectShadow", SLANG_SPEC_SAMPLER2DRECTSHADOW},
-   {NULL, SLANG_SPEC_VOID}
-};
-
-slang_type_specifier_type
-slang_type_specifier_type_from_string(const char *name)
-{
-   const type_specifier_type_name *p = type_specifier_type_names;
-   while (p->name != NULL) {
-      if (slang_string_compare(p->name, name) == 0)
-         break;
-      p++;
-   }
-   return p->type;
-}
-
-const char *
-slang_type_specifier_type_to_string(slang_type_specifier_type type)
-{
-   const type_specifier_type_name *p = type_specifier_type_names;
-   while (p->name != NULL) {
-      if (p->type == type)
-         break;
-      p++;
-   }
-   return p->name;
-}
-
-/* slang_fully_specified_type */
-
-int
-slang_fully_specified_type_construct(slang_fully_specified_type * type)
-{
-   type->qualifier = SLANG_QUAL_NONE;
-   slang_type_specifier_ctr(&type->specifier);
-   return 1;
-}
-
-void
-slang_fully_specified_type_destruct(slang_fully_specified_type * type)
-{
-   slang_type_specifier_dtr(&type->specifier);
-}
-
-int
-slang_fully_specified_type_copy(slang_fully_specified_type * x,
-                                const slang_fully_specified_type * y)
-{
-   slang_fully_specified_type z;
-
-   if (!slang_fully_specified_type_construct(&z))
-      return 0;
-   z.qualifier = y->qualifier;
-   z.precision = y->precision;
-   z.variant = y->variant;
-   z.centroid = y->centroid;
-   if (!slang_type_specifier_copy(&z.specifier, &y->specifier)) {
-      slang_fully_specified_type_destruct(&z);
-      return 0;
-   }
-   slang_fully_specified_type_destruct(x);
-   *x = z;
-   return 1;
-}
-
-
 static slang_variable *
 slang_variable_new(void)
 {
index d2a86b7..554684b 100644 (file)
@@ -33,71 +33,6 @@ extern "C" {
 struct slang_ir_storage_;
 
 
-typedef enum slang_type_variant_
-{
-   SLANG_VARIANT,    /* the default */
-   SLANG_INVARIANT   /* indicates the "invariant" keyword */
-} slang_type_variant;
-
-
-typedef enum slang_type_centroid_
-{
-   SLANG_CENTER,    /* the default */
-   SLANG_CENTROID   /* indicates the "centroid" keyword */
-} slang_type_centroid;
-
-
-typedef enum slang_type_qualifier_
-{
-   SLANG_QUAL_NONE,
-   SLANG_QUAL_CONST,
-   SLANG_QUAL_ATTRIBUTE,
-   SLANG_QUAL_VARYING,
-   SLANG_QUAL_UNIFORM,
-   SLANG_QUAL_OUT,
-   SLANG_QUAL_INOUT,
-   SLANG_QUAL_FIXEDOUTPUT,      /* internal */
-   SLANG_QUAL_FIXEDINPUT        /* internal */
-} slang_type_qualifier;
-
-extern slang_type_specifier_type
-slang_type_specifier_type_from_string(const char *);
-
-extern const char *
-slang_type_specifier_type_to_string(slang_type_specifier_type);
-
-
-
-typedef enum slang_type_precision_
-{
-   SLANG_PREC_DEFAULT,
-   SLANG_PREC_LOW,
-   SLANG_PREC_MEDIUM,
-   SLANG_PREC_HIGH
-} slang_type_precision;
-
-
-typedef struct slang_fully_specified_type_
-{
-   slang_type_qualifier qualifier;
-   slang_type_specifier specifier;
-   slang_type_precision precision;
-   slang_type_variant variant;
-   slang_type_centroid centroid;
-   GLint array_len;           /**< -1 if not an array type */
-} slang_fully_specified_type;
-
-extern int
-slang_fully_specified_type_construct(slang_fully_specified_type *);
-
-extern void
-slang_fully_specified_type_destruct(slang_fully_specified_type *);
-
-extern int
-slang_fully_specified_type_copy(slang_fully_specified_type *,
-                               const slang_fully_specified_type *);
-
-
 /**
  * A shading language program variable.
  */
index 430fc10..a0357d7 100644 (file)
@@ -166,6 +166,109 @@ _slang_multiply_swizzles(slang_swizzle * dst, const slang_swizzle * left,
 }
 
 
+typedef struct
+{
+   const char *name;
+   slang_type_specifier_type type;
+} type_specifier_type_name;
+
+static const type_specifier_type_name type_specifier_type_names[] = {
+   {"void", SLANG_SPEC_VOID},
+   {"bool", SLANG_SPEC_BOOL},
+   {"bvec2", SLANG_SPEC_BVEC2},
+   {"bvec3", SLANG_SPEC_BVEC3},
+   {"bvec4", SLANG_SPEC_BVEC4},
+   {"int", SLANG_SPEC_INT},
+   {"ivec2", SLANG_SPEC_IVEC2},
+   {"ivec3", SLANG_SPEC_IVEC3},
+   {"ivec4", SLANG_SPEC_IVEC4},
+   {"float", SLANG_SPEC_FLOAT},
+   {"vec2", SLANG_SPEC_VEC2},
+   {"vec3", SLANG_SPEC_VEC3},
+   {"vec4", SLANG_SPEC_VEC4},
+   {"mat2", SLANG_SPEC_MAT2},
+   {"mat3", SLANG_SPEC_MAT3},
+   {"mat4", SLANG_SPEC_MAT4},
+   {"mat2x3", SLANG_SPEC_MAT23},
+   {"mat3x2", SLANG_SPEC_MAT32},
+   {"mat2x4", SLANG_SPEC_MAT24},
+   {"mat4x2", SLANG_SPEC_MAT42},
+   {"mat3x4", SLANG_SPEC_MAT34},
+   {"mat4x3", SLANG_SPEC_MAT43},
+   {"sampler1D", SLANG_SPEC_SAMPLER1D},
+   {"sampler2D", SLANG_SPEC_SAMPLER2D},
+   {"sampler3D", SLANG_SPEC_SAMPLER3D},
+   {"samplerCube", SLANG_SPEC_SAMPLERCUBE},
+   {"sampler1DShadow", SLANG_SPEC_SAMPLER1DSHADOW},
+   {"sampler2DShadow", SLANG_SPEC_SAMPLER2DSHADOW},
+   {"sampler2DRect", SLANG_SPEC_SAMPLER2DRECT},
+   {"sampler2DRectShadow", SLANG_SPEC_SAMPLER2DRECTSHADOW},
+   {NULL, SLANG_SPEC_VOID}
+};
+
+slang_type_specifier_type
+slang_type_specifier_type_from_string(const char *name)
+{
+   const type_specifier_type_name *p = type_specifier_type_names;
+   while (p->name != NULL) {
+      if (slang_string_compare(p->name, name) == 0)
+         break;
+      p++;
+   }
+   return p->type;
+}
+
+const char *
+slang_type_specifier_type_to_string(slang_type_specifier_type type)
+{
+   const type_specifier_type_name *p = type_specifier_type_names;
+   while (p->name != NULL) {
+      if (p->type == type)
+         break;
+      p++;
+   }
+   return p->name;
+}
+
+/* slang_fully_specified_type */
+
+int
+slang_fully_specified_type_construct(slang_fully_specified_type * type)
+{
+   type->qualifier = SLANG_QUAL_NONE;
+   slang_type_specifier_ctr(&type->specifier);
+   return 1;
+}
+
+void
+slang_fully_specified_type_destruct(slang_fully_specified_type * type)
+{
+   slang_type_specifier_dtr(&type->specifier);
+}
+
+int
+slang_fully_specified_type_copy(slang_fully_specified_type * x,
+                                const slang_fully_specified_type * y)
+{
+   slang_fully_specified_type z;
+
+   if (!slang_fully_specified_type_construct(&z))
+      return 0;
+   z.qualifier = y->qualifier;
+   z.precision = y->precision;
+   z.variant = y->variant;
+   z.centroid = y->centroid;
+   if (!slang_type_specifier_copy(&z.specifier, &y->specifier)) {
+      slang_fully_specified_type_destruct(&z);
+      return 0;
+   }
+   slang_fully_specified_type_destruct(x);
+   *x = z;
+   return 1;
+}
+
+
+
 GLvoid
 slang_type_specifier_ctr(slang_type_specifier * self)
 {
@@ -377,14 +480,6 @@ typeof_math_call(const char *name, slang_operation *call,
    }
 }
 
-GLboolean
-_slang_typeof_operation(const slang_assemble_ctx * A,
-                        slang_operation * op,
-                        slang_typeinfo * ti)
-{
-   return _slang_typeof_operation_(op, &A->space, ti, A->atoms, A->log);
-}
-
 
 /**
  * Determine the return type of an operation.
index 5e57fbb..171a899 100644 (file)
@@ -55,17 +55,7 @@ typedef struct slang_name_space_
 } slang_name_space;
 
 
-typedef struct slang_assemble_ctx_
-{
-   slang_atom_pool *atoms;
-   slang_name_space space;
-   struct gl_program *program;
-   slang_var_table *vartable;
-   slang_info_log *log;
-   struct slang_label_ *curFuncEndLabel;
-   struct slang_ir_node_ *CurLoop;
-   struct slang_function_ *CurFunction;
-} slang_assemble_ctx;
+struct slang_assemble_ctx_;
 
 
 extern GLboolean
@@ -79,6 +69,43 @@ _slang_multiply_swizzles(slang_swizzle *, const slang_swizzle *,
                          const slang_swizzle *);
 
 
+typedef enum slang_type_variant_
+{
+   SLANG_VARIANT,    /* the default */
+   SLANG_INVARIANT   /* indicates the "invariant" keyword */
+} slang_type_variant;
+
+
+typedef enum slang_type_centroid_
+{
+   SLANG_CENTER,    /* the default */
+   SLANG_CENTROID   /* indicates the "centroid" keyword */
+} slang_type_centroid;
+
+
+typedef enum slang_type_qualifier_
+{
+   SLANG_QUAL_NONE,
+   SLANG_QUAL_CONST,
+   SLANG_QUAL_ATTRIBUTE,
+   SLANG_QUAL_VARYING,
+   SLANG_QUAL_UNIFORM,
+   SLANG_QUAL_OUT,
+   SLANG_QUAL_INOUT,
+   SLANG_QUAL_FIXEDOUTPUT,      /* internal */
+   SLANG_QUAL_FIXEDINPUT        /* internal */
+} slang_type_qualifier;
+
+
+typedef enum slang_type_precision_
+{
+   SLANG_PREC_DEFAULT,
+   SLANG_PREC_LOW,
+   SLANG_PREC_MEDIUM,
+   SLANG_PREC_HIGH
+} slang_type_precision;
+
+
 /**
  * The basic shading language types (float, vec4, mat3, etc)
  */
@@ -119,6 +146,13 @@ typedef enum slang_type_specifier_type_
 } slang_type_specifier_type;
 
 
+extern slang_type_specifier_type
+slang_type_specifier_type_from_string(const char *);
+
+extern const char *
+slang_type_specifier_type_to_string(slang_type_specifier_type);
+
+
 /**
  * Describes more sophisticated types, like structs and arrays.
  */
@@ -155,6 +189,28 @@ slang_type_specifier_compatible(const slang_type_specifier * x,
                                 const slang_type_specifier * y);
 
 
+typedef struct slang_fully_specified_type_
+{
+   slang_type_qualifier qualifier;
+   slang_type_specifier specifier;
+   slang_type_precision precision;
+   slang_type_variant variant;
+   slang_type_centroid centroid;
+   GLint array_len;           /**< -1 if not an array type */
+} slang_fully_specified_type;
+
+extern int
+slang_fully_specified_type_construct(slang_fully_specified_type *);
+
+extern void
+slang_fully_specified_type_destruct(slang_fully_specified_type *);
+
+extern int
+slang_fully_specified_type_copy(slang_fully_specified_type *,
+                               const slang_fully_specified_type *);
+
+
+
 typedef struct slang_typeinfo_
 {
    GLboolean can_be_referenced;
@@ -171,16 +227,6 @@ extern GLvoid
 slang_typeinfo_destruct(slang_typeinfo *);
 
 
-/**
- * Retrieves type information about an operation.
- * Returns GL_TRUE on success.
- * Returns GL_FALSE otherwise.
- */
-extern GLboolean
-_slang_typeof_operation(const slang_assemble_ctx *,
-                        struct slang_operation_ *,
-                        slang_typeinfo *);
-
 extern GLboolean
 _slang_typeof_operation_(struct slang_operation_ *,
                          const slang_name_space *,