Commit 57442b11 by zmo@google.com

Update emulated functions.

It turns out there are bugs in our tests, so kbr fixed them a while ago. Now we had another look at the tests, and it turned out some functions we don't have emulate, and some functions we need to also emulate in fragment shaders. BUG= TEST= R=kbr Review URL: https://codereview.appspot.com/6011056 git-svn-id: https://angleproject.googlecode.com/svn/trunk@1034 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 14e966b2
#define MAJOR_VERSION 1 #define MAJOR_VERSION 1
#define MINOR_VERSION 0 #define MINOR_VERSION 0
#define BUILD_VERSION 0 #define BUILD_VERSION 0
#define BUILD_REVISION 1033 #define BUILD_REVISION 1034
#define STRINGIFY(x) #x #define STRINGIFY(x) #x
#define MACRO_STRINGIFY(x) STRINGIFY(x) #define MACRO_STRINGIFY(x) STRINGIFY(x)
......
...@@ -16,11 +16,6 @@ namespace { ...@@ -16,11 +16,6 @@ namespace {
// evaluated. This is unlikely to show up in real shaders, but is something to // evaluated. This is unlikely to show up in real shaders, but is something to
// consider. // consider.
const char* kFunctionEmulationVertexSource[] = { const char* kFunctionEmulationVertexSource[] = {
"#error no emulation for atan(float, float)",
"vec2 webgl_atan_emu(vec2 y, vec2 x) { return vec2(atan(y[0], x[0]), atan(y[1], x[1])); }",
"vec3 webgl_atan_emu(vec3 y, vec3 x) { return vec3(atan(y[0], x[0]), atan(y[1], x[1]), atan(y[2], x[2])); }",
"vec4 webgl_atan_emu(vec4 y, vec4 x) { return vec4(atan(y[0], x[0]), atan(y[1], x[1]), atan(y[2], x[2]), atan(y[3], x[3])); }",
"#error no emulation for cos(float)", "#error no emulation for cos(float)",
"#error no emulation for cos(vec2)", "#error no emulation for cos(vec2)",
"#error no emulation for cos(vec3)", "#error no emulation for cos(vec3)",
...@@ -41,11 +36,6 @@ const char* kFunctionEmulationVertexSource[] = { ...@@ -41,11 +36,6 @@ const char* kFunctionEmulationVertexSource[] = {
"#error no emulation for length(vec3)", "#error no emulation for length(vec3)",
"#error no emulation for length(vec4)", "#error no emulation for length(vec4)",
"#error no emulation for mod(float, float)",
"vec2 webgl_mod_emu(vec2 x, vec2 y) { return vec2(mod(x[0], y[0]), mod(x[1], y[1])); }",
"vec3 webgl_mod_emu(vec3 x, vec3 y) { return vec3(mod(x[0], y[0]), mod(x[1], y[1]), mod(x[2], y[2])); }",
"vec4 webgl_mod_emu(vec4 x, vec4 y) { return vec4(mod(x[0], y[0]), mod(x[1], y[1]), mod(x[2], y[2]), mod(x[3], y[3])); }",
"#define webgl_normalize_emu(x) ((x) == 0.0 ? 0.0 : ((x) > 0.0 ? 1.0 : -1.0))", "#define webgl_normalize_emu(x) ((x) == 0.0 ? 0.0 : ((x) > 0.0 ? 1.0 : -1.0))",
"#error no emulation for normalize(vec2)", "#error no emulation for normalize(vec2)",
"#error no emulation for normalize(vec3)", "#error no emulation for normalize(vec3)",
...@@ -58,42 +48,32 @@ const char* kFunctionEmulationVertexSource[] = { ...@@ -58,42 +48,32 @@ const char* kFunctionEmulationVertexSource[] = {
}; };
const char* kFunctionEmulationFragmentSource[] = { const char* kFunctionEmulationFragmentSource[] = {
"#error no emulation for atan(float, float)",
"#error no emulation for atan(vec2, vec2)",
"#error no emulation for atan(vec3, vec3)",
"#error no emulation for atan(vec4, vec4)",
"webgl_emu_precision float webgl_cos_emu(webgl_emu_precision float a) { return cos(a); }", "webgl_emu_precision float webgl_cos_emu(webgl_emu_precision float a) { return cos(a); }",
"webgl_emu_precision vec2 webgl_cos_emu(webgl_emu_precision vec2 a) { return cos(a); }", "webgl_emu_precision vec2 webgl_cos_emu(webgl_emu_precision vec2 a) { return cos(a); }",
"webgl_emu_precision vec3 webgl_cos_emu(webgl_emu_precision vec3 a) { return cos(a); }", "webgl_emu_precision vec3 webgl_cos_emu(webgl_emu_precision vec3 a) { return cos(a); }",
"webgl_emu_precision vec4 webgl_cos_emu(webgl_emu_precision vec4 a) { return cos(a); }", "webgl_emu_precision vec4 webgl_cos_emu(webgl_emu_precision vec4 a) { return cos(a); }",
"#error no emulation for distance(float, float)", "#define webgl_distance_emu(x, y) ((x) >= (y) ? (x) - (y) : (y) - (x))",
"#error no emulation for distance(vec2, vec2)", "#error no emulation for distance(vec2, vec2)",
"#error no emulation for distance(vec3, vec3)", "#error no emulation for distance(vec3, vec3)",
"#error no emulation for distance(vec4, vec4)", "#error no emulation for distance(vec4, vec4)",
"#error no emulation for dot(float, float)", "#define webgl_dot_emu(x, y) ((x) * (y))",
"#error no emulation for dot(vec2, vec2)", "#error no emulation for dot(vec2, vec2)",
"#error no emulation for dot(vec3, vec3)", "#error no emulation for dot(vec3, vec3)",
"#error no emulation for dot(vec4, vec4)", "#error no emulation for dot(vec4, vec4)",
"#error no emulation for length(float)", "#define webgl_length_emu(x) ((x) >= 0.0 ? (x) : -(x))",
"#error no emulation for length(vec2)", "#error no emulation for length(vec2)",
"#error no emulation for length(vec3)", "#error no emulation for length(vec3)",
"#error no emulation for length(vec4)", "#error no emulation for length(vec4)",
"#error no emulation for mod(float, float)", "#define webgl_normalize_emu(x) ((x) == 0.0 ? 0.0 : ((x) > 0.0 ? 1.0 : -1.0))",
"#error no emulation for mod(vec2, vec2)",
"#error no emulation for mod(vec3, vec3)",
"#error no emulation for mod(vec4, vec4)",
"#error no emulation for normalize(float)",
"#error no emulation for normalize(vec2)", "#error no emulation for normalize(vec2)",
"#error no emulation for normalize(vec3)", "#error no emulation for normalize(vec3)",
"#error no emulation for normalize(vec4)", "#error no emulation for normalize(vec4)",
"#error no emulation for reflect(float, float)", "#define webgl_reflect_emu(I, N) ((I) - 2.0 * (N) * (I) * (N))",
"#error no emulation for reflect(vec2, vec2)", "#error no emulation for reflect(vec2, vec2)",
"#error no emulation for reflect(vec3, vec3)", "#error no emulation for reflect(vec3, vec3)",
"#error no emulation for reflect(vec4, vec4)" "#error no emulation for reflect(vec4, vec4)"
...@@ -102,10 +82,6 @@ const char* kFunctionEmulationFragmentSource[] = { ...@@ -102,10 +82,6 @@ const char* kFunctionEmulationFragmentSource[] = {
const bool kFunctionEmulationVertexMask[] = { const bool kFunctionEmulationVertexMask[] = {
#if defined(__APPLE__) #if defined(__APPLE__)
// Work around ATI driver bugs in Mac. // Work around ATI driver bugs in Mac.
false, // TFunctionAtan1_1
false, // TFunctionAtan2_2
false, // TFunctionAtan3_3
false, // TFunctionAtan4_4
false, // TFunctionCos1 false, // TFunctionCos1
false, // TFunctionCos2 false, // TFunctionCos2
false, // TFunctionCos3 false, // TFunctionCos3
...@@ -122,10 +98,6 @@ const bool kFunctionEmulationVertexMask[] = { ...@@ -122,10 +98,6 @@ const bool kFunctionEmulationVertexMask[] = {
false, // TFunctionLength2 false, // TFunctionLength2
false, // TFunctionLength3 false, // TFunctionLength3
false, // TFunctionLength4 false, // TFunctionLength4
false, // TFunctionMod1_1
false, // TFunctionMod2_2
false, // TFunctionMod3_3
false, // TFunctionMod4_4
true, // TFunctionNormalize1 true, // TFunctionNormalize1
false, // TFunctionNormalize2 false, // TFunctionNormalize2
false, // TFunctionNormalize3 false, // TFunctionNormalize3
...@@ -136,10 +108,6 @@ const bool kFunctionEmulationVertexMask[] = { ...@@ -136,10 +108,6 @@ const bool kFunctionEmulationVertexMask[] = {
false, // TFunctionReflect4_4 false, // TFunctionReflect4_4
#else #else
// Work around D3D driver bug in Win. // Work around D3D driver bug in Win.
false, // TFunctionAtan1_1
true, // TFunctionAtan2_2
true, // TFunctionAtan3_3
true, // TFunctionAtan4_4
false, // TFunctionCos1 false, // TFunctionCos1
false, // TFunctionCos2 false, // TFunctionCos2
false, // TFunctionCos3 false, // TFunctionCos3
...@@ -156,10 +124,6 @@ const bool kFunctionEmulationVertexMask[] = { ...@@ -156,10 +124,6 @@ const bool kFunctionEmulationVertexMask[] = {
false, // TFunctionLength2 false, // TFunctionLength2
false, // TFunctionLength3 false, // TFunctionLength3
false, // TFunctionLength4 false, // TFunctionLength4
false, // TFunctionMod1_1
true, // TFunctionMod2_2
true, // TFunctionMod3_3
true, // TFunctionMod4_4
false, // TFunctionNormalize1 false, // TFunctionNormalize1
false, // TFunctionNormalize2 false, // TFunctionNormalize2
false, // TFunctionNormalize3 false, // TFunctionNormalize3
...@@ -173,22 +137,38 @@ const bool kFunctionEmulationVertexMask[] = { ...@@ -173,22 +137,38 @@ const bool kFunctionEmulationVertexMask[] = {
}; };
const bool kFunctionEmulationFragmentMask[] = { const bool kFunctionEmulationFragmentMask[] = {
false, // TFunctionAtan1_1
false, // TFunctionAtan2_2
false, // TFunctionAtan3_3
false, // TFunctionAtan4_4
#if defined(__APPLE__) #if defined(__APPLE__)
// Work around a ATI driver bug in Mac that causes crashes. // Work around ATI driver bugs in Mac.
true, // TFunctionCos1 true, // TFunctionCos1
true, // TFunctionCos2 true, // TFunctionCos2
true, // TFunctionCos3 true, // TFunctionCos3
true, // TFunctionCos4 true, // TFunctionCos4
true, // TFunctionDistance1_1
false, // TFunctionDistance2_2
false, // TFunctionDistance3_3
false, // TFunctionDistance4_4
true, // TFunctionDot1_1
false, // TFunctionDot2_2
false, // TFunctionDot3_3
false, // TFunctionDot4_4
true, // TFunctionLength1
false, // TFunctionLength2
false, // TFunctionLength3
false, // TFunctionLength4
true, // TFunctionNormalize1
false, // TFunctionNormalize2
false, // TFunctionNormalize3
false, // TFunctionNormalize4
true, // TFunctionReflect1_1
false, // TFunctionReflect2_2
false, // TFunctionReflect3_3
false, // TFunctionReflect4_4
#else #else
// Work around D3D driver bug in Win.
false, // TFunctionCos1 false, // TFunctionCos1
false, // TFunctionCos2 false, // TFunctionCos2
false, // TFunctionCos3 false, // TFunctionCos3
false, // TFunctionCos4 false, // TFunctionCos4
#endif
false, // TFunctionDistance1_1 false, // TFunctionDistance1_1
false, // TFunctionDistance2_2 false, // TFunctionDistance2_2
false, // TFunctionDistance3_3 false, // TFunctionDistance3_3
...@@ -201,10 +181,6 @@ const bool kFunctionEmulationFragmentMask[] = { ...@@ -201,10 +181,6 @@ const bool kFunctionEmulationFragmentMask[] = {
false, // TFunctionLength2 false, // TFunctionLength2
false, // TFunctionLength3 false, // TFunctionLength3
false, // TFunctionLength4 false, // TFunctionLength4
false, // TFunctionMod1_1
false, // TFunctionMod2_2
false, // TFunctionMod3_3
false, // TFunctionMod4_4
false, // TFunctionNormalize1 false, // TFunctionNormalize1
false, // TFunctionNormalize2 false, // TFunctionNormalize2
false, // TFunctionNormalize3 false, // TFunctionNormalize3
...@@ -213,6 +189,7 @@ const bool kFunctionEmulationFragmentMask[] = { ...@@ -213,6 +189,7 @@ const bool kFunctionEmulationFragmentMask[] = {
false, // TFunctionReflect2_2 false, // TFunctionReflect2_2
false, // TFunctionReflect3_3 false, // TFunctionReflect3_3
false, // TFunctionReflect4_4 false, // TFunctionReflect4_4
#endif
false // TFunctionUnknown false // TFunctionUnknown
}; };
...@@ -386,18 +363,12 @@ BuiltInFunctionEmulator::IdentifyFunction( ...@@ -386,18 +363,12 @@ BuiltInFunctionEmulator::IdentifyFunction(
unsigned int function = TFunctionUnknown; unsigned int function = TFunctionUnknown;
switch (op) { switch (op) {
case EOpAtan:
function = TFunctionAtan1_1;
break;
case EOpDistance: case EOpDistance:
function = TFunctionDistance1_1; function = TFunctionDistance1_1;
break; break;
case EOpDot: case EOpDot:
function = TFunctionDot1_1; function = TFunctionDot1_1;
break; break;
case EOpMod:
function = TFunctionMod1_1;
break;
case EOpReflect: case EOpReflect:
function = TFunctionReflect1_1; function = TFunctionReflect1_1;
break; break;
......
...@@ -45,12 +45,7 @@ private: ...@@ -45,12 +45,7 @@ private:
// Built-in functions. // Built-in functions.
// //
enum TBuiltInFunction { enum TBuiltInFunction {
TFunctionAtan1_1 = 0, // float atan(float, float); TFunctionCos1 = 0, // float cos(float);
TFunctionAtan2_2, // vec2 atan(vec2, vec2);
TFunctionAtan3_3, // vec3 atan(vec3, vec2);
TFunctionAtan4_4, // vec4 atan(vec4, vec2);
TFunctionCos1, // float cos(float);
TFunctionCos2, // vec2 cos(vec2); TFunctionCos2, // vec2 cos(vec2);
TFunctionCos3, // vec3 cos(vec3); TFunctionCos3, // vec3 cos(vec3);
TFunctionCos4, // vec4 cos(vec4); TFunctionCos4, // vec4 cos(vec4);
...@@ -70,11 +65,6 @@ private: ...@@ -70,11 +65,6 @@ private:
TFunctionLength3, // float length(vec3); TFunctionLength3, // float length(vec3);
TFunctionLength4, // float length(vec4); TFunctionLength4, // float length(vec4);
TFunctionMod1_1, // float mod(float, float);
TFunctionMod2_2, // vec2 mod(vec2, vec2);
TFunctionMod3_3, // vec3 mod(vec3, vec3);
TFunctionMod4_4, // vec4 mod(vec4, vec4);
TFunctionNormalize1, // float normalize(float); TFunctionNormalize1, // float normalize(float);
TFunctionNormalize2, // vec2 normalize(vec2); TFunctionNormalize2, // vec2 normalize(vec2);
TFunctionNormalize3, // vec3 normalize(vec3); TFunctionNormalize3, // vec3 normalize(vec3);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment