return true;
}
-
void TestShaderCodeContainSubstrings(Control control, std::vector<std::pair<std::string, bool>> substringCheckList, const char* location)
{
Renderer renderer = control.GetRendererAt(0);
Property::Map* map = value.GetMap();
DALI_TEST_CHECK(map);
+ Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
+ std::string vertexShader;
+ DALI_TEST_CHECK(vertex->Get(vertexShader));
+ for(const auto& checkPair : substringCheckList)
+ {
+ const auto& keyword = checkPair.first;
+ const auto& expect = checkPair.second;
+ tet_printf("check [%s] %s exist in vertex shader\n", keyword.c_str(), expect ? "is" : "is not");
+ DALI_TEST_EQUALS((vertexShader.find(keyword.c_str()) != std::string::npos), expect, location);
+ }
+
Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
DALI_TEST_CHECK(fragment);
std::string fragmentShader;
tet_printf("check [%s] %s exist in fragment shader\n", keyword.c_str(), expect ? "is" : "is not");
DALI_TEST_EQUALS((fragmentShader.find(keyword.c_str()) != std::string::npos), expect, location);
}
+}
+
+void TestShaderCodeContainSubstringsForEachShader(Control control, std::vector<std::pair<std::string, std::pair<bool, bool>>> substringCheckList, const char* location)
+{
+ Renderer renderer = control.GetRendererAt(0);
+ Shader shader = renderer.GetShader();
+ Property::Value value = shader.GetProperty(Shader::Property::PROGRAM);
+ Property::Map* map = value.GetMap();
+ DALI_TEST_CHECK(map);
Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
std::string vertexShader;
for(const auto& checkPair : substringCheckList)
{
const auto& keyword = checkPair.first;
- const auto& expect = checkPair.second;
+ const auto& expect = checkPair.second.first;
tet_printf("check [%s] %s exist in vertex shader\n", keyword.c_str(), expect ? "is" : "is not");
DALI_TEST_EQUALS((vertexShader.find(keyword.c_str()) != std::string::npos), expect, location);
}
+
+ Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
+ DALI_TEST_CHECK(fragment);
+ std::string fragmentShader;
+ DALI_TEST_CHECK(fragment->Get(fragmentShader));
+ for(const auto& checkPair : substringCheckList)
+ {
+ const auto& keyword = checkPair.first;
+ const auto& expect = checkPair.second.second;
+ tet_printf("check [%s] %s exist in fragment shader\n", keyword.c_str(), expect ? "is" : "is not");
+ DALI_TEST_EQUALS((fragmentShader.find(keyword.c_str()) != std::string::npos), expect, location);
+ }
}
} //namespace
DALI_TEST_CHECK(cornerRadiusValue);
DALI_TEST_EQUALS(cornerRadiusValue->Get<Vector4>(), targetCornerRadius, TEST_LOCATION);
- TestShaderCodeContainSubstrings(
+ TestShaderCodeContainSubstringsForEachShader(
dummyControl,
{
- {"#define IS_REQUIRED_BLUR", true},
- {"#define IS_REQUIRED_BORDERLINE", false}, // Note : We ignore borderline when blur radius occured
- {"#define IS_REQUIRED_ROUNDED_CORNER", false}, // Note : low spec shader doesn't support rounded blur
+ {"#define IS_REQUIRED_BLUR", {true, true}},
+ {"#define IS_REQUIRED_BORDERLINE", {false, false}}, // Note : We ignore borderline when blur radius occured
+ {"#define IS_REQUIRED_ROUNDED_CORNER", {true, true}},
+ {"#define SL_VERSION_LOW", {false, true}},
},
TEST_LOCATION);
DALI_TEST_CHECK(cornerRadiusValue);
DALI_TEST_EQUALS(cornerRadiusValue->Get<Vector4>(), Vector4::ZERO, TEST_LOCATION);
- TestShaderCodeContainSubstrings(
+ TestShaderCodeContainSubstringsForEachShader(
dummyControl,
{
- {"#define IS_REQUIRED_BLUR", true}, // Note : mAlwaysUsingBlurRadius is true.
- {"#define IS_REQUIRED_BORDERLINE", false}, // Note : We ignore borderline when blur radius occured
- {"#define IS_REQUIRED_ROUNDED_CORNER", false}, // Note : mAlwaysUsingCornerRadius is true.
+ {"#define IS_REQUIRED_BLUR", {true, true}}, // Note : mAlwaysUsingBlurRadius is true.
+ {"#define IS_REQUIRED_BORDERLINE", {false, false}}, // Note : We ignore borderline when blur radius occured
+ {"#define IS_REQUIRED_ROUNDED_CORNER", {true, true}}, // Note : mAlwaysUsingCornerRadius is true.
+ {"#define SL_VERSION_LOW", {false, true}},
},
TEST_LOCATION);
// For Shadow Map
uniform lowp int uIsShadowEnabled;
uniform sampler2D sShadowMap;
-#ifdef GLSL_VERSION_1_0
+#ifdef SL_VERSION_LOW
uniform int uShadowMapWidth;
uniform int uShadowMapHeight;
#endif
// Specular Light
// uMaxLOD that means mipmap level of specular texture is used for bluring of reflection of specular following roughness.
float lod = perceptualRoughness * (uMaxLOD - 1.0);
-#ifdef GLSL_VERSION_1_0
+#ifdef SL_VERSION_LOW
// glsl 1.0 doesn't support textureLod. Let we just use textureCube instead.
lowp vec3 specularLight = linear(textureCube(sSpecularEnvSampler, reflection * uYDirection).rgb);
#else
// Diffuse Light
lowp vec3 diffuseColor = mix(baseColor.rgb, vec3(0), metallic);
-#ifdef GLSL_VERSION_1_0
+#ifdef SL_VERSION_LOW
lowp vec3 irradiance = linear(textureCube(sDiffuseEnvSampler, n * uYDirection).rgb);
#else
lowp vec3 irradiance = linear(TEXTURE(sDiffuseEnvSampler, n * uYDirection).rgb);
mediump float exposureFactor = 0.0;
if(uEnableShadowSoftFiltering > 0)
{
-#ifdef GLSL_VERSION_1_0
+#ifdef SL_VERSION_LOW
ivec2 texSize = ivec2(uShadowMapWidth, uShadowMapHeight);
#else
ivec2 texSize = textureSize(sShadowMap, 0);
INPUT vec4 aVertexColor;
-#ifdef GLSL_VERSION_1_0
+#ifdef SL_VERSION_LOW
INPUT float aVertexID;
#endif
#ifdef MORPH
uniform highp sampler2D sBlendShapeGeometry;
-#ifdef GLSL_VERSION_1_0
+#ifdef SL_VERSION_LOW
uniform int uBlendShapeGeometryWidth;
uniform int uBlendShapeGeometryHeight;
#endif
#ifdef SKINNING
-#ifdef GLSL_VERSION_1_0
+#ifdef SL_VERSION_LOW
#define MAX_BONES 80
uniform mat4 uBone[MAX_BONES];
#else
highp vec3 tangent = aTangent.xyz;
#ifdef MORPH
-#ifdef GLSL_VERSION_1_0
+#ifdef SL_VERSION_LOW
int width = uBlendShapeGeometryWidth;
#else
int width = textureSize( sBlendShapeGeometry, 0 ).x;
highp int blendShapeBufferOffset = 0;
-#ifdef GLSL_VERSION_1_0
+#ifdef SL_VERSION_LOW
highp float blendShapeWidth = float(uBlendShapeGeometryWidth);
highp float blendShapeHeight = float(uBlendShapeGeometryHeight);
highp float invertBlendShapeWidth = 1.0 / blendShapeWidth;
#ifdef MORPH_POSITION
// Calculate the index to retrieve the geometry from the texture.
-#ifdef GLSL_VERSION_1_0
+#ifdef SL_VERSION_LOW
vertexId = int(floor(aVertexID + 0.5)) + blendShapeBufferOffset;
y = vertexId / width;
x = vertexId - y * width;
highp float unnormalizeFactor = uBlendShapeUnnormalizeFactor[index];
#endif
-#ifdef GLSL_VERSION_1_0
+#ifdef SL_VERSION_LOW
highp float floatX = float(x) + 0.5;
highp float floatY = float(y) + 0.5;
diff = weight * unnormalizeFactor * ( texture2D( sBlendShapeGeometry, vec2(floatX * invertBlendShapeWidth, floatY * invertBlendShapeHeight) ).xyz - 0.5 );
#ifdef MORPH_NORMAL
// Calculate the index to retrieve the normal from the texture.
-#ifdef GLSL_VERSION_1_0
+#ifdef SL_VERSION_LOW
vertexId = int(floor(aVertexID + 0.5)) + blendShapeBufferOffset;
y = vertexId / width;
x = vertexId - y * width;
// Retrieves the blend shape normal from the texture, unnormalizes it and multiply by the weight.
if(0.0 != weight)
{
-#ifdef GLSL_VERSION_1_0
+#ifdef SL_VERSION_LOW
highp float floatX = float(x) + 0.5;
highp float floatY = float(y) + 0.5;
diff = weight * 2.0 * ( texture2D( sBlendShapeGeometry, vec2(floatX * invertBlendShapeWidth, floatY * invertBlendShapeHeight) ).xyz - 0.5 );
#ifdef MORPH_TANGENT
// Calculate the index to retrieve the tangent from the texture.
-#ifdef GLSL_VERSION_1_0
+#ifdef SL_VERSION_LOW
vertexId = int(floor(aVertexID + 0.5)) + blendShapeBufferOffset;
y = vertexId / width;
x = vertexId - y * width;
// Retrieves the blend shape tangent from the texture, unnormalizes it and multiply by the weight.
if(0.0 != weight)
{
-#ifdef GLSL_VERSION_1_0
+#ifdef SL_VERSION_LOW
highp float floatX = float(x) + 0.5;
highp float floatY = float(y) + 0.5;
diff = weight * 2.0 * ( texture2D( sBlendShapeGeometry, vec2(floatX * invertBlendShapeWidth, floatY * invertBlendShapeHeight) ).xyz - 0.5 );
highp vec4 positionV = uViewMatrix * positionW;
-#ifdef GLSL_VERSION_1_0
+#ifdef SL_VERSION_LOW
highp vec3 i0 = uViewMatrix[0].xyz;
highp vec3 i1 = uViewMatrix[1].xyz;
highp vec3 i2 = uViewMatrix[2].xyz;
INPUT vec2 aTexCoord;
INPUT vec4 aVertexColor;
-#ifdef GLSL_VERSION_1_0
+#ifdef SL_VERSION_LOW
INPUT float aVertexID;
#endif
#ifdef MORPH
uniform highp sampler2D sBlendShapeGeometry;
-#ifdef GLSL_VERSION_1_0
+#ifdef SL_VERSION_LOW
uniform int uBlendShapeGeometryWidth;
uniform int uBlendShapeGeometryHeight;
#endif
#ifdef SKINNING
-#ifdef GLSL_VERSION_1_0
+#ifdef SL_VERSION_LOW
#define MAX_BONES 80
uniform mat4 uBone[MAX_BONES];
#else
#ifdef MORPH
-#ifdef GLSL_VERSION_1_0
+#ifdef SL_VERSION_LOW
int width = uBlendShapeGeometryWidth;
#else
int width = textureSize( sBlendShapeGeometry, 0 ).x;
highp int blendShapeBufferOffset = 0;
-#ifdef GLSL_VERSION_1_0
+#ifdef SL_VERSION_LOW
highp float blendShapeWidth = float(uBlendShapeGeometryWidth);
highp float blendShapeHeight = float(uBlendShapeGeometryHeight);
highp float invertBlendShapeWidth = 1.0 / blendShapeWidth;
#ifdef MORPH_POSITION
// Calculate the index to retrieve the geometry from the texture.
-#ifdef GLSL_VERSION_1_0
+#ifdef SL_VERSION_LOW
vertexId = int(floor(aVertexID + 0.5)) + blendShapeBufferOffset;
y = vertexId / width;
x = vertexId - y * width;
highp float unnormalizeFactor = uBlendShapeUnnormalizeFactor[index];
#endif
-#ifdef GLSL_VERSION_1_0
+#ifdef SL_VERSION_LOW
highp float floatX = float(x) + 0.5;
highp float floatY = float(y) + 0.5;
diff = weight * unnormalizeFactor * ( texture2D( sBlendShapeGeometry, vec2(floatX * invertBlendShapeWidth, floatY * invertBlendShapeHeight) ).xyz - 0.5 );
}
if(DALI_UNLIKELY(Dali::Shader::GetShaderLanguageVersion() < MINIMUM_SHADER_VERSION_SUPPORT_TEXTURE_TEXEL_AND_SIZE))
{
- shaderOption.AddOption(Scene3D::Loader::ShaderOption::Type::GLSL_VERSION_1_0);
+ shaderOption.AddOption(Scene3D::Loader::ShaderOption::Type::SL_VERSION_LOW);
}
Shader newShader = mShaderManager->ProduceShader(shaderOption);
}
if(DALI_UNLIKELY(Dali::Shader::GetShaderLanguageVersion() < MINIMUM_SHADER_VERSION_SUPPORT_TEXTURE_TEXEL_AND_SIZE))
{
- option.AddOption(ShaderOption::Type::GLSL_VERSION_1_0);
+ option.AddOption(ShaderOption::Type::SL_VERSION_LOW);
}
return option;
"MORPH_NORMAL",
"MORPH_TANGENT",
"MORPH_VERSION_2_0",
- "GLSL_VERSION_1_0",
+ "SL_VERSION_LOW",
};
static constexpr uint32_t NUMBER_OF_OPTIONS = sizeof(OPTION_KEYWORD) / sizeof(OPTION_KEYWORD[0]);
static const char* ADD_EXTRA_SKINNING_ATTRIBUTES{"ADD_EXTRA_SKINNING_ATTRIBUTES"};
MORPH_NORMAL, // 10000
MORPH_TANGENT, // 20000
MORPH_VERSION_2_0, // 40000
- GLSL_VERSION_1_0, // 80000
+ SL_VERSION_LOW, // 80000
};
struct MacroDefinition
#endif
#ifdef IS_REQUIRED_BLUR
+#ifdef SL_VERSION_LOW
+// Legacy code for low version glsl
+mediump float calculateBlurOpacity()
+{
+ highp float potential = gPotential;
+
+ highp float alias = min(gRadius, vAliasMargin);
+ highp float potentialMin = gMinOutlinePotential - blurRadius - alias;
+ highp float potentialMax = gMaxOutlinePotential + blurRadius + alias;
+
+ return 1.0 - smoothstep(potentialMin, potentialMax, potential);
+}
+#else
mediump float calculateBlurOpacity()
{
// Don't use borderline!
v = v + cy;
highp float potential = 0.0;
- highp float alias = min(gRadius, 1.0);
+ highp float alias = min(gRadius, vAliasMargin);
highp float potentialMin = cy + gRadius - blurRadius - alias;
highp float potentialMax = cy + gRadius + blurRadius + alias;
potential = v.y;
// for anti-alias when blurRaidus = 0.0
- highp float heuristicBaselineScale = max(1.0 , cr * (cr + cy));
+ highp float heuristicBaselineScale = max(vAliasMargin , cr * (cr + cy));
highp float potentialDiff = min(alias, diffFromBaseline / heuristicBaselineScale);
potentialMin += potentialDiff;
potentialMax -= potentialDiff;
return 1.0 - smoothstep(potentialMin, potentialMax, potential);
}
#endif
+#endif
void main()
{
// If we use blur, just ignore borderline
borderline = false;
shaderTypeFlag |= ColorVisualRequireFlag::BLUR;
-
- // If shader version doesn't support blur with corner radius, ignore corner radius
- if(DALI_UNLIKELY(Dali::Shader::GetShaderLanguageVersion() < MINIMUM_SHADER_VERSION_SUPPORT_ROUNDED_BLUR))
- {
- roundedCorner = false;
- }
}
if(roundedCorner)
{
{
vertexShaderPrefixList += "#define IS_REQUIRED_BLUR\n";
fragmentShaderPrefixList += "#define IS_REQUIRED_BLUR\n";
+
+ // If shader version doesn't support latest blur with corner radius, Let we use legacy code.
+ if(DALI_UNLIKELY(Dali::Shader::GetShaderLanguageVersion() < MINIMUM_SHADER_VERSION_SUPPORT_ROUNDED_BLUR))
+ {
+ fragmentShaderPrefixList += "#define SL_VERSION_LOW\n";
+ }
}
if(borderline)
{