yagl_glsl_parser: Fix invalid placement of set_last_sampler_array_count 27/265027/1 accepted/tizen_6.5_unified tizen_6.5 accepted/tizen/6.5/unified/20211028.093639 accepted/tizen/unified/20211008.014737 submit/tizen/20211007.231031 submit/tizen_6.5/20211028.161501 tizen_6.5.m2_release
authorLukasz Kostyra <l.kostyra@samsung.com>
Thu, 7 Oct 2021 08:19:24 +0000 (10:19 +0200)
committerLukasz Kostyra <l.kostyra@samsung.com>
Thu, 7 Oct 2021 08:31:44 +0000 (10:31 +0200)
When parsing non-array uniforms, there was a possibility that a parsed
uniform was not a sampler. Despite that, set_last_sampler_array_count
was called, which could trigger an assertion.

This fixes boot issues on wearable image, as wearable image EFL was
using some shaders exploiting this corner case.

Change-Id: Icf3363f6c6622047ecbafa68a68e3bbc385e1471

GLESv2/yagl_glsl_parser.y
GLESv2/yagl_glsl_state.c

index 74e5246411d443f4a57fb304e2214d01b3277a44..8043841010680a999832c13eea791c10c90593c0 100644 (file)
@@ -701,11 +701,12 @@ expression
                 }
 
                 yagl_glsl_state_add_sampler_ExternalOES(state, $4.value);
+                yagl_glsl_state_set_last_sampler_array_count(state, 1);
             } else if (strcmp(type_resolved, "sampler2D") == 0) {
                 yagl_glsl_state_add_sampler_2D(state, $4.value);
+                yagl_glsl_state_set_last_sampler_array_count(state, 1);
             }
 
-            yagl_glsl_state_set_last_sampler_array_count(state, 1);
             free(type_resolved);
         }
     }
@@ -736,11 +737,12 @@ expression
                 }
 
                 yagl_glsl_state_add_sampler_ExternalOES(state, $3.value);
+                yagl_glsl_state_set_last_sampler_array_count(state, 1);
             } else if (strcmp(type_resolved, "sampler2D") == 0) {
                 yagl_glsl_state_add_sampler_2D(state, $3.value);
+                yagl_glsl_state_set_last_sampler_array_count(state, 1);
             }
 
-            yagl_glsl_state_set_last_sampler_array_count(state, 1);
             free(type_resolved);
         }
     }
@@ -772,7 +774,6 @@ expression
                     state->have_samplerexternaloes = 1;
                 }
 
-                // TODO add how many samplers are added too - check resolution_value
                 yagl_glsl_state_add_sampler_ExternalOES(state, $4.value);
                 yagl_glsl_state_pp_condition_parse_start(state);
             } else if (strcmp(type_resolved, "sampler2D") == 0) {
index 86190ec892a96e4ae0d4bb69d6ed866598b90074..72149abea0c96a2f18b94dfe83a48f39879430f4 100644 (file)
@@ -840,7 +840,7 @@ yagl_glsl_pp_condition_status yagl_glsl_state_pp_condition_resolve(struct yagl_g
             res_cur++;
         } else {
             if (yagl_glsl_pp_expr_op_is_unary(state->pp_exprs[i].op)) {
-                assert(res_cur > 0);
+                assert(res_cur >= 1);
 
                 if (!yagl_glsl_state_pp_solve_unary(state, state->pp_exprs[i].op, res_stack[res_cur - 1], &tmp_result)) {
                     YAGL_LOG_ERROR("Expression #%d: Unary operator %d (%s) failed", i, state->pp_exprs[i].op, glsl_pp_op_dbgstr[state->pp_exprs[i].op]);