diff options
author | Michal Krol <[email protected]> | 2008-08-07 16:49:54 +0200 |
---|---|---|
committer | Michal Krol <[email protected]> | 2008-08-07 16:49:54 +0200 |
commit | 9a20cecc5cf41c5eda6cedd5f30416bc1b49ac91 (patch) | |
tree | 6b370e5ac0927c1b92fbb9752402a7750e0be9b3 /src | |
parent | c5c7130385b1b0d35b52a6df68d9558a92fabd86 (diff) |
mesa: Extend GLSL syntax to accept type precision in full type specifiers.
Diffstat (limited to 'src')
-rw-r--r-- | src/mesa/shader/slang/library/slang_shader.syn | 25 | ||||
-rw-r--r-- | src/mesa/shader/slang/library/slang_shader_syn.h | 23 | ||||
-rw-r--r-- | src/mesa/shader/slang/slang_compile.c | 29 |
3 files changed, 53 insertions, 24 deletions
diff --git a/src/mesa/shader/slang/library/slang_shader.syn b/src/mesa/shader/slang/library/slang_shader.syn index 4505758520a..06bd8ac883c 100644 --- a/src/mesa/shader/slang/library/slang_shader.syn +++ b/src/mesa/shader/slang/library/slang_shader.syn @@ -49,7 +49,7 @@ .syntax translation_unit; /* revision number - increment after each change affecting emitted output */ -.emtcode REVISION 3 +.emtcode REVISION 4 /* external declaration (or precision or invariant stmt) */ .emtcode EXTERNAL_NULL 0 @@ -59,9 +59,10 @@ .emtcode INVARIANT_STMT 4 /* precision */ -.emtcode PRECISION_LOW 0 -.emtcode PRECISION_MEDIUM 1 -.emtcode PRECISION_HIGH 2 +.emtcode PRECISION_DEFAULT 0 +.emtcode PRECISION_LOW 1 +.emtcode PRECISION_MEDIUM 2 +.emtcode PRECISION_HIGH 3 /* declaration */ .emtcode DECLARATION_FUNCTION_PROTOTYPE 1 @@ -855,15 +856,21 @@ single_declaration_6 /* <fully_specified_type> ::= <type_specifier> | <type_qualifier> <type_specifier> + | <precision> <type_specifier> + | <type_qualifier> <precision> <type_specifier> */ fully_specified_type_space - fully_specified_type_1 .and type_specifier_space; + fully_specified_type_optqual .and fully_specified_type_optprec .and type_specifier_space; fully_specified_type_nospace - fully_specified_type_1 .and type_specifier_nospace; -fully_specified_type_1 - fully_specified_type_2 .or .true .emit TYPE_QUALIFIER_NONE; -fully_specified_type_2 + fully_specified_type_optqual .and fully_specified_type_optprec .and type_specifier_nospace; +fully_specified_type_optqual + fully_specified_type_qual .or .true .emit TYPE_QUALIFIER_NONE; +fully_specified_type_qual type_qualifier .and space; +fully_specified_type_optprec + fully_specified_type_prec .or .true .emit PRECISION_DEFAULT; +fully_specified_type_prec + precision .and space; /* <type_qualifier> ::= "const" diff --git a/src/mesa/shader/slang/library/slang_shader_syn.h b/src/mesa/shader/slang/library/slang_shader_syn.h index 0c4c14f9d1e..1b258fcdc13 100644 --- a/src/mesa/shader/slang/library/slang_shader_syn.h +++ b/src/mesa/shader/slang/library/slang_shader_syn.h @@ -2,15 +2,16 @@ /* DO NOT EDIT - THIS FILE IS AUTOMATICALLY GENERATED FROM THE .syn FILE */ ".syntax translation_unit;\n" -".emtcode REVISION 3\n" +".emtcode REVISION 4\n" ".emtcode EXTERNAL_NULL 0\n" ".emtcode EXTERNAL_FUNCTION_DEFINITION 1\n" ".emtcode EXTERNAL_DECLARATION 2\n" ".emtcode DEFAULT_PRECISION 3\n" ".emtcode INVARIANT_STMT 4\n" -".emtcode PRECISION_LOW 0\n" -".emtcode PRECISION_MEDIUM 1\n" -".emtcode PRECISION_HIGH 2\n" +".emtcode PRECISION_DEFAULT 0\n" +".emtcode PRECISION_LOW 1\n" +".emtcode PRECISION_MEDIUM 2\n" +".emtcode PRECISION_HIGH 3\n" ".emtcode DECLARATION_FUNCTION_PROTOTYPE 1\n" ".emtcode DECLARATION_INIT_DECLARATOR_LIST 2\n" ".emtcode FUNCTION_ORDINARY 0\n" @@ -413,13 +414,17 @@ "single_declaration_6\n" " constant_expression .emit VARIABLE_ARRAY_EXPLICIT .or .true .emit VARIABLE_ARRAY_UNKNOWN;\n" "fully_specified_type_space\n" -" fully_specified_type_1 .and type_specifier_space;\n" +" fully_specified_type_optqual .and fully_specified_type_optprec .and type_specifier_space;\n" "fully_specified_type_nospace\n" -" fully_specified_type_1 .and type_specifier_nospace;\n" -"fully_specified_type_1\n" -" fully_specified_type_2 .or .true .emit TYPE_QUALIFIER_NONE;\n" -"fully_specified_type_2\n" +" fully_specified_type_optqual .and fully_specified_type_optprec .and type_specifier_nospace;\n" +"fully_specified_type_optqual\n" +" fully_specified_type_qual .or .true .emit TYPE_QUALIFIER_NONE;\n" +"fully_specified_type_qual\n" " type_qualifier .and space;\n" +"fully_specified_type_optprec\n" +" fully_specified_type_prec .or .true .emit PRECISION_DEFAULT;\n" +"fully_specified_type_prec\n" +" precision .and space;\n" "type_qualifier\n" " \"const\" .emit TYPE_QUALIFIER_CONST .or\n" " .if (shader_type == 2) \"attribute\" .emit TYPE_QUALIFIER_ATTRIBUTE .or\n" diff --git a/src/mesa/shader/slang/slang_compile.c b/src/mesa/shader/slang/slang_compile.c index f90bbd8c567..2a1af39ee07 100644 --- a/src/mesa/shader/slang/slang_compile.c +++ b/src/mesa/shader/slang/slang_compile.c @@ -237,7 +237,7 @@ parse_float(slang_parse_ctx * C, float *number) } /* revision number - increment after each change affecting emitted output */ -#define REVISION 3 +#define REVISION 4 static int check_revision(slang_parse_ctx * C) @@ -691,14 +691,36 @@ parse_type_specifier(slang_parse_ctx * C, slang_output_ctx * O, return 1; } +#define PRECISION_DEFAULT 0 +#define PRECISION_LOW 1 +#define PRECISION_MEDIUM 2 +#define PRECISION_HIGH 3 + static int parse_fully_specified_type(slang_parse_ctx * C, slang_output_ctx * O, slang_fully_specified_type * type) { + GLuint precision; + if (!parse_type_qualifier(C, &type->qualifier)) return 0; + precision = *C->I++; if (!parse_type_specifier(C, O, &type->specifier)) return 0; + switch (precision) { + case PRECISION_DEFAULT: + /* TODO: Grab the default precision for the given type specifier. + */ + break; + case PRECISION_LOW: + case PRECISION_MEDIUM: + case PRECISION_HIGH: + /* TODO: Translate to mesa representation. + */ + break; + default: + return 0; + } return 1; } @@ -1869,11 +1891,6 @@ parse_declaration(slang_parse_ctx * C, slang_output_ctx * O) return 1; } - -#define PRECISION_LOW 0 -#define PRECISION_MEDIUM 1 -#define PRECISION_HIGH 2 - static int parse_default_precision(slang_parse_ctx * C, slang_output_ctx * O) { |