YaGL: Redefine samplerExternalOES in GLSL 87/71687/1 accepted/tizen/common/20160609.145843 accepted/tizen/ivi/20160609.091238 accepted/tizen/mobile/20160609.091511 accepted/tizen/tv/20160609.091254 accepted/tizen/wearable/20160609.091243 submit/tizen/20160609.005815
authorVasiliy Ulyanov <v.ulyanov@samsung.com>
Thu, 26 May 2016 10:12:03 +0000 (13:12 +0300)
committerVasiliy Ulyanov <v.ulyanov@samsung.com>
Thu, 26 May 2016 12:20:30 +0000 (15:20 +0300)
The former external sampler hadnling did not work correctly with
statements like bellow:

    #define SamplerType samplerExternalOES

Using a #define construct in the header for samplerExternalOES seems
more appropriate rather than substituing every occurrence.

Change-Id: If1c654046ad78011a5148013889f5dc93882a6a9
Signed-off-by: Vasiliy Ulyanov <v.ulyanov@samsung.com>
GLESv2/yagl_glsl_lexer.l
GLESv2/yagl_glsl_parser.y
GLESv2/yagl_glsl_state.c
GLESv2/yagl_glsl_state.h

index fdca03e284eff19c26e1aa0f1663101c3d8ef741..b3508d602f8138d19202ed22770daab046b8eb1b 100644 (file)
@@ -193,12 +193,6 @@ STRING [^ \r\t\v\f\n()\[\]{},;?:/%*&|^!+\-=<>\.]+
     return TOK_GLFRAGCOLOR;
 }
 
-"samplerExternalOES" {
-    struct yagl_glsl_state *state = yagl_glsl_lexer_get_extra(yyscanner);
-    yagl_glsl_state_new_str_token(state, yylval, yytext);
-    return TOK_SAMPLEREXTERNALOES;
-}
-
 {PRECISION} {
     struct yagl_glsl_state *state = yagl_glsl_lexer_get_extra(yyscanner);
     yagl_glsl_state_new_str_token(state, yylval, yytext);
index 93049a71cda96de28d639c853dbb60b14c55348b..9f71e0f01813dd0cd327d8f4b9c64b90a8478485 100644 (file)
@@ -69,7 +69,6 @@ static int yagl_glsl_lex(union YYSTYPE *val, struct yagl_glsl_state *state)
 %token <str> TOK_TEXTURECUBE
 %token <str> TOK_TEXTURECUBELOD
 %token <str> TOK_GLFRAGCOLOR
-%token <str> TOK_SAMPLEREXTERNALOES
 
 %%
 
@@ -591,9 +590,4 @@ expression
         yagl_glsl_state_append_output(state, $1.value);
     }
 }
-| TOK_SAMPLEREXTERNALOES
-{
-    yagl_glsl_state_flush_pending(state, $1.index);
-    yagl_glsl_state_append_output(state, "sampler2D");
-}
 ;
index 6934c54930ca72c9e40fd4ff51ff430132c26467..eaebb598b775c787e76b8d7a8ee2cb6cfa80a3b4 100644 (file)
@@ -43,13 +43,15 @@ static void yagl_glsl_state_flush_version(struct yagl_glsl_state *state)
 {
     int have_version = state->have_version;
     int have_extensions = state->have_extensions;
+    int have_samplerexternaloes = state->have_samplerexternaloes;
 
-    if (have_version && have_extensions) {
+    if (have_version && have_extensions && have_samplerexternaloes) {
         return;
     }
 
     state->have_version = 1;
     state->have_extensions = 1;
+    state->have_samplerexternaloes = 1;
 
     if (!have_version) {
         switch (state->patch_version) {
@@ -76,6 +78,10 @@ static void yagl_glsl_state_flush_version(struct yagl_glsl_state *state)
             break;
         }
     }
+
+    if(!have_samplerexternaloes) {
+        yagl_glsl_state_append_header(state, "#define samplerExternalOES sampler2D\n\n");
+    }
 }
 
 static void yagl_glsl_state_move_pending(struct yagl_glsl_state *state)
index 606a54786fa03b11b7cf78e9d4ab1404787aa00c..d371d1064cbd84afe494252d0f2010432723668f 100644 (file)
@@ -86,6 +86,8 @@ struct yagl_glsl_state
 
     int have_extensions;
 
+    int have_samplerexternaloes;
+
     int frag_color_declared;
     int texture1d_declared;
     int texture1dproj_declared;