diff options
Diffstat (limited to 'src/mesa/shader')
-rw-r--r-- | src/mesa/shader/slang/slang_codegen.c | 14 | ||||
-rw-r--r-- | src/mesa/shader/slang/slang_codegen.h | 13 | ||||
-rw-r--r-- | src/mesa/shader/slang/slang_compile_variable.c | 102 | ||||
-rw-r--r-- | src/mesa/shader/slang/slang_compile_variable.h | 65 | ||||
-rw-r--r-- | src/mesa/shader/slang/slang_typeinfo.c | 111 | ||||
-rw-r--r-- | src/mesa/shader/slang/slang_typeinfo.h | 88 |
6 files changed, 197 insertions, 196 deletions
diff --git a/src/mesa/shader/slang/slang_codegen.c b/src/mesa/shader/slang/slang_codegen.c index d50319432e..02de8e7ce5 100644 --- a/src/mesa/shader/slang/slang_codegen.c +++ b/src/mesa/shader/slang/slang_codegen.c @@ -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) { diff --git a/src/mesa/shader/slang/slang_codegen.h b/src/mesa/shader/slang/slang_codegen.h index ba7ca4c142..9489033d7b 100644 --- a/src/mesa/shader/slang/slang_codegen.h +++ b/src/mesa/shader/slang/slang_codegen.h @@ -31,6 +31,19 @@ #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); diff --git a/src/mesa/shader/slang/slang_compile_variable.c b/src/mesa/shader/slang/slang_compile_variable.c index abe9c55d79..57fe0584da 100644 --- a/src/mesa/shader/slang/slang_compile_variable.c +++ b/src/mesa/shader/slang/slang_compile_variable.c @@ -33,108 +33,6 @@ #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) { diff --git a/src/mesa/shader/slang/slang_compile_variable.h b/src/mesa/shader/slang/slang_compile_variable.h index d2a86b772c..554684b75f 100644 --- a/src/mesa/shader/slang/slang_compile_variable.h +++ b/src/mesa/shader/slang/slang_compile_variable.h @@ -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. */ diff --git a/src/mesa/shader/slang/slang_typeinfo.c b/src/mesa/shader/slang/slang_typeinfo.c index 430fc10b67..a0357d7cef 100644 --- a/src/mesa/shader/slang/slang_typeinfo.c +++ b/src/mesa/shader/slang/slang_typeinfo.c @@ -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. diff --git a/src/mesa/shader/slang/slang_typeinfo.h b/src/mesa/shader/slang/slang_typeinfo.h index 5e57fbb03e..171a899f64 100644 --- a/src/mesa/shader/slang/slang_typeinfo.h +++ b/src/mesa/shader/slang/slang_typeinfo.h @@ -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 *, |