Fix shader compile crash issue 40/276640/2
authorEunki, Hong <eunkiki.hong@samsung.com>
Wed, 22 Jun 2022 09:27:23 +0000 (18:27 +0900)
committerEunki, Hong <eunkiki.hong@samsung.com>
Wed, 22 Jun 2022 09:39:29 +0000 (18:39 +0900)
Due to the unknown reason, we got crash during glShaderSource.
To "avoid" that crash, we fix the code that we don't use !defined(~)

Change-Id: I54c7278baffb16ee63481ea92ccc67baa227b071
Signed-off-by: Eunki, Hong <eunkiki.hong@samsung.com>
dali-toolkit/internal/graphics/shaders/color-visual-shader.frag
dali-toolkit/internal/graphics/shaders/color-visual-shader.vert

index db23361..7603982 100644 (file)
@@ -9,15 +9,14 @@ INPUT mediump vec4 vCornerRadius;
 
 uniform lowp vec4 uColor;
 uniform lowp vec3 mixColor;
-#if !defined(IS_REQUIRED_BLUR) && defined(IS_REQUIRED_BORDERLINE)
+#ifdef IS_REQUIRED_BLUR
+uniform mediump float blurRadius;
+#elif defined(IS_REQUIRED_BORDERLINE)
 uniform mediump float borderlineWidth;
 uniform mediump float borderlineOffset;
 uniform lowp vec4 borderlineColor;
 uniform lowp vec4 uActorColor;
 #endif
-#ifdef IS_REQUIRED_BLUR
-uniform mediump float blurRadius;
-#endif
 
 
 #if defined(IS_REQUIRED_ROUNDED_CORNER) || defined(IS_REQUIRED_BORDERLINE) || defined(IS_REQUIRED_BLUR)
@@ -58,7 +57,8 @@ void calculatePosition()
 {
   gFragmentPosition = abs(vPosition) - vRectSize;
   gCenterPosition = -gRadius;
-#if !defined(IS_REQUIRED_BLUR) && defined(IS_REQUIRED_BORDERLINE)
+#ifdef IS_REQUIRED_BLUR
+#elif defined(IS_REQUIRED_BORDERLINE)
   gCenterPosition += borderlineWidth * (clamp(borderlineOffset, -1.0, 1.0) + 1.0) * 0.5;
 #endif
   gDiff = gFragmentPosition - gCenterPosition;
@@ -76,7 +76,10 @@ void setupMinMaxPotential()
   gMaxOutlinePotential = gRadius + gPotentialRange;
   gMinOutlinePotential = gRadius - gPotentialRange;
 
-#if !defined(IS_REQUIRED_BLUR) && defined(IS_REQUIRED_BORDERLINE)
+#ifdef IS_REQUIRED_BLUR
+  gMaxInlinePotential = gMaxOutlinePotential;
+  gMinInlinePotential = gMinOutlinePotential;
+#elif defined(IS_REQUIRED_BORDERLINE)
   gMaxInlinePotential = gMaxOutlinePotential - borderlineWidth;
   gMinInlinePotential = gMinOutlinePotential - borderlineWidth;
 #else
@@ -99,7 +102,8 @@ void PreprocessPotential()
 }
 #endif
 
-#if !defined(IS_REQUIRED_BLUR) && defined(IS_REQUIRED_BORDERLINE)
+#ifdef IS_REQUIRED_BLUR
+#elif defined(IS_REQUIRED_BORDERLINE)
 lowp vec4 convertBorderlineColor(lowp vec4 textureColor)
 {
   mediump float potential = gPotential;
@@ -163,7 +167,8 @@ lowp vec4 convertBorderlineColor(lowp vec4 textureColor)
 }
 #endif
 
-#if !defined(IS_REQUIRED_BLUR) && defined(IS_REQUIRED_ROUNDED_CORNER)
+#ifdef IS_REQUIRED_BLUR
+#elif defined(IS_REQUIRED_ROUNDED_CORNER)
 mediump float calculateCornerOpacity()
 {
   mediump float potential = gPotential;
@@ -269,7 +274,8 @@ void main()
     PreprocessPotential();
 #endif
 
-#if !defined(IS_REQUIRED_BLUR) && defined(IS_REQUIRED_BORDERLINE)
+#ifdef IS_REQUIRED_BLUR
+#elif defined(IS_REQUIRED_BORDERLINE)
     targetColor = convertBorderlineColor(targetColor);
 #endif
     OUT_COLOR = targetColor;
index f1688da..63ef338 100644 (file)
@@ -17,12 +17,11 @@ uniform highp vec2 size;
 uniform mediump vec4 offsetSizeMode;
 uniform mediump vec2 origin;
 uniform mediump vec2 anchorPoint;
-#if !defined(IS_REQUIRED_BLUR) && defined(IS_REQUIRED_BORDERLINE)
-uniform mediump float borderlineWidth;
-uniform mediump float borderlineOffset;
-#endif
 #ifdef IS_REQUIRED_BLUR
 uniform mediump float blurRadius;
+#elif defined(IS_REQUIRED_BORDERLINE)
+uniform mediump float borderlineWidth;
+uniform mediump float borderlineOffset;
 #endif
 #ifdef IS_REQUIRED_ROUNDED_CORNER
 uniform mediump vec4 cornerRadius;
@@ -41,7 +40,9 @@ vec4 ComputeVertexPosition()
 #endif
 
 #ifdef IS_REQUIRED_ROUNDED_CORNER
-#if !defined(IS_REQUIRED_BLUR) && defined(IS_REQUIRED_BORDERLINE)
+#ifdef IS_REQUIRED_BLUR
+  mediump float minSize = min(visualSize.x, visualSize.y);
+#elif defined(IS_REQUIRED_BORDERLINE)
   mediump float minSize = min(visualSize.x, visualSize.y) + (1.0 + clamp(borderlineOffset, -1.0, 1.0)) * borderlineWidth;
 #else
   mediump float minSize = min(visualSize.x, visualSize.y);