[Mesa-dev] [PATCH 13/17] glsl: Add default precision qualifiers to the symbol table
Samuel Iglesias Gonsalvez
siglesias at igalia.com
Wed Jul 29 07:01:30 PDT 2015
From: Iago Toral Quiroga <itoral at igalia.com>
The GLSL ES spec specifies default precision qualifiers for certain types,
so populate the symbol table with these.
Notice that the desktop GLSL spec also indicates defaults for some types
but this is not really useful since precision qualifiers are completely
ignored in desktop GLSL.
---
src/glsl/glsl_parser.yy | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/src/glsl/glsl_parser.yy b/src/glsl/glsl_parser.yy
index e66b80a..f55fd23 100644
--- a/src/glsl/glsl_parser.yy
+++ b/src/glsl/glsl_parser.yy
@@ -310,6 +310,20 @@ translation_unit:
{
delete state->symbols;
state->symbols = new(ralloc_parent(state)) glsl_symbol_table;
+ if (state->es_shader) {
+ if (state->stage == MESA_SHADER_FRAGMENT) {
+ state->symbols->add_default_precision_qualifier("int", ast_precision_medium);
+ state->symbols->add_default_precision_qualifier("sampler2D", ast_precision_low);
+ state->symbols->add_default_precision_qualifier("samplerCube", ast_precision_low);
+ state->symbols->add_default_precision_qualifier("samplerExternalOES", ast_precision_low);
+ } else {
+ state->symbols->add_default_precision_qualifier("float", ast_precision_high);
+ state->symbols->add_default_precision_qualifier("int", ast_precision_high);
+ state->symbols->add_default_precision_qualifier("sampler2D", ast_precision_low);
+ state->symbols->add_default_precision_qualifier("samplerCube", ast_precision_low);
+ state->symbols->add_default_precision_qualifier("samplerExternalOES", ast_precision_low);
+ }
+ }
_mesa_glsl_initialize_types(state);
}
;
--
2.4.3
More information about the mesa-dev
mailing list