diff options
author | Brian Paul <[email protected]> | 2008-11-07 16:08:21 -0700 |
---|---|---|
committer | Brian Paul <[email protected]> | 2008-11-07 16:08:21 -0700 |
commit | 87d1a26ba38e75f6988e094dbfbc0f77c0ae502b (patch) | |
tree | c48d78b48e08224b982878aa99e6ac06b37a45fa /src/mesa/shader/slang/slang_compile.c | |
parent | 448156f769ebf271a6a8c03c61588c3e6c6363f0 (diff) |
mesa: add support for 'centroid' qualifier in GLSL 1.20
Diffstat (limited to 'src/mesa/shader/slang/slang_compile.c')
-rw-r--r-- | src/mesa/shader/slang/slang_compile.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/mesa/shader/slang/slang_compile.c b/src/mesa/shader/slang/slang_compile.c index b826888120d..72b83c04224 100644 --- a/src/mesa/shader/slang/slang_compile.c +++ b/src/mesa/shader/slang/slang_compile.c @@ -162,6 +162,7 @@ typedef struct slang_output_ctx_ GLuint default_precision[TYPE_SPECIFIER_COUNT]; GLboolean allow_precision; GLboolean allow_invariant; + GLboolean allow_centroid; } slang_output_ctx; /* _slang_compile() */ @@ -502,6 +503,27 @@ parse_type_variant(slang_parse_ctx * C, slang_type_variant *variant) } +/* centroid qualifer */ +#define TYPE_CENTER 95 +#define TYPE_CENTROID 96 + +static int +parse_type_centroid(slang_parse_ctx * C, slang_type_centroid *centroid) +{ + GLuint c = *C->I++; + switch (c) { + case TYPE_CENTER: + *centroid = SLANG_CENTER; + return 1; + case TYPE_CENTROID: + *centroid = SLANG_CENTROID; + return 1; + default: + return 0; + } +} + + /* type qualifier */ #define TYPE_QUALIFIER_NONE 0 #define TYPE_QUALIFIER_CONST 1 @@ -751,6 +773,9 @@ parse_fully_specified_type(slang_parse_ctx * C, slang_output_ctx * O, if (!parse_type_variant(C, &type->variant)) return 0; + if (!parse_type_centroid(C, &type->centroid)) + return 0; + if (!parse_type_qualifier(C, &type->qualifier)) return 0; @@ -766,6 +791,19 @@ parse_fully_specified_type(slang_parse_ctx * C, slang_output_ctx * O, return 0; } + if (!O->allow_centroid && type->centroid == SLANG_CENTROID) { + slang_info_log_error(C->L, + "'centroid' keyword not allowed (perhaps set #version 120)"); + return 0; + } + else if (type->centroid == SLANG_CENTROID && + type->qualifier != SLANG_QUAL_VARYING) { + slang_info_log_error(C->L, + "'centroid' keyword only allowed for varying vars"); + return 0; + } + + /* need this? if (type->qualifier != SLANG_QUAL_VARYING && type->variant == SLANG_INVARIANT) { @@ -2119,6 +2157,9 @@ parse_code_unit(slang_parse_ctx * C, slang_code_unit * unit, o.allow_invariant = (C->version >= 120) ? GL_TRUE : GL_FALSE; #endif + /* allow 'centroid' keyword? */ + o.allow_centroid = (C->version >= 120) ? GL_TRUE : GL_FALSE; + /* allow 'lowp/mediump/highp' keywords? */ #if FEATURE_es2_glsl o.allow_precision = GL_TRUE; |