aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorGravatar Ethan Nicholas <ethannicholas@google.com>2017-08-16 16:41:30 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-08-16 23:05:15 +0000
commit88d99c63878c2d3d340120f0321676f72afcb4f0 (patch)
tree5b957dbf2f78ef7a15aa3810f8922c915508683f /tests
parenta26d219a929f4e70f8597dfd57a53348c4bba905 (diff)
Switched highp float to highfloat and mediump float to half.
The ultimate goal is to end up with "float" and "half", but this intermediate step uses "highfloat" so that it is clear if I missed a "float" somewhere. Once this lands, a subsequent CL will switch all "highfloats" back to "floats". Bug: skia: Change-Id: Ia13225c7a0a0a2901e07665891c473d2500ddcca Reviewed-on: https://skia-review.googlesource.com/31000 Commit-Queue: Ethan Nicholas <ethannicholas@google.com> Reviewed-by: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/GrMeshTest.cpp12
-rw-r--r--tests/GrPipelineDynamicStateTest.cpp6
-rw-r--r--tests/ImageStorageTest.cpp6
-rw-r--r--tests/PrimitiveProcessorTest.cpp4
-rw-r--r--tests/SkSLErrorTest.cpp178
-rw-r--r--tests/SkSLFPTest.cpp68
-rw-r--r--tests/SkSLGLSLTest.cpp392
7 files changed, 318 insertions, 348 deletions
diff --git a/tests/GrMeshTest.cpp b/tests/GrMeshTest.cpp
index 288c057589..c722a5c27d 100644
--- a/tests/GrMeshTest.cpp
+++ b/tests/GrMeshTest.cpp
@@ -327,20 +327,20 @@ class GLSLMeshTestProcessor : public GrGLSLGeometryProcessor {
GrGLSLVertexBuilder* v = args.fVertBuilder;
if (!mp.fInstanceLocation) {
- v->codeAppendf("float2 vertex = %s;", mp.fVertex->fName);
+ v->codeAppendf("highfloat2 vertex = %s;", mp.fVertex->fName);
} else {
if (mp.fVertex) {
- v->codeAppendf("float2 offset = %s;", mp.fVertex->fName);
+ v->codeAppendf("highfloat2 offset = %s;", mp.fVertex->fName);
} else {
- v->codeAppend ("float2 offset = float2(sk_VertexID / 2, sk_VertexID % 2);");
+ v->codeAppend ("highfloat2 offset = highfloat2(sk_VertexID / 2, sk_VertexID % 2);");
}
- v->codeAppendf("float2 vertex = %s + offset * %i;",
+ v->codeAppendf("highfloat2 vertex = %s + offset * %i;",
mp.fInstanceLocation->fName, kBoxSize);
}
- gpArgs->fPositionVar.set(kVec2f_GrSLType, "vertex");
+ gpArgs->fPositionVar.set(kHighFloat2_GrSLType, "vertex");
GrGLSLPPFragmentBuilder* f = args.fFragBuilder;
- f->codeAppendf("%s = float4(1);", args.fOutputCoverage);
+ f->codeAppendf("%s = half4(1);", args.fOutputCoverage);
}
};
diff --git a/tests/GrPipelineDynamicStateTest.cpp b/tests/GrPipelineDynamicStateTest.cpp
index 2049ccb182..15c76c0136 100644
--- a/tests/GrPipelineDynamicStateTest.cpp
+++ b/tests/GrPipelineDynamicStateTest.cpp
@@ -91,11 +91,11 @@ class GLSLPipelineDynamicStateTestProcessor : public GrGLSLGeometryProcessor {
varyingHandler->addPassThroughAttribute(&mp.fColor, args.fOutputColor);
GrGLSLVertexBuilder* v = args.fVertBuilder;
- v->codeAppendf("float2 vertex = %s;", mp.fVertex.fName);
- gpArgs->fPositionVar.set(kVec2f_GrSLType, "vertex");
+ v->codeAppendf("highfloat2 vertex = %s;", mp.fVertex.fName);
+ gpArgs->fPositionVar.set(kHighFloat2_GrSLType, "vertex");
GrGLSLPPFragmentBuilder* f = args.fFragBuilder;
- f->codeAppendf("%s = float4(1);", args.fOutputCoverage);
+ f->codeAppendf("%s = half4(1);", args.fOutputCoverage);
}
};
diff --git a/tests/ImageStorageTest.cpp b/tests/ImageStorageTest.cpp
index 6d5cab09ec..8a6023ff9b 100644
--- a/tests/ImageStorageTest.cpp
+++ b/tests/ImageStorageTest.cpp
@@ -58,13 +58,13 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ImageStorageLoad, reporter, ctxInfo) {
const TestFP& tfp = args.fFp.cast<TestFP>();
GrGLSLFPFragmentBuilder* fb = args.fFragBuilder;
SkString imageLoadStr;
- fb->codeAppend("highp float2 coord = sk_FragCoord.xy;");
+ fb->codeAppend("highfloat2 coord = sk_FragCoord.xy;");
fb->appendImageStorageLoad(&imageLoadStr, args.fImageStorages[0],
"int2(coord)");
if (GrPixelConfigIsSint(tfp.fImageStorageAccess.peekTexture()->config())) {
// Map the signed bytes so that when then get read back as unorm values they
// will have their original bit pattern.
- fb->codeAppendf("highp int4 ivals = %s;", imageLoadStr.c_str());
+ fb->codeAppendf("int4 ivals = %s;", imageLoadStr.c_str());
// NV gives a linker error for this:
// fb->codeAppend("ivals +=
// "mix(int4(0), int4(256), lessThan(ivals, int4(0)));");
@@ -72,7 +72,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ImageStorageLoad, reporter, ctxInfo) {
fb->codeAppend("if (ivals.g < 0) { ivals.g += 256; }");
fb->codeAppend("if (ivals.b < 0) { ivals.b += 256; }");
fb->codeAppend("if (ivals.a < 0) { ivals.a += 256; }");
- fb->codeAppendf("%s = float4(ivals)/255;", args.fOutputColor);
+ fb->codeAppendf("%s = half4(ivals)/255;", args.fOutputColor);
} else {
fb->codeAppendf("%s = %s;", args.fOutputColor, imageLoadStr.c_str());
}
diff --git a/tests/PrimitiveProcessorTest.cpp b/tests/PrimitiveProcessorTest.cpp
index 1e764e1433..47dff33755 100644
--- a/tests/PrimitiveProcessorTest.cpp
+++ b/tests/PrimitiveProcessorTest.cpp
@@ -72,8 +72,8 @@ private:
args.fVaryingHandler->emitAttributes(gp);
this->writeOutputPosition(args.fVertBuilder, gpArgs, gp.getAttrib(0).fName);
GrGLSLPPFragmentBuilder* fragBuilder = args.fFragBuilder;
- fragBuilder->codeAppendf("%s = float4(1);", args.fOutputColor);
- fragBuilder->codeAppendf("%s = float4(1);", args.fOutputCoverage);
+ fragBuilder->codeAppendf("%s = half4(1);", args.fOutputColor);
+ fragBuilder->codeAppendf("%s = half4(1);", args.fOutputCoverage);
}
void setData(const GrGLSLProgramDataManager& pdman,
const GrPrimitiveProcessor& primProc,
diff --git a/tests/SkSLErrorTest.cpp b/tests/SkSLErrorTest.cpp
index b94cc82324..4943e101cf 100644
--- a/tests/SkSLErrorTest.cpp
+++ b/tests/SkSLErrorTest.cpp
@@ -37,39 +37,39 @@ static void test_success(skiatest::Reporter* r, const char* src) {
DEF_TEST(SkSLUndefinedSymbol, r) {
test_failure(r,
- "void main() { x = float2(1); }",
+ "void main() { x = highfloat2(1); }",
"error: 1: unknown identifier 'x'\n1 error\n");
}
DEF_TEST(SkSLUndefinedFunction, r) {
test_failure(r,
- "void main() { int x = foo(1); }",
+ "void main() { int x = foo(1); }",
"error: 1: unknown identifier 'foo'\n1 error\n");
}
DEF_TEST(SkSLGenericArgumentMismatch, r) {
test_failure(r,
- "void main() { float x = sin(1, 2); }",
+ "void main() { highfloat x = sin(1, 2); }",
"error: 1: call to 'sin' expected 1 argument, but found 2\n1 error\n");
test_failure(r,
- "void main() { float x = sin(true); }",
+ "void main() { highfloat x = sin(true); }",
"error: 1: no match for sin(bool)\n1 error\n");
test_success(r,
- "void main() { float x = sin(1); }");
+ "void main() { highfloat x = sin(1); }");
}
DEF_TEST(SkSLArgumentCountMismatch, r) {
test_failure(r,
- "float foo(float x) { return x * x; }"
- "void main() { float x = foo(1, 2); }",
+ "highfloat foo(highfloat x) { return x * x; }"
+ "void main() { highfloat x = foo(1, 2); }",
"error: 1: call to 'foo' expected 1 argument, but found 2\n1 error\n");
}
DEF_TEST(SkSLArgumentMismatch, r) {
- test_failure(r,
- "float foo(float x) { return x * x; }"
- "void main() { float x = foo(true); }",
- "error: 1: expected 'float', but found 'bool'\n1 error\n");
+ test_failure(r,
+ "highfloat foo(highfloat x) { return x * x; }"
+ "void main() { highfloat x = foo(true); }",
+ "error: 1: expected 'highfloat', but found 'bool'\n1 error\n");
}
DEF_TEST(SkSLIfTypeMismatch, r) {
@@ -80,32 +80,32 @@ DEF_TEST(SkSLIfTypeMismatch, r) {
DEF_TEST(SkSLDoTypeMismatch, r) {
test_failure(r,
- "void main() { do { } while (float2(1)); }",
- "error: 1: expected 'bool', but found 'float2'\n1 error\n");
+ "void main() { do { } while (highfloat2(1)); }",
+ "error: 1: expected 'bool', but found 'highfloat2'\n1 error\n");
}
DEF_TEST(SkSLWhileTypeMismatch, r) {
test_failure(r,
- "void main() { while (float3(1)) { } }",
- "error: 1: expected 'bool', but found 'float3'\n1 error\n");
+ "void main() { while (highfloat3(1)) { } }",
+ "error: 1: expected 'bool', but found 'highfloat3'\n1 error\n");
}
DEF_TEST(SkSLForTypeMismatch, r) {
test_failure(r,
- "void main() { for (int x = 0; x; x++) { } }",
+ "void main() { for (int x = 0; x; x++) { } }",
"error: 1: expected 'bool', but found 'int'\n1 error\n");
}
DEF_TEST(SkSLConstructorTypeMismatch, r) {
test_failure(r,
- "void main() { float2 x = float2(1.0, false); }",
- "error: 1: expected 'float', but found 'bool'\n1 error\n");
+ "void main() { highfloat2 x = highfloat2(1.0, false); }",
+ "error: 1: expected 'highfloat', but found 'bool'\n1 error\n");
test_failure(r,
- "void main() { float2 x = float2(bool2(false)); }",
- "error: 1: 'bool2' is not a valid parameter to 'float2' constructor\n1 error\n");
+ "void main() { highfloat2 x = highfloat2(bool2(false)); }",
+ "error: 1: 'bool2' is not a valid parameter to 'highfloat2' constructor\n1 error\n");
test_failure(r,
- "void main() { bool2 x = bool2(float2(1)); }",
- "error: 1: 'float2' is not a valid parameter to 'bool2' constructor\n1 error\n");
+ "void main() { bool2 x = bool2(highfloat2(1)); }",
+ "error: 1: 'highfloat2' is not a valid parameter to 'bool2' constructor\n1 error\n");
test_failure(r,
"void main() { bool x = bool(1.0); }",
"error: 1: cannot construct 'bool'\n1 error\n");
@@ -113,69 +113,69 @@ DEF_TEST(SkSLConstructorTypeMismatch, r) {
"struct foo { int x; }; void main() { foo x = foo(5); }",
"error: 1: cannot construct 'foo'\n1 error\n");
test_failure(r,
- "struct foo { int x; } foo; void main() { float x = float(foo); }",
- "error: 1: invalid argument to 'float' constructor (expected a number or bool, but found 'foo')\n1 error\n");
+ "struct foo { int x; } foo; void main() { highfloat x = highfloat(foo); }",
+ "error: 1: invalid argument to 'highfloat' constructor (expected a number or bool, but found 'foo')\n1 error\n");
test_failure(r,
- "struct foo { int x; } foo; void main() { float2 x = float2(foo); }",
- "error: 1: 'foo' is not a valid parameter to 'float2' constructor\n1 error\n");
+ "struct foo { int x; } foo; void main() { highfloat2 x = highfloat2(foo); }",
+ "error: 1: 'foo' is not a valid parameter to 'highfloat2' constructor\n1 error\n");
test_failure(r,
- "void main() { float2x2 x = float2x2(true); }",
- "error: 1: expected 'float', but found 'bool'\n1 error\n");
+ "void main() { highfloat2x2 x = highfloat2x2(true); }",
+ "error: 1: expected 'highfloat', but found 'bool'\n1 error\n");
}
DEF_TEST(SkSLConstructorArgumentCount, r) {
test_failure(r,
- "void main() { float3 x = float3(1.0, 2.0); }",
- "error: 1: invalid arguments to 'float3' constructor (expected 3 scalars, but "
+ "void main() { highfloat3 x = highfloat3(1.0, 2.0); }",
+ "error: 1: invalid arguments to 'highfloat3' constructor (expected 3 scalars, but "
"found 2)\n1 error\n");
test_failure(r,
- "void main() { float3 x = float3(1.0, 2.0, 3.0, 4.0); }",
- "error: 1: invalid arguments to 'float3' constructor (expected 3 scalars, but found "
+ "void main() { highfloat3 x = highfloat3(1.0, 2.0, 3.0, 4.0); }",
+ "error: 1: invalid arguments to 'highfloat3' constructor (expected 3 scalars, but found "
"4)\n1 error\n");
}
DEF_TEST(SkSLSwizzleScalar, r) {
test_failure(r,
- "void main() { float x = 1; float y = x.y; }",
- "error: 1: cannot swizzle value of type 'float'\n1 error\n");
+ "void main() { highfloat x = 1; highfloat y = x.y; }",
+ "error: 1: cannot swizzle value of type 'highfloat'\n1 error\n");
}
DEF_TEST(SkSLSwizzleMatrix, r) {
test_failure(r,
- "void main() { float2x2 x = float2x2(1); float y = x.y; }",
- "error: 1: cannot swizzle value of type 'float2x2'\n1 error\n");
+ "void main() { highfloat2x2 x = highfloat2x2(1); highfloat y = x.y; }",
+ "error: 1: cannot swizzle value of type 'highfloat2x2'\n1 error\n");
}
DEF_TEST(SkSLSwizzleOutOfBounds, r) {
test_failure(r,
- "void main() { float3 test = float2(1).xyz; }",
+ "void main() { highfloat3 test = highfloat2(1).xyz; }",
"error: 1: invalid swizzle component 'z'\n1 error\n");
}
DEF_TEST(SkSLSwizzleTooManyComponents, r) {
test_failure(r,
- "void main() { float4 test = float2(1).xxxxx; }",
+ "void main() { highfloat4 test = highfloat2(1).xxxxx; }",
"error: 1: too many components in swizzle mask 'xxxxx'\n1 error\n");
}
DEF_TEST(SkSLSwizzleDuplicateOutput, r) {
test_failure(r,
- "void main() { float4 test = float4(1); test.xyyz = float4(1); }",
+ "void main() { highfloat4 test = highfloat4(1); test.xyyz = highfloat4(1); }",
"error: 1: cannot write to the same swizzle field more than once\n1 error\n");
}
DEF_TEST(SkSLAssignmentTypeMismatch, r) {
test_failure(r,
"void main() { int x = 1.0; }",
- "error: 1: expected 'int', but found 'float'\n1 error\n");
+ "error: 1: expected 'int', but found 'highfloat'\n1 error\n");
test_failure(r,
"void main() { int x; x = 1.0; }",
- "error: 1: type mismatch: '=' cannot operate on 'int', 'float'\n1 error\n");
+ "error: 1: type mismatch: '=' cannot operate on 'int', 'highfloat'\n1 error\n");
test_success(r,
- "void main() { float3 x = float3(0); x *= 1.0; }");
+ "void main() { highfloat3 x = highfloat3(0); x *= 1.0; }");
test_failure(r,
"void main() { int3 x = int3(0); x *= 1.0; }",
- "error: 1: type mismatch: '*=' cannot operate on 'int3', 'float'\n1 error\n");
+ "error: 1: type mismatch: '*=' cannot operate on 'int3', 'highfloat'\n1 error\n");
}
DEF_TEST(SkSLReturnFromVoid, r) {
@@ -192,13 +192,13 @@ DEF_TEST(SkSLReturnMissingValue, r) {
DEF_TEST(SkSLReturnTypeMismatch, r) {
test_failure(r,
- "int foo() { return 1.0; } void main() { }",
- "error: 1: expected 'int', but found 'float'\n1 error\n");
+ "int foo() { return 1.0; } void main() { }",
+ "error: 1: expected 'int', but found 'highfloat'\n1 error\n");
}
DEF_TEST(SkSLDuplicateFunction, r) {
test_failure(r,
- "void main() { } void main() { }",
+ "void main() { } void main() { }",
"error: 1: duplicate definition of void main()\n1 error\n");
test_success(r,
"void main(); void main() { }");
@@ -206,29 +206,29 @@ DEF_TEST(SkSLDuplicateFunction, r) {
DEF_TEST(SkSLUsingInvalidValue, r) {
test_failure(r,
- "void main() { int x = int; }",
+ "void main() { int x = int; }",
"error: 1: expected '(' to begin constructor invocation\n1 error\n");
test_failure(r,
- "int test() { return 1; } void main() { int x = test; }",
+ "int test() { return 1; } void main() { int x = test; }",
"error: 1: expected '(' to begin function call\n1 error\n");
}
DEF_TEST(SkSLDifferentReturnType, r) {
test_failure(r,
- "int main() { return 1; } void main() { }",
+ "int main() { return 1; } void main() { }",
"error: 1: functions 'void main()' and 'int main()' differ only in return type\n1 "
"error\n");
}
DEF_TEST(SkSLDifferentModifiers, r) {
test_failure(r,
- "void test(int x); void test(out int x) { }",
+ "void test(int x); void test(out int x) { }",
"error: 1: modifiers on parameter 1 differ between declaration and definition\n1 "
"error\n");
}
DEF_TEST(SkSLDuplicateSymbol, r) {
test_failure(r,
- "int main; void main() { }",
+ "int main; void main() { }",
"error: 1: symbol 'main' was already defined\n1 error\n");
test_failure(r,
@@ -240,32 +240,32 @@ DEF_TEST(SkSLDuplicateSymbol, r) {
DEF_TEST(SkSLBinaryTypeMismatch, r) {
test_failure(r,
- "void main() { float x = 3 * true; }",
+ "void main() { highfloat x = 3 * true; }",
"error: 1: type mismatch: '*' cannot operate on 'int', 'bool'\n1 error\n");
test_failure(r,
"void main() { bool x = 1 || 2.0; }",
- "error: 1: type mismatch: '||' cannot operate on 'int', 'float'\n1 error\n");
+ "error: 1: type mismatch: '||' cannot operate on 'int', 'highfloat'\n1 error\n");
}
DEF_TEST(SkSLCallNonFunction, r) {
test_failure(r,
- "void main() { float x = 3; x(); }",
+ "void main() { highfloat x = 3; x(); }",
"error: 1: 'x' is not a function\n1 error\n");
}
DEF_TEST(SkSLInvalidUnary, r) {
test_failure(r,
- "void main() { float4x4 x = float4x4(1); ++x; }",
- "error: 1: '++' cannot operate on 'float4x4'\n1 error\n");
+ "void main() { highfloat4x4 x = highfloat4x4(1); ++x; }",
+ "error: 1: '++' cannot operate on 'highfloat4x4'\n1 error\n");
test_failure(r,
- "void main() { float3 x = float3(1); --x; }",
- "error: 1: '--' cannot operate on 'float3'\n1 error\n");
+ "void main() { highfloat3 x = highfloat3(1); --x; }",
+ "error: 1: '--' cannot operate on 'highfloat3'\n1 error\n");
test_failure(r,
- "void main() { float4x4 x = float4x4(1); x++; }",
- "error: 1: '++' cannot operate on 'float4x4'\n1 error\n");
+ "void main() { highfloat4x4 x = highfloat4x4(1); x++; }",
+ "error: 1: '++' cannot operate on 'highfloat4x4'\n1 error\n");
test_failure(r,
- "void main() { float3 x = float3(1); x--; }",
- "error: 1: '--' cannot operate on 'float3'\n1 error\n");
+ "void main() { highfloat3 x = highfloat3(1); x--; }",
+ "error: 1: '--' cannot operate on 'highfloat3'\n1 error\n");
test_failure(r,
"void main() { int x = !12; }",
"error: 1: '!' cannot operate on 'int'\n1 error\n");
@@ -276,7 +276,7 @@ DEF_TEST(SkSLInvalidUnary, r) {
"struct foo { } bar; void main() { foo x = -bar; }",
"error: 1: '-' cannot operate on 'foo'\n1 error\n");
test_success(r,
- "void main() { float2 x = float2(1, 1); x = +x; x = -x; }");
+ "void main() { highfloat2 x = highfloat2(1, 1); x = +x; x = -x; }");
}
DEF_TEST(SkSLInvalidAssignment, r) {
@@ -296,17 +296,17 @@ DEF_TEST(SkSLBadIndex, r) {
"void main() { int x = 2[0]; }",
"error: 1: expected array, but found 'int'\n1 error\n");
test_failure(r,
- "void main() { float2 x = float2(0); int y = x[0][0]; }",
- "error: 1: expected array, but found 'float'\n1 error\n");
+ "void main() { highfloat2 x = highfloat2(0); int y = x[0][0]; }",
+ "error: 1: expected array, but found 'highfloat'\n1 error\n");
}
DEF_TEST(SkSLTernaryMismatch, r) {
test_failure(r,
"void main() { int x = 5 > 2 ? true : 1.0; }",
- "error: 1: ternary operator result mismatch: 'bool', 'float'\n1 error\n");
+ "error: 1: ternary operator result mismatch: 'bool', 'highfloat'\n1 error\n");
test_failure(r,
- "void main() { int x = 5 > 2 ? float3(1) : 1.0; }",
- "error: 1: ternary operator result mismatch: 'float3', 'float'\n1 error\n");
+ "void main() { int x = 5 > 2 ? highfloat3(1) : 1.0; }",
+ "error: 1: ternary operator result mismatch: 'highfloat3', 'highfloat'\n1 error\n");
}
DEF_TEST(SkSLInterfaceBlockStorageModifiers, r) {
@@ -333,7 +333,7 @@ DEF_TEST(SkSLUseWithoutInitialize, r) {
"error: 1: 'x' has not been assigned\n1 error\n");
test_failure(r,
"void main() { int x; switch (3) { case 0: x = 0; case 1: x = 1; }"
- "sk_FragColor = float4(x); }",
+ "sk_FragColor = highfloat4(x); }",
"error: 1: 'x' has not been assigned\n1 error\n");
}
@@ -403,32 +403,32 @@ DEF_TEST(SkSLDivByZero, r) {
"int x = 1 / 0;",
"error: 1: division by zero\n1 error\n");
test_failure(r,
- "float x = 1 / 0;",
+ "highfloat x = 1 / 0;",
"error: 1: division by zero\n1 error\n");
test_failure(r,
- "float x = 1.0 / 0.0;",
+ "highfloat x = 1.0 / 0.0;",
"error: 1: division by zero\n1 error\n");
test_failure(r,
- "float x = -67.0 / (3.0 - 3);",
+ "highfloat x = -67.0 / (3.0 - 3);",
"error: 1: division by zero\n1 error\n");
}
DEF_TEST(SkSLUnsupportedGLSLIdentifiers, r) {
test_failure(r,
- "void main() { float x = gl_FragCoord.x; };",
+ "void main() { highfloat x = gl_FragCoord.x; };",
"error: 1: unknown identifier 'gl_FragCoord'\n1 error\n");
test_failure(r,
- "void main() { float r = gl_FragColor.r; };",
+ "void main() { highfloat r = gl_FragColor.r; };",
"error: 1: unknown identifier 'gl_FragColor'\n1 error\n");
}
DEF_TEST(SkSLWrongSwitchTypes, r) {
test_failure(r,
- "void main() { switch (float2(1)) { case 1: break; } }",
- "error: 1: expected 'int', but found 'float2'\n1 error\n");
+ "void main() { switch (highfloat2(1)) { case 1: break; } }",
+ "error: 1: expected 'int', but found 'highfloat2'\n1 error\n");
test_failure(r,
- "void main() { switch (1) { case float2(1): break; } }",
- "error: 1: expected 'int', but found 'float2'\n1 error\n");
+ "void main() { switch (1) { case highfloat2(1): break; } }",
+ "error: 1: expected 'int', but found 'highfloat2'\n1 error\n");
}
DEF_TEST(SkSLNonConstantCase, r) {
@@ -445,18 +445,18 @@ DEF_TEST(SkSLDuplicateCase, r) {
DEF_TEST(SkSLFieldAfterRuntimeArray, r) {
test_failure(r,
- "buffer broken { float x[]; float y; };",
+ "buffer broken { highfloat x[]; highfloat y; };",
"error: 1: only the last entry in an interface block may be a runtime-sized "
"array\n1 error\n");
}
DEF_TEST(SkSLStaticIf, r) {
test_success(r,
- "void main() { float x = 5; float y = 10;"
- "@if (x < y) { sk_FragColor = float4(1); } }");
+ "void main() { highfloat x = 5; highfloat y = 10;"
+ "@if (x < y) { sk_FragColor = highfloat4(1); } }");
test_failure(r,
- "void main() { float x = sqrt(25); float y = 10;"
- "@if (x < y) { sk_FragColor = float4(1); } }",
+ "void main() { highfloat x = sqrt(25); highfloat y = 10;"
+ "@if (x < y) { sk_FragColor = highfloat4(1); } }",
"error: 1: static if has non-static test\n1 error\n");
}
@@ -465,16 +465,16 @@ DEF_TEST(SkSLStaticSwitch, r) {
"void main() {"
"int x = 1;"
"@switch (x) {"
- "case 1: sk_FragColor = float4(1); break;"
- "default: sk_FragColor = float4(0);"
+ "case 1: sk_FragColor = highfloat4(1); break;"
+ "default: sk_FragColor = highfloat4(0);"
"}"
"}");
test_failure(r,
"void main() {"
"int x = int(sqrt(1));"
"@switch (x) {"
- "case 1: sk_FragColor = float4(1); break;"
- "default: sk_FragColor = float4(0);"
+ "case 1: sk_FragColor = highfloat4(1); break;"
+ "default: sk_FragColor = highfloat4(0);"
"}"
"}",
"error: 1: static switch has non-static test\n1 error\n");
@@ -482,8 +482,8 @@ DEF_TEST(SkSLStaticSwitch, r) {
"void main() {"
"int x = 1;"
"@switch (x) {"
- "case 1: sk_FragColor = float4(1); if (sqrt(0) < sqrt(1)) break;"
- "default: sk_FragColor = float4(0);"
+ "case 1: sk_FragColor = highfloat4(1); if (sqrt(0) < sqrt(1)) break;"
+ "default: sk_FragColor = highfloat4(0);"
"}"
"}",
"error: 1: static switch contains non-static conditional break\n1 error\n");
diff --git a/tests/SkSLFPTest.cpp b/tests/SkSLFPTest.cpp
index c3f9468ca8..266169f630 100644
--- a/tests/SkSLFPTest.cpp
+++ b/tests/SkSLFPTest.cpp
@@ -62,7 +62,7 @@ static void test(skiatest::Reporter* r, const char* src, const GrShaderCaps& cap
DEF_TEST(SkSLFPHelloWorld, r) {
test(r,
"void main() {"
- "sk_OutColor = float4(1);"
+ "sk_OutColor = half4(1);"
"}",
*SkSL::ShaderCapsFactory::Default(),
{
@@ -132,7 +132,7 @@ DEF_TEST(SkSLFPHelloWorld, r) {
" GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;\n"
" const GrTest& _outer = args.fFp.cast<GrTest>();\n"
" (void) _outer;\n"
- " fragBuilder->codeAppendf(\"%s = float4(1.0);\\n\", args.fOutputColor);\n"
+ " fragBuilder->codeAppendf(\"%s = half4(1.0);\\n\", args.fOutputColor);\n"
" }\n"
"private:\n"
" void onSetData(const GrGLSLProgramDataManager& pdman, "
@@ -163,9 +163,9 @@ DEF_TEST(SkSLFPHelloWorld, r) {
DEF_TEST(SkSLFPInput, r) {
test(r,
- "in float2 point;"
+ "in half2 point;"
"void main() {"
- "sk_OutColor = float4(point, point);"
+ "sk_OutColor = half4(point, point);"
"}",
*SkSL::ShaderCapsFactory::Default(),
{
@@ -176,7 +176,7 @@ DEF_TEST(SkSLFPInput, r) {
", fPoint(point)"
},
{
- "fragBuilder->codeAppendf(\"%s = float4(float2(%f, %f), float2(%f, %f));\\n\", "
+ "fragBuilder->codeAppendf(\"%s = half4(half2(%f, %f), half2(%f, %f));\\n\", "
"args.fOutputColor, _outer.point().fX, _outer.point().fY, "
"_outer.point().fX, _outer.point().fY);",
"if (fPoint != that.fPoint) return false;"
@@ -185,7 +185,7 @@ DEF_TEST(SkSLFPInput, r) {
DEF_TEST(SkSLFPUniform, r) {
test(r,
- "uniform float4 color;"
+ "uniform half4 color;"
"void main() {"
"sk_OutColor = color;"
"}",
@@ -194,14 +194,14 @@ DEF_TEST(SkSLFPUniform, r) {
"static std::unique_ptr<GrFragmentProcessor> Make()"
},
{
- "fColorVar = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kVec4f_GrSLType, "
+ "fColorVar = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kHalf4_GrSLType, "
"kDefault_GrSLPrecision, \"color\");",
});
}
DEF_TEST(SkSLFPInUniform, r) {
test(r,
- "in uniform float4 color;"
+ "in uniform half4 color;"
"void main() {"
"sk_OutColor = color;"
"}",
@@ -210,7 +210,7 @@ DEF_TEST(SkSLFPInUniform, r) {
"static std::unique_ptr<GrFragmentProcessor> Make(SkRect color) {",
},
{
- "fColorVar = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kVec4f_GrSLType, "
+ "fColorVar = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kHalf4_GrSLType, "
"kDefault_GrSLPrecision, \"color\");",
"const SkRect colorValue = _outer.color();",
"pdman.set4fv(fColorVar, 1, (float*) &colorValue);"
@@ -221,7 +221,7 @@ DEF_TEST(SkSLFPSections, r) {
test(r,
"@header { header section }"
"void main() {"
- "sk_OutColor = float4(1);"
+ "sk_OutColor = half4(1);"
"}",
*SkSL::ShaderCapsFactory::Default(),
{
@@ -231,7 +231,7 @@ DEF_TEST(SkSLFPSections, r) {
test(r,
"@class { class section }"
"void main() {"
- "sk_OutColor = float4(1);"
+ "sk_OutColor = half4(1);"
"}",
*SkSL::ShaderCapsFactory::Default(),
{
@@ -243,16 +243,16 @@ DEF_TEST(SkSLFPSections, r) {
test(r,
"@cpp { cpp section }"
"void main() {"
- "sk_OutColor = float4(1);"
+ "sk_OutColor = half4(1);"
"}",
*SkSL::ShaderCapsFactory::Default(),
{},
{"cpp section"});
test(r,
"@constructorParams { int x, float y, std::vector<float> z }"
- "in float w;"
+ "in highfloat w;"
"void main() {"
- "sk_OutColor = float4(1);"
+ "sk_OutColor = highfloat4(1);"
"}",
*SkSL::ShaderCapsFactory::Default(),
{
@@ -265,7 +265,7 @@ DEF_TEST(SkSLFPSections, r) {
test(r,
"@constructor { constructor section }"
"void main() {"
- "sk_OutColor = float4(1);"
+ "sk_OutColor = half4(1);"
"}",
*SkSL::ShaderCapsFactory::Default(),
{
@@ -275,7 +275,7 @@ DEF_TEST(SkSLFPSections, r) {
test(r,
"@initializers { initializers section }"
"void main() {"
- "sk_OutColor = float4(1);"
+ "sk_OutColor = half4(1);"
"}",
*SkSL::ShaderCapsFactory::Default(),
{
@@ -283,22 +283,22 @@ DEF_TEST(SkSLFPSections, r) {
},
{});
test(r,
- "float x = 10;"
- "@emitCode { fragBuilder->codeAppendf(\"float y = %d\\n\", x * 2); }"
+ "half x = 10;"
+ "@emitCode { fragBuilder->codeAppendf(\"half y = %d\\n\", x * 2); }"
"void main() {"
- "sk_OutColor = float4(1);"
+ "sk_OutColor = half4(1);"
"}",
*SkSL::ShaderCapsFactory::Default(),
{},
{
"x = 10.0;\n"
- " fragBuilder->codeAppendf(\"float y = %d\\n\", x * 2);"
+ " fragBuilder->codeAppendf(\"half y = %d\\n\", x * 2);"
});
test(r,
"@fields { fields section }"
"@clone { }"
"void main() {"
- "sk_OutColor = float4(1);"
+ "sk_OutColor = half4(1);"
"}",
*SkSL::ShaderCapsFactory::Default(),
{
@@ -309,7 +309,7 @@ DEF_TEST(SkSLFPSections, r) {
test(r,
"@make { make section }"
"void main() {"
- "sk_OutColor = float4(1);"
+ "sk_OutColor = half4(1);"
"}",
*SkSL::ShaderCapsFactory::Default(),
{
@@ -318,11 +318,11 @@ DEF_TEST(SkSLFPSections, r) {
},
{});
test(r,
- "uniform float calculated;"
- "in float provided;"
+ "uniform half calculated;"
+ "in half provided;"
"@setData(varName) { varName.set1f(calculated, provided * 2); }"
"void main() {"
- "sk_OutColor = float4(1);"
+ "sk_OutColor = half4(1);"
"}",
*SkSL::ShaderCapsFactory::Default(),
{},
@@ -336,7 +336,7 @@ DEF_TEST(SkSLFPSections, r) {
test(r,
"@test(testDataName) { testDataName section }"
"void main() {"
- "sk_OutColor = float4(1);"
+ "sk_OutColor = half4(1);"
"}",
*SkSL::ShaderCapsFactory::Default(),
{},
@@ -353,7 +353,7 @@ DEF_TEST(SkSLFPColorSpaceXform, r) {
"in uniform sampler2D image;"
"in uniform colorSpaceXform colorXform;"
"void main() {"
- "sk_OutColor = sk_InColor * texture(image, float2(0, 0), colorXform);"
+ "sk_OutColor = sk_InColor * texture(image, highfloat2(0, 0), colorXform);"
"}",
*SkSL::ShaderCapsFactory::Default(),
{
@@ -363,12 +363,12 @@ DEF_TEST(SkSLFPColorSpaceXform, r) {
"sk_sp<GrColorSpaceXform> fColorXform;"
},
{
- "fragBuilder->codeAppendf(\"float4 _tmpVar1;%s = %s * %stexture(%s, "
- "float2(0.0, 0.0)).%s%s;\\n\", args.fOutputColor, args.fInputColor ? args.fInputColor : "
- "\"float4(1)\", fColorSpaceHelper.isValid() ? \"(_tmpVar1 = \" : \"\", "
+ "fragBuilder->codeAppendf(\"half4 _tmpVar1;%s = %s * %stexture(%s, "
+ "highfloat2(0.0, 0.0)).%s%s;\\n\", args.fOutputColor, args.fInputColor ? args.fInputColor : "
+ "\"half4(1)\", fColorSpaceHelper.isValid() ? \"(_tmpVar1 = \" : \"\", "
"fragBuilder->getProgramBuilder()->samplerVariable(args.fTexSamplers[0]).c_str(), "
"fragBuilder->getProgramBuilder()->samplerSwizzle(args.fTexSamplers[0]).c_str(), "
- "fColorSpaceHelper.isValid() ? SkStringPrintf(\", float4(clamp((%s * float4(_tmpVar1.rgb, "
+ "fColorSpaceHelper.isValid() ? SkStringPrintf(\", half4(clamp((%s * half4(_tmpVar1.rgb, "
"1.0)).rgb, 0.0, _tmpVar1.a), _tmpVar1.a))\", args.fUniformHandler->getUniformCStr("
"fColorSpaceHelper.gamutXformUniform())).c_str() : \"\");"
});
@@ -377,14 +377,14 @@ DEF_TEST(SkSLFPColorSpaceXform, r) {
DEF_TEST(SkSLFPTransformedCoords, r) {
test(r,
"void main() {"
- "sk_OutColor = float4(sk_TransformedCoords2D[0], sk_TransformedCoords2D[0]);"
+ "sk_OutColor = half4(sk_TransformedCoords2D[0], sk_TransformedCoords2D[0]);"
"}",
*SkSL::ShaderCapsFactory::Default(),
{},
{
"SkString sk_TransformedCoords2D_0 = "
"fragBuilder->ensureCoords2D(args.fTransformedCoords[0]);",
- "fragBuilder->codeAppendf(\"%s = float4(%s, %s);\\n\", args.fOutputColor, "
+ "fragBuilder->codeAppendf(\"%s = half4(%s, %s);\\n\", args.fOutputColor, "
"sk_TransformedCoords2D_0.c_str(), sk_TransformedCoords2D_0.c_str());"
});
@@ -392,7 +392,7 @@ DEF_TEST(SkSLFPTransformedCoords, r) {
DEF_TEST(SkSLFPLayoutWhen, r) {
test(r,
- "layout(when=someExpression(someOtherExpression())) uniform float sometimes;"
+ "layout(when=someExpression(someOtherExpression())) uniform half sometimes;"
"void main() {"
"}",
*SkSL::ShaderCapsFactory::Default(),
diff --git a/tests/SkSLGLSLTest.cpp b/tests/SkSLGLSLTest.cpp
index a7f6740442..73c6dccbde 100644
--- a/tests/SkSLGLSLTest.cpp
+++ b/tests/SkSLGLSLTest.cpp
@@ -51,7 +51,7 @@ static void test(skiatest::Reporter* r, const char* src, const GrShaderCaps& cap
DEF_TEST(SkSLHelloWorld, r) {
test(r,
- "void main() { sk_FragColor = float4(0.75); }",
+ "void main() { sk_FragColor = highfloat4(0.75); }",
*SkSL::ShaderCapsFactory::Default(),
"#version 400\n"
"out vec4 sk_FragColor;\n"
@@ -63,7 +63,7 @@ DEF_TEST(SkSLHelloWorld, r) {
DEF_TEST(SkSLControl, r) {
test(r,
"void main() {"
- "if (sqrt(2) > 5) { sk_FragColor = float4(0.75); } else { discard; }"
+ "if (sqrt(2) > 5) { sk_FragColor = highfloat4(0.75); } else { discard; }"
"int i = 0;"
"while (i < 10) { sk_FragColor *= 0.5; i++; }"
"do { sk_FragColor += 0.01; } while (sk_FragColor.x < 0.75);"
@@ -98,9 +98,9 @@ DEF_TEST(SkSLControl, r) {
DEF_TEST(SkSLFunctions, r) {
test(r,
- "float foo(float v[2]) { return v[0] * v[1]; }"
- "void bar(inout float x) { float y[2], z; y[0] = x; y[1] = x * 2; z = foo(y); x = z; }"
- "void main() { float x = 10; bar(x); sk_FragColor = float4(x); }",
+ "highfloat foo(highfloat v[2]) { return v[0] * v[1]; }"
+ "void bar(inout highfloat x) { highfloat y[2], z; y[0] = x; y[1] = x * 2; z = foo(y); x = z; }"
+ "void main() { highfloat x = 10; bar(x); sk_FragColor = highfloat4(x); }",
*SkSL::ShaderCapsFactory::Default(),
"#version 400\n"
"out vec4 sk_FragColor;\n"
@@ -124,7 +124,7 @@ DEF_TEST(SkSLFunctions, r) {
DEF_TEST(SkSLOperators, r) {
test(r,
"void main() {"
- "float x = 1, y = 2;"
+ "highfloat x = 1, y = 2;"
"int z = 3;"
"x = x - x + y * z * x * (y - z);"
"y = x / y / z;"
@@ -142,8 +142,8 @@ DEF_TEST(SkSLOperators, r) {
"z >>= 2;"
"z <<= 4;"
"z %= 5;"
- "x = (float2(sqrt(1)) , 6);"
- "z = (float2(sqrt(1)) , 6);"
+ "x = (highfloat2(sqrt(1)) , 6);"
+ "z = (highfloat2(sqrt(1)) , 6);"
"}",
*SkSL::ShaderCapsFactory::Default(),
"#version 400\n"
@@ -175,12 +175,12 @@ DEF_TEST(SkSLOperators, r) {
DEF_TEST(SkSLMatrices, r) {
test(r,
"void main() {"
- "float2x4 x = float2x4(1);"
- "float3x2 y = float3x2(1, 0, 0, 1, float2(2, 2));"
- "float3x4 z = x * y;"
- "float3 v1 = float3x3(1) * float3(2);"
- "float3 v2 = float3(2) * float3x3(1);"
- "sk_FragColor = float4(z[0].x, v1 + v2);"
+ "highfloat2x4 x = highfloat2x4(1);"
+ "highfloat3x2 y = highfloat3x2(1, 0, 0, 1, highfloat2(2, 2));"
+ "highfloat3x4 z = x * y;"
+ "highfloat3 v1 = highfloat3x3(1) * highfloat3(2);"
+ "highfloat3 v2 = highfloat3(2) * highfloat3x3(1);"
+ "sk_FragColor = highfloat4(z[0].x, v1 + v2);"
"}",
*SkSL::ShaderCapsFactory::Default(),
"#version 400\n"
@@ -196,13 +196,13 @@ DEF_TEST(SkSLMatrices, r) {
DEF_TEST(SkSLInterfaceBlock, r) {
test(r,
"uniform testBlock {"
- "float x;"
- "float y[2];"
- "layout(binding=12) float3x2 z;"
+ "half x;"
+ "half y[2];"
+ "layout(binding=12) half3x2 z;"
"bool w;"
"};"
"void main() {"
- " sk_FragColor = float4(x, y[0], y[1], 0);"
+ " sk_FragColor = half4(x, y[0], y[1], 0);"
"}",
*SkSL::ShaderCapsFactory::Default(),
"#version 400\n"
@@ -218,10 +218,10 @@ DEF_TEST(SkSLInterfaceBlock, r) {
"}\n");
test(r,
"uniform testBlock {"
- "float x;"
+ "highfloat x;"
"} test;"
"void main() {"
- " sk_FragColor = float4(test.x);"
+ " sk_FragColor = half4(test.x);"
"}",
*SkSL::ShaderCapsFactory::Default(),
"#version 400\n"
@@ -234,10 +234,10 @@ DEF_TEST(SkSLInterfaceBlock, r) {
"}\n");
test(r,
"uniform testBlock {"
- "float x;"
+ "highfloat x;"
"} test[2];"
"void main() {"
- " sk_FragColor = float4(test[1].x);"
+ " sk_FragColor = half4(test[1].x);"
"}",
*SkSL::ShaderCapsFactory::Default(),
"#version 400\n"
@@ -258,8 +258,8 @@ DEF_TEST(SkSLStructs, r) {
"} a1, a2;"
"A a3;"
"struct B {"
- "float x;"
- "float y[2];"
+ "highfloat x;"
+ "highfloat y[2];"
"layout(binding=1) A z;"
"};"
"B b1, b2, b3;"
@@ -284,7 +284,7 @@ DEF_TEST(SkSLStructs, r) {
DEF_TEST(SkSLVersion, r) {
test(r,
- "in float test; void main() { sk_FragColor = float4(0.75); }",
+ "in highfloat test; void main() { sk_FragColor = highfloat4(0.75); }",
*SkSL::ShaderCapsFactory::Version450Core(),
"#version 450 core\n"
"out vec4 sk_FragColor;\n"
@@ -293,7 +293,7 @@ DEF_TEST(SkSLVersion, r) {
" sk_FragColor = vec4(0.75);\n"
"}\n");
test(r,
- "in float test; void main() { sk_FragColor = float4(0.75); }",
+ "in highfloat test; void main() { sk_FragColor = highfloat4(0.75); }",
*SkSL::ShaderCapsFactory::Version110(),
"#version 110\n"
"varying float test;\n"
@@ -304,8 +304,8 @@ DEF_TEST(SkSLVersion, r) {
DEF_TEST(SkSLUsesPrecisionModifiers, r) {
test(r,
- "void main() { float x = 0.75; highp float y = 1; x++; y++;"
- "sk_FragColor.rg = float2(x, y); }",
+ "void main() { half x = 0.75; highfloat y = 1; x++; y++;"
+ "sk_FragColor.rg = half2(x, y); }",
*SkSL::ShaderCapsFactory::Default(),
"#version 400\n"
"out vec4 sk_FragColor;\n"
@@ -317,15 +317,14 @@ DEF_TEST(SkSLUsesPrecisionModifiers, r) {
" sk_FragColor.xy = vec2(x, y);\n"
"}\n");
test(r,
- "void main() { float x = 0.75; half y = 1; x++; y++;"
- "sk_FragColor.rg = float2(x, y); }",
+ "void main() { half x = 0.75; highfloat y = 1; x++; y++;"
+ "sk_FragColor.rg = half2(x, y); }",
*SkSL::ShaderCapsFactory::UsesPrecisionModifiers(),
"#version 400\n"
- "precision highp float;\n"
"out mediump vec4 sk_FragColor;\n"
"void main() {\n"
- " float x = 0.75;\n"
- " mediump float y = 1.0;\n"
+ " mediump float x = 0.75;\n"
+ " highp float y = 1.0;\n"
" x++;\n"
" y++;\n"
" sk_FragColor.xy = vec2(x, y);\n"
@@ -335,7 +334,7 @@ DEF_TEST(SkSLUsesPrecisionModifiers, r) {
DEF_TEST(SkSLMinAbs, r) {
test(r,
"void main() {"
- "float x = -5;"
+ "highfloat x = -5;"
"sk_FragColor.r = min(abs(x), 6);"
"}",
*SkSL::ShaderCapsFactory::Default(),
@@ -347,7 +346,7 @@ DEF_TEST(SkSLMinAbs, r) {
test(r,
"void main() {"
- "float x = -5.0;"
+ "highfloat x = -5.0;"
"sk_FragColor.r = min(abs(x), 6.0);"
"}",
*SkSL::ShaderCapsFactory::CannotUseMinAndAbsTogether(),
@@ -364,7 +363,7 @@ DEF_TEST(SkSLMinAbs, r) {
DEF_TEST(SkSLFractNegative, r) {
static constexpr char input[] =
"void main() {"
- "float x = -42.0;"
+ "highfloat x = -42.0;"
"sk_FragColor.r = fract(x);"
"}";
static constexpr char output_default[] =
@@ -386,7 +385,7 @@ DEF_TEST(SkSLFractNegative, r) {
DEF_TEST(SkSLNegatedAtan, r) {
test(r,
- "void main() { float2 x = float2(sqrt(2)); sk_FragColor.r = atan(x.x, -x.y); }",
+ "void main() { highfloat2 x = highfloat2(sqrt(2)); sk_FragColor.r = atan(x.x, -x.y); }",
*SkSL::ShaderCapsFactory::Default(),
"#version 400\n"
"out vec4 sk_FragColor;\n"
@@ -395,7 +394,7 @@ DEF_TEST(SkSLNegatedAtan, r) {
" sk_FragColor.x = atan(x.x, -x.y);\n"
"}\n");
test(r,
- "void main() { float2 x = float2(sqrt(2)); sk_FragColor.r = atan(x.x, -x.y); }",
+ "void main() { highfloat2 x = highfloat2(sqrt(2)); sk_FragColor.r = atan(x.x, -x.y); }",
*SkSL::ShaderCapsFactory::MustForceNegatedAtanParamToFloat(),
"#version 400\n"
"out vec4 sk_FragColor;\n"
@@ -466,13 +465,13 @@ DEF_TEST(SkSLHex, r) {
DEF_TEST(SkSLVectorConstructors, r) {
test(r,
- "float2 v1 = float2(1);"
- "float2 v2 = float2(1, 2);"
- "float2 v3 = float2(float2(1));"
- "float3 v4 = float3(float2(1), 1.0);"
+ "highfloat2 v1 = highfloat2(1);"
+ "highfloat2 v2 = highfloat2(1, 2);"
+ "highfloat2 v3 = highfloat2(highfloat2(1));"
+ "highfloat3 v4 = highfloat3(highfloat2(1), 1.0);"
"int2 v5 = int2(1);"
- "int2 v6 = int2(float2(1, 2));"
- "float2 v7 = float2(int2(1, 2));",
+ "int2 v6 = int2(highfloat2(1, 2));"
+ "highfloat2 v7 = highfloat2(int2(1, 2));",
*SkSL::ShaderCapsFactory::Default(),
"#version 400\n"
"out vec4 sk_FragColor;\n"
@@ -487,9 +486,9 @@ DEF_TEST(SkSLVectorConstructors, r) {
DEF_TEST(SkSLArrayConstructors, r) {
test(r,
- "float test1[] = float[](1, 2, 3, 4);"
- "float2 test2[] = float2[](float2(1, 2), float2(3, 4));"
- "float4x4 test3[] = float4x4[]();",
+ "highfloat test1[] = highfloat[](1, 2, 3, 4);"
+ "highfloat2 test2[] = highfloat2[](highfloat2(1, 2), highfloat2(3, 4));"
+ "highfloat4x4 test3[] = highfloat4x4[]();",
*SkSL::ShaderCapsFactory::Default(),
"#version 400\n"
"out vec4 sk_FragColor;\n"
@@ -511,7 +510,6 @@ DEF_TEST(SkSLDerivatives, r) {
"void main() { sk_FragColor.r = 1; }",
*SkSL::ShaderCapsFactory::ShaderDerivativeExtensionString(),
"#version 400\n"
- "precision highp float;\n"
"out mediump vec4 sk_FragColor;\n"
"void main() {\n"
" sk_FragColor.x = 1.0;\n"
@@ -521,7 +519,6 @@ DEF_TEST(SkSLDerivatives, r) {
*SkSL::ShaderCapsFactory::ShaderDerivativeExtensionString(),
"#version 400\n"
"#extension GL_OES_standard_derivatives : require\n"
- "precision highp float;\n"
"out mediump vec4 sk_FragColor;\n"
"void main() {\n"
" sk_FragColor.x = dFdx(1.0);\n"
@@ -717,55 +714,55 @@ DEF_TEST(SkSLBoolFolding, r) {
DEF_TEST(SkSLVecFolding, r) {
test(r,
"void main() {"
- "sk_FragColor.r = float4(0.5, 1, 1, 1).x;"
- "sk_FragColor = float4(float2(1), float2(2, 3)) + float4(5, 6, 7, 8);"
- "sk_FragColor = float4(8, float3(10)) - float4(1);"
- "sk_FragColor = float4(2) * float4(1, 2, 3, 4);"
- "sk_FragColor = float4(12) / float4(1, 2, 3, 4);"
- "sk_FragColor.r = (float4(12) / float4(1, 2, 3, 4)).y;"
- "sk_FragColor.x = float4(1) == float4(1) ? 1.0 : -1.0;"
- "sk_FragColor.x = float4(1) == float4(2) ? 2.0 : -2.0;"
- "sk_FragColor.x = float2(1) == float2(1, 1) ? 3.0 : -3.0;"
- "sk_FragColor.x = float2(1, 1) == float2(1, 1) ? 4.0 : -4.0;"
- "sk_FragColor.x = float2(1) == float2(1, 0) ? 5.0 : -5.0;"
- "sk_FragColor.x = float4(1) == float4(float2(1), float2(1)) ? 6.0 : -6.0;"
- "sk_FragColor.x = float4(float3(1), 1) == float4(float2(1), float2(1)) ? 7.0 : -7.0;"
- "sk_FragColor.x = float4(float3(1), 1) == float4(float2(1), 1, 0) ? 8.0 : -8.0;"
- "sk_FragColor.x = float2(1) != float2(1, 0) ? 9.0 : -9.0;"
- "sk_FragColor.x = float4(1) != float4(float2(1), float2(1)) ? 10.0 : -10.0;"
- "sk_FragColor = float4(sqrt(1)) * float4(1);"
- "sk_FragColor = float4(1) * float4(sqrt(2));"
- "sk_FragColor = float4(0) * float4(sqrt(3));"
- "sk_FragColor = float4(sqrt(4)) * float4(0);"
- "sk_FragColor = float4(0) / float4(sqrt(5));"
- "sk_FragColor = float4(0) + float4(sqrt(6));"
- "sk_FragColor = float4(sqrt(7)) + float4(0);"
- "sk_FragColor = float4(sqrt(8)) - float4(0);"
- "sk_FragColor = float4(0) + sqrt(9);"
- "sk_FragColor = float4(0) * sqrt(10);"
- "sk_FragColor = float4(0) / sqrt(11);"
- "sk_FragColor = float4(1) * sqrt(12);"
- "sk_FragColor = 0 + float4(sqrt(13));"
- "sk_FragColor = 0 * float4(sqrt(14));"
- "sk_FragColor = 0 / float4(sqrt(15));"
- "sk_FragColor = 1 * float4(sqrt(16));"
- "sk_FragColor = float4(sqrt(17)) + 0;"
- "sk_FragColor = float4(sqrt(18)) * 0;"
- "sk_FragColor = float4(sqrt(19)) * 1;"
- "sk_FragColor = float4(sqrt(19.5)) - 0;"
- "sk_FragColor = sqrt(20) * float4(1);"
- "sk_FragColor = sqrt(21) + float4(0);"
- "sk_FragColor = sqrt(22) - float4(0);"
- "sk_FragColor = sqrt(23) / float4(1);"
- "sk_FragColor = float4(sqrt(24)) / 1;"
- "sk_FragColor += float4(1);"
- "sk_FragColor += float4(0);"
- "sk_FragColor -= float4(1);"
- "sk_FragColor -= float4(0);"
- "sk_FragColor *= float4(1);"
- "sk_FragColor *= float4(2);"
- "sk_FragColor /= float4(1);"
- "sk_FragColor /= float4(2);"
+ "sk_FragColor.r = highfloat4(0.5, 1, 1, 1).x;"
+ "sk_FragColor = highfloat4(highfloat2(1), highfloat2(2, 3)) + highfloat4(5, 6, 7, 8);"
+ "sk_FragColor = highfloat4(8, highfloat3(10)) - highfloat4(1);"
+ "sk_FragColor = highfloat4(2) * highfloat4(1, 2, 3, 4);"
+ "sk_FragColor = highfloat4(12) / highfloat4(1, 2, 3, 4);"
+ "sk_FragColor.r = (highfloat4(12) / highfloat4(1, 2, 3, 4)).y;"
+ "sk_FragColor.x = highfloat4(1) == highfloat4(1) ? 1.0 : -1.0;"
+ "sk_FragColor.x = highfloat4(1) == highfloat4(2) ? 2.0 : -2.0;"
+ "sk_FragColor.x = highfloat2(1) == highfloat2(1, 1) ? 3.0 : -3.0;"
+ "sk_FragColor.x = highfloat2(1, 1) == highfloat2(1, 1) ? 4.0 : -4.0;"
+ "sk_FragColor.x = highfloat2(1) == highfloat2(1, 0) ? 5.0 : -5.0;"
+ "sk_FragColor.x = highfloat4(1) == highfloat4(highfloat2(1), highfloat2(1)) ? 6.0 : -6.0;"
+ "sk_FragColor.x = highfloat4(highfloat3(1), 1) == highfloat4(highfloat2(1), highfloat2(1)) ? 7.0 : -7.0;"
+ "sk_FragColor.x = highfloat4(highfloat3(1), 1) == highfloat4(highfloat2(1), 1, 0) ? 8.0 : -8.0;"
+ "sk_FragColor.x = highfloat2(1) != highfloat2(1, 0) ? 9.0 : -9.0;"
+ "sk_FragColor.x = highfloat4(1) != highfloat4(highfloat2(1), highfloat2(1)) ? 10.0 : -10.0;"
+ "sk_FragColor = highfloat4(sqrt(1)) * highfloat4(1);"
+ "sk_FragColor = highfloat4(1) * highfloat4(sqrt(2));"
+ "sk_FragColor = highfloat4(0) * highfloat4(sqrt(3));"
+ "sk_FragColor = highfloat4(sqrt(4)) * highfloat4(0);"
+ "sk_FragColor = highfloat4(0) / highfloat4(sqrt(5));"
+ "sk_FragColor = highfloat4(0) + highfloat4(sqrt(6));"
+ "sk_FragColor = highfloat4(sqrt(7)) + highfloat4(0);"
+ "sk_FragColor = highfloat4(sqrt(8)) - highfloat4(0);"
+ "sk_FragColor = highfloat4(0) + sqrt(9);"
+ "sk_FragColor = highfloat4(0) * sqrt(10);"
+ "sk_FragColor = highfloat4(0) / sqrt(11);"
+ "sk_FragColor = highfloat4(1) * sqrt(12);"
+ "sk_FragColor = 0 + highfloat4(sqrt(13));"
+ "sk_FragColor = 0 * highfloat4(sqrt(14));"
+ "sk_FragColor = 0 / highfloat4(sqrt(15));"
+ "sk_FragColor = 1 * highfloat4(sqrt(16));"
+ "sk_FragColor = highfloat4(sqrt(17)) + 0;"
+ "sk_FragColor = highfloat4(sqrt(18)) * 0;"
+ "sk_FragColor = highfloat4(sqrt(19)) * 1;"
+ "sk_FragColor = highfloat4(sqrt(19.5)) - 0;"
+ "sk_FragColor = sqrt(20) * highfloat4(1);"
+ "sk_FragColor = sqrt(21) + highfloat4(0);"
+ "sk_FragColor = sqrt(22) - highfloat4(0);"
+ "sk_FragColor = sqrt(23) / highfloat4(1);"
+ "sk_FragColor = highfloat4(sqrt(24)) / 1;"
+ "sk_FragColor += highfloat4(1);"
+ "sk_FragColor += highfloat4(0);"
+ "sk_FragColor -= highfloat4(1);"
+ "sk_FragColor -= highfloat4(0);"
+ "sk_FragColor *= highfloat4(1);"
+ "sk_FragColor *= highfloat4(2);"
+ "sk_FragColor /= highfloat4(1);"
+ "sk_FragColor /= highfloat4(2);"
"}",
*SkSL::ShaderCapsFactory::Default(),
"#version 400\n"
@@ -822,24 +819,24 @@ DEF_TEST(SkSLVecFolding, r) {
DEF_TEST(SkSLMatFolding, r) {
test(r,
"void main() {"
- "sk_FragColor.x = float2x2(float2(1.0, 0.0), float2(0.0, 1.0)) == "
- "float2x2(float2(1.0, 0.0), float2(0.0, 1.0)) ? 1 : -1;"
- "sk_FragColor.x = float2x2(float2(1.0, 0.0), float2(1.0, 1.0)) == "
- "float2x2(float2(1.0, 0.0), float2(0.0, 1.0)) ? 2 : -2;"
- "sk_FragColor.x = float2x2(1) == float2x2(1) ? 3 : -3;"
- "sk_FragColor.x = float2x2(1) == float2x2(0) ? 4 : -4;"
- "sk_FragColor.x = float2x2(1) == float2x2(float2(1.0, 0.0), float2(0.0, 1.0)) ? 5 : -5;"
- "sk_FragColor.x = float2x2(2) == float2x2(float2(1.0, 0.0), float2(0.0, 1.0)) ? 6 : -6;"
- "sk_FragColor.x = float3x2(2) == float3x2(float2(2.0, 0.0), float2(0.0, 2.0), float2(0.0))"
+ "sk_FragColor.x = highfloat2x2(highfloat2(1.0, 0.0), highfloat2(0.0, 1.0)) == "
+ "highfloat2x2(highfloat2(1.0, 0.0), highfloat2(0.0, 1.0)) ? 1 : -1;"
+ "sk_FragColor.x = highfloat2x2(highfloat2(1.0, 0.0), highfloat2(1.0, 1.0)) == "
+ "highfloat2x2(highfloat2(1.0, 0.0), highfloat2(0.0, 1.0)) ? 2 : -2;"
+ "sk_FragColor.x = highfloat2x2(1) == highfloat2x2(1) ? 3 : -3;"
+ "sk_FragColor.x = highfloat2x2(1) == highfloat2x2(0) ? 4 : -4;"
+ "sk_FragColor.x = highfloat2x2(1) == highfloat2x2(highfloat2(1.0, 0.0), highfloat2(0.0, 1.0)) ? 5 : -5;"
+ "sk_FragColor.x = highfloat2x2(2) == highfloat2x2(highfloat2(1.0, 0.0), highfloat2(0.0, 1.0)) ? 6 : -6;"
+ "sk_FragColor.x = highfloat3x2(2) == highfloat3x2(highfloat2(2.0, 0.0), highfloat2(0.0, 2.0), highfloat2(0.0))"
"? 7 : -7;"
- "sk_FragColor.x = float2x2(1) != float2x2(1) ? 8 : -8;"
- "sk_FragColor.x = float2x2(1) != float2x2(0) ? 9 : -9;"
- "sk_FragColor.x = float3x3(float3(1.0, 0.0, 0.0), float3(0.0, 1.0, 0.0), "
- "float3(0.0, 0.0, 0.0)) == float3x3(float2x2(1.0)) ? 10 : -10;"
- "sk_FragColor.x = float2x2(float3x3(1.0)) == float2x2(1.0) ? 11 : -11;"
- "sk_FragColor.x = float2x2(float4(1.0, 0.0, 0.0, 1.0)) == float2x2(1.0) ? 12 : -12;"
- "sk_FragColor.x = float2x2(1.0, 0.0, float2(0.0, 1.0)) == float2x2(1.0) ? 13 : -13;"
- "sk_FragColor.x = float2x2(float2(1.0, 0.0), 0.0, 1.0) == float2x2(1.0) ? 14 : -14;"
+ "sk_FragColor.x = highfloat2x2(1) != highfloat2x2(1) ? 8 : -8;"
+ "sk_FragColor.x = highfloat2x2(1) != highfloat2x2(0) ? 9 : -9;"
+ "sk_FragColor.x = highfloat3x3(highfloat3(1.0, 0.0, 0.0), highfloat3(0.0, 1.0, 0.0), "
+ "highfloat3(0.0, 0.0, 0.0)) == highfloat3x3(highfloat2x2(1.0)) ? 10 : -10;"
+ "sk_FragColor.x = highfloat2x2(highfloat3x3(1.0)) == highfloat2x2(1.0) ? 11 : -11;"
+ "sk_FragColor.x = highfloat2x2(highfloat4(1.0, 0.0, 0.0, 1.0)) == highfloat2x2(1.0) ? 12 : -12;"
+ "sk_FragColor.x = highfloat2x2(1.0, 0.0, highfloat2(0.0, 1.0)) == highfloat2x2(1.0) ? 13 : -13;"
+ "sk_FragColor.x = highfloat2x2(highfloat2(1.0, 0.0), 0.0, 1.0) == highfloat2x2(1.0) ? 14 : -14;"
"}",
*SkSL::ShaderCapsFactory::Default(),
"#version 400\n"
@@ -891,7 +888,7 @@ DEF_TEST(SkSLCaps, r) {
"if (sk_Caps.fbFetchSupport) y = 1;"
"if (sk_Caps.dropsTileOnZeroDivide && sk_Caps.texelFetchSupport) z = 1;"
"if (sk_Caps.dropsTileOnZeroDivide && sk_Caps.canUseAnyFunctionInShader) w = 1;"
- "sk_FragColor = float4(x, y, z, w);"
+ "sk_FragColor = half4(x, y, z, w);"
"}",
*SkSL::ShaderCapsFactory::VariousCaps(),
"#version 400\n"
@@ -906,11 +903,11 @@ DEF_TEST(SkSLTexture, r) {
"uniform sampler1D one;"
"uniform sampler2D two;"
"void main() {"
- "float4 a = texture(one, 0);"
- "float4 b = texture(two, float2(0));"
- "float4 c = texture(one, float2(0));"
- "float4 d = texture(two, float3(0));"
- "sk_FragColor = float4(a.x, b.x, c.x, d.x);"
+ "highfloat4 a = texture(one, 0);"
+ "highfloat4 b = texture(two, highfloat2(0));"
+ "highfloat4 c = texture(one, highfloat2(0));"
+ "highfloat4 d = texture(two, highfloat3(0));"
+ "sk_FragColor = half4(a.x, b.x, c.x, d.x);"
"}",
*SkSL::ShaderCapsFactory::Default(),
"#version 400\n"
@@ -928,11 +925,11 @@ DEF_TEST(SkSLTexture, r) {
"uniform sampler1D one;"
"uniform sampler2D two;"
"void main() {"
- "float4 a = texture(one, 0);"
- "float4 b = texture(two, float2(0));"
- "float4 c = texture(one, float2(0));"
- "float4 d = texture(two, float3(0));"
- "sk_FragColor = float4(a.x, b.x, c.x, d.x);"
+ "highfloat4 a = texture(one, 0);"
+ "highfloat4 b = texture(two, highfloat2(0));"
+ "highfloat4 c = texture(one, highfloat2(0));"
+ "highfloat4 d = texture(two, highfloat3(0));"
+ "sk_FragColor = half4(a.x, b.x, c.x, d.x);"
"}",
*SkSL::ShaderCapsFactory::Version110(),
"#version 110\n"
@@ -1047,7 +1044,7 @@ DEF_TEST(SkSLClipDistance, r) {
"}\n",
SkSL::Program::kVertex_Kind);
test(r,
- "void main() { sk_FragColor = float4(sk_ClipDistance[0]); }",
+ "void main() { sk_FragColor = half4(sk_ClipDistance[0]); }",
*SkSL::ShaderCapsFactory::Default(),
"#version 400\n"
"out vec4 sk_FragColor;\n"
@@ -1058,9 +1055,9 @@ DEF_TEST(SkSLClipDistance, r) {
DEF_TEST(SkSLArrayTypes, r) {
test(r,
- "void main() { float2 x[2] = float2[2](float2(1), float2(2));"
- "float2[2] y = float2[2](float2(3), float2(4));"
- "sk_FragColor = float4(x[0], y[1]); }",
+ "void main() { highfloat2 x[2] = highfloat2[2](highfloat2(1), highfloat2(2));"
+ "highfloat2[2] y = highfloat2[2](highfloat2(3), highfloat2(4));"
+ "sk_FragColor = highfloat4(x[0], y[1]); }",
*SkSL::ShaderCapsFactory::Default(),
"#version 400\n"
"out vec4 sk_FragColor;\n"
@@ -1076,9 +1073,9 @@ DEF_TEST(SkSLGeometry, r) {
"layout(invocations = 2) in;"
"layout(line_strip, max_vertices = 2) out;"
"void main() {"
- "gl_Position = sk_in[0].gl_Position + float4(-0.5, 0, 0, sk_InvocationID);"
+ "gl_Position = sk_in[0].gl_Position + highfloat4(-0.5, 0, 0, sk_InvocationID);"
"EmitVertex();"
- "gl_Position = sk_in[0].gl_Position + float4(0.5, 0, 0, sk_InvocationID);"
+ "gl_Position = sk_in[0].gl_Position + highfloat4(0.5, 0, 0, sk_InvocationID);"
"EmitVertex();"
"EndPrimitive();"
"}",
@@ -1101,7 +1098,7 @@ DEF_TEST(SkSLSwitch, r) {
// basic "does a switch even work" test
test(r,
"void main() {"
- " float x;"
+ " highfloat x;"
" switch (int(sqrt(1))) {"
" case 0:"
" x = 0.0;"
@@ -1112,7 +1109,7 @@ DEF_TEST(SkSLSwitch, r) {
" default:"
" x = 2.0;"
" }"
- " sk_FragColor = float4(x);"
+ " sk_FragColor = highfloat4(x);"
"}",
*SkSL::ShaderCapsFactory::Default(),
"#version 400\n"
@@ -1134,7 +1131,7 @@ DEF_TEST(SkSLSwitch, r) {
// dead code inside of switch
test(r,
"void main() {"
- " float x;"
+ " highfloat x;"
" switch (int(sqrt(2))) {"
" case 0:"
" x = 0.0;"
@@ -1143,7 +1140,7 @@ DEF_TEST(SkSLSwitch, r) {
" default:"
" x = 2.0;"
" }"
- " sk_FragColor = float4(x);"
+ " sk_FragColor = half4(x);"
"}",
*SkSL::ShaderCapsFactory::Default(),
"#version 400\n"
@@ -1162,14 +1159,14 @@ DEF_TEST(SkSLSwitch, r) {
// non-static test w/ fallthrough
test(r,
"void main() {"
- " float x = 0.0;"
+ " highfloat x = 0.0;"
" switch (int(sqrt(3))) {"
" case 0:"
" x = 0.0;"
" case 1:"
" x = 1.0;"
" }"
- " sk_FragColor = float4(x);"
+ " sk_FragColor = half4(x);"
"}",
*SkSL::ShaderCapsFactory::Default(),
"#version 400\n"
@@ -1187,14 +1184,14 @@ DEF_TEST(SkSLSwitch, r) {
// static test w/ fallthrough
test(r,
"void main() {"
- " float x = 0.0;"
+ " highfloat x = 0.0;"
" switch (0) {"
" case 0:"
" x = 0.0;"
" case 1:"
" x = 1.0;"
" }"
- " sk_FragColor = float4(x);"
+ " sk_FragColor = half4(x);"
"}",
*SkSL::ShaderCapsFactory::Default(),
"#version 400\n"
@@ -1205,14 +1202,14 @@ DEF_TEST(SkSLSwitch, r) {
// static test w/ fallthrough, different entry point
test(r,
"void main() {"
- " float x = 0.0;"
+ " highfloat x = 0.0;"
" switch (1) {"
" case 0:"
" x = 0.0;"
" case 1:"
" x = 1.0;"
" }"
- " sk_FragColor = float4(x);"
+ " sk_FragColor = half4(x);"
"}",
*SkSL::ShaderCapsFactory::Default(),
"#version 400\n"
@@ -1223,7 +1220,7 @@ DEF_TEST(SkSLSwitch, r) {
// static test w/ break
test(r,
"void main() {"
- " float x = 0.0;"
+ " highfloat x = 0.0;"
" switch (0) {"
" case 0:"
" x = 0.0;"
@@ -1231,7 +1228,7 @@ DEF_TEST(SkSLSwitch, r) {
" case 1:"
" x = 1.0;"
" }"
- " sk_FragColor = float4(x);"
+ " sk_FragColor = half4(x);"
"}",
*SkSL::ShaderCapsFactory::Default(),
"#version 400\n"
@@ -1242,7 +1239,7 @@ DEF_TEST(SkSLSwitch, r) {
// static test w/ static conditional break
test(r,
"void main() {"
- " float x = 0.0;"
+ " highfloat x = 0.0;"
" switch (0) {"
" case 0:"
" x = 0.0;"
@@ -1250,7 +1247,7 @@ DEF_TEST(SkSLSwitch, r) {
" case 1:"
" x = 1.0;"
" }"
- " sk_FragColor = float4(x);"
+ " sk_FragColor = half4(x);"
"}",
*SkSL::ShaderCapsFactory::Default(),
"#version 400\n"
@@ -1261,7 +1258,7 @@ DEF_TEST(SkSLSwitch, r) {
// static test w/ non-static conditional break
test(r,
"void main() {"
- " float x = 0.0;"
+ " highfloat x = 0.0;"
" switch (0) {"
" case 0:"
" x = 0.0;"
@@ -1269,7 +1266,7 @@ DEF_TEST(SkSLSwitch, r) {
" case 1:"
" x = 1.0;"
" }"
- " sk_FragColor = float4(x);"
+ " sk_FragColor = half4(x);"
"}",
*SkSL::ShaderCapsFactory::Default(),
"#version 400\n"
@@ -1291,7 +1288,7 @@ DEF_TEST(SkSLRectangleTexture, r) {
test(r,
"uniform sampler2D test;"
"void main() {"
- " sk_FragColor = texture(test, float2(0.5));"
+ " sk_FragColor = texture(test, highfloat2(0.5));"
"}",
*SkSL::ShaderCapsFactory::Default(),
"#version 400\n"
@@ -1303,7 +1300,7 @@ DEF_TEST(SkSLRectangleTexture, r) {
test(r,
"uniform sampler2DRect test;"
"void main() {"
- " sk_FragColor = texture(test, float2(0.5));"
+ " sk_FragColor = texture(test, highfloat2(0.5));"
"}",
*SkSL::ShaderCapsFactory::Default(),
"#version 400\n"
@@ -1315,7 +1312,7 @@ DEF_TEST(SkSLRectangleTexture, r) {
test(r,
"uniform sampler2DRect test;"
"void main() {"
- " sk_FragColor = texture(test, float3(0.5));"
+ " sk_FragColor = texture(test, highfloat3(0.5));"
"}",
*SkSL::ShaderCapsFactory::Default(),
"#version 400\n"
@@ -1329,12 +1326,12 @@ DEF_TEST(SkSLRectangleTexture, r) {
DEF_TEST(SkSLUnusedVars, r) {
test(r,
"void main() {"
- "float a = 1, b = 2, c = 3;"
- "float d = c;"
- "float e = d;"
+ "highfloat a = 1, b = 2, c = 3;"
+ "highfloat d = c;"
+ "highfloat e = d;"
"b++;"
"d++;"
- "sk_FragColor = float4(b, b, d, d);"
+ "sk_FragColor = highfloat4(b, b, d, d);"
"}",
*SkSL::ShaderCapsFactory::Default(),
"#version 400\n"
@@ -1351,11 +1348,11 @@ DEF_TEST(SkSLUnusedVars, r) {
DEF_TEST(SkSLMultipleAssignments, r) {
test(r,
"void main() {"
- "float x;"
- "float y;"
+ "highfloat x;"
+ "highfloat y;"
"int z;"
"x = y = z = 1;"
- "sk_FragColor = float4(z);"
+ "sk_FragColor = highfloat4(z);"
"}",
*SkSL::ShaderCapsFactory::Default(),
"#version 400\n"
@@ -1367,13 +1364,13 @@ DEF_TEST(SkSLMultipleAssignments, r) {
DEF_TEST(SkSLComplexDelete, r) {
test(r,
- "uniform float4x4 colorXform;"
+ "uniform highfloat4x4 colorXform;"
"uniform sampler2D sampler;"
"void main() {"
- "float4 tmpColor;"
- "sk_FragColor = float4(1.0) * (tmpColor = texture(sampler, float2(1)) , "
- "colorXform != float4x4(1.0) ? float4(clamp((float4x4(colorXform) * "
- "float4(tmpColor.xyz, 1.0)).xyz, "
+ "highfloat4 tmpColor;"
+ "sk_FragColor = highfloat4(1.0) * (tmpColor = texture(sampler, highfloat2(1)) , "
+ "colorXform != highfloat4x4(1.0) ? highfloat4(clamp((highfloat4x4(colorXform) * "
+ "highfloat4(tmpColor.xyz, 1.0)).xyz, "
"0.0, tmpColor.w), tmpColor.w) : tmpColor);"
"}",
*SkSL::ShaderCapsFactory::Default(),
@@ -1392,8 +1389,8 @@ DEF_TEST(SkSLComplexDelete, r) {
DEF_TEST(SkSLDependentInitializers, r) {
test(r,
"void main() {"
- "float x = 0.5, y = x * 2;"
- "sk_FragColor = float4(y);"
+ "highfloat x = 0.5, y = x * 2;"
+ "sk_FragColor = highfloat4(y);"
"}",
*SkSL::ShaderCapsFactory::Default(),
"#version 400\n"
@@ -1427,11 +1424,11 @@ DEF_TEST(SkSLInvocations, r) {
"layout(invocations = 2) in;"
"layout(line_strip, max_vertices = 2) out;"
"void test() {"
- "gl_Position = sk_in[0].gl_Position + float4(0.5, 0, 0, sk_InvocationID);"
+ "gl_Position = sk_in[0].gl_Position + highfloat4(0.5, 0, 0, sk_InvocationID);"
"EmitVertex();"
"}"
"void main() {"
- "gl_Position = sk_in[0].gl_Position + float4(-0.5, 0, 0, sk_InvocationID);"
+ "gl_Position = sk_in[0].gl_Position + highfloat4(-0.5, 0, 0, sk_InvocationID);"
"EmitVertex();"
"}",
*SkSL::ShaderCapsFactory::MustImplementGSInvocationsWithLoop(),
@@ -1458,13 +1455,13 @@ DEF_TEST(SkSLInvocations, r) {
DEF_TEST(SkSLTypePrecision, r) {
test(r,
- "float f = 1;"
+ "highfloat f = 1;"
"half h = 2;"
"double d = 3;"
- "float2 f2 = float2(1, 2);"
+ "highfloat2 f2 = highfloat2(1, 2);"
"half3 h3 = half3(1, 2, 3);"
"double4 d4 = double4(1, 2, 3, 4);"
- "float2x2 f22 = float2x2(1, 2, 3, 4);"
+ "highfloat2x2 f22 = highfloat2x2(1, 2, 3, 4);"
"half2x4 h24 = half2x4(1, 2, 3, 4, 5, 6, 7, 8);"
"double4x2 d42 = double4x2(1, 2, 3, 4, 5, 6, 7, 8);",
*SkSL::ShaderCapsFactory::Default(),
@@ -1480,21 +1477,20 @@ DEF_TEST(SkSLTypePrecision, r) {
"mat2x4 h24 = mat2x4(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0);\n"
"dmat4x2 d42 = dmat4x2(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0);\n");
test(r,
- "float f = 1;"
+ "highfloat f = 1;"
"half h = 2;"
- "float2 f2 = float2(1, 2);"
+ "highfloat2 f2 = highfloat2(1, 2);"
"half3 h3 = half3(1, 2, 3);"
- "float2x2 f22 = float2x2(1, 2, 3, 4);"
+ "highfloat2x2 f22 = highfloat2x2(1, 2, 3, 4);"
"half2x4 h24 = half2x4(1, 2, 3, 4, 5, 6, 7, 8);",
*SkSL::ShaderCapsFactory::UsesPrecisionModifiers(),
"#version 400\n"
- "precision highp float;\n"
"out mediump vec4 sk_FragColor;\n"
- "float f = 1.0;\n"
+ "highp float f = 1.0;\n"
"mediump float h = 2.0;\n"
- "vec2 f2 = vec2(1.0, 2.0);\n"
+ "highp vec2 f2 = vec2(1.0, 2.0);\n"
"mediump vec3 h3 = vec3(1.0, 2.0, 3.0);\n"
- "mat2 f22 = mat2(1.0, 2.0, 3.0, 4.0);\n"
+ "highp mat2 f22 = mat2(1.0, 2.0, 3.0, 4.0);\n"
"mediump mat2x4 h24 = mat2x4(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0);\n");
}
@@ -1505,50 +1501,37 @@ DEF_TEST(SkSLNumberConversions, r) {
"ushort us = ushort(sqrt(1));"
"uint ui = uint(sqrt(1));"
"half h = sqrt(1);"
- "float f = sqrt(1);"
- "double d = sqrt(1);"
+ "highfloat f = sqrt(1);"
"short s2s = s;"
"short i2s = i;"
"short us2s = short(us);"
"short ui2s = short(ui);"
"short h2s = short(h);"
"short f2s = short(f);"
- "short d2fs = short(d);"
"int s2i = s;"
"int i2i = i;"
"int us2i = int(us);"
"int ui2i = int(ui);"
"int h2i = int(h);"
"int f2i = int(f);"
- "int d2fi = int(d);"
"ushort s2us = ushort(s);"
"ushort i2us = ushort(i);"
"ushort us2us = us;"
"ushort ui2us = ui;"
"ushort h2us = ushort(h);"
"ushort f2us = ushort(f);"
- "ushort d2fus = ushort(d);"
"uint s2ui = uint(s);"
"uint i2ui = uint(i);"
"uint us2ui = us;"
"uint ui2ui = ui;"
"uint h2ui = uint(h);"
"uint f2ui = uint(f);"
- "uint d2fui = uint(d);"
- "float s2f = s;"
- "float i2f = i;"
- "float us2f = us;"
- "float ui2f = ui;"
- "float h2f = h;"
- "float f2f = f;"
- "float d2f = d;"
- "double s2d = s;"
- "double i2d = i;"
- "double us2d = us;"
- "double ui2d = ui;"
- "double h2d = h;"
- "double f2d = f;"
- "double d2d = d;",
+ "highfloat s2f = s;"
+ "highfloat i2f = i;"
+ "highfloat us2f = us;"
+ "highfloat ui2f = ui;"
+ "highfloat h2f = h;"
+ "highfloat f2f = f;",
*SkSL::ShaderCapsFactory::Default(),
"#version 400\n"
"out vec4 sk_FragColor;\n"
@@ -1558,49 +1541,36 @@ DEF_TEST(SkSLNumberConversions, r) {
"uint ui = uint(sqrt(1.0));\n"
"float h = sqrt(1.0);\n"
"float f = sqrt(1.0);\n"
- "double d = sqrt(1.0);\n"
"int s2s = s;\n"
"int i2s = i;\n"
"int us2s = int(us);\n"
"int ui2s = int(ui);\n"
"int h2s = int(h);\n"
"int f2s = int(f);\n"
- "int d2fs = int(d);\n"
"int s2i = s;\n"
"int i2i = i;\n"
"int us2i = int(us);\n"
"int ui2i = int(ui);\n"
"int h2i = int(h);\n"
"int f2i = int(f);\n"
- "int d2fi = int(d);\n"
"uint s2us = uint(s);\n"
"uint i2us = uint(i);\n"
"uint us2us = us;\n"
"uint ui2us = ui;\n"
"uint h2us = uint(h);\n"
"uint f2us = uint(f);\n"
- "uint d2fus = uint(d);\n"
"uint s2ui = uint(s);\n"
"uint i2ui = uint(i);\n"
"uint us2ui = us;\n"
"uint ui2ui = ui;\n"
"uint h2ui = uint(h);\n"
"uint f2ui = uint(f);\n"
- "uint d2fui = uint(d);\n"
"float s2f = float(s);\n"
"float i2f = float(i);\n"
"float us2f = float(us);\n"
"float ui2f = float(ui);\n"
"float h2f = h;\n"
- "float f2f = f;\n"
- "float d2f = d;\n"
- "double s2d = double(s);\n"
- "double i2d = double(i);\n"
- "double us2d = double(us);\n"
- "double ui2d = double(ui);\n"
- "double h2d = h;\n"
- "double f2d = f;\n"
- "double d2d = d;\n");
+ "float f2f = f;\n");
}
#endif