Commit c634a637 by Olli Etuaho Committed by Commit Bot

Remove webgl_ prefix from emulated function names

The prefix is unnecessary now that user-defined names are prefixed in both GLSL and HLSL output. Removing the prefix makes compiler output a bit simpler to read. BUG=angleproject:2038 TEST=angle_unittests Change-Id: I9ffc508f50d6146a2d85798875c88e2c385b83fe Reviewed-on: https://chromium-review.googlesource.com/508730Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
parent af11b53a
...@@ -45,7 +45,7 @@ class BuiltInFunctionEmulator::BuiltInFunctionEmulationMarker : public TIntermTr ...@@ -45,7 +45,7 @@ class BuiltInFunctionEmulator::BuiltInFunctionEmulationMarker : public TIntermTr
} }
const TIntermSequence &sequence = *(node->getSequence()); const TIntermSequence &sequence = *(node->getSequence());
bool needToEmulate = false; bool needToEmulate = false;
// Right now we only handle built-in functions with two or three parameters. // Right now we only handle built-in functions with two to four parameters.
if (sequence.size() == 2) if (sequence.size() == 2)
{ {
TIntermTyped *param1 = sequence[0]->getAsTyped(); TIntermTyped *param1 = sequence[0]->getAsTyped();
...@@ -281,7 +281,7 @@ void BuiltInFunctionEmulator::addFunctionMap(BuiltinQueryFunc queryFunc) ...@@ -281,7 +281,7 @@ void BuiltInFunctionEmulator::addFunctionMap(BuiltinQueryFunc queryFunc)
void BuiltInFunctionEmulator::WriteEmulatedFunctionName(TInfoSinkBase &out, const char *name) void BuiltInFunctionEmulator::WriteEmulatedFunctionName(TInfoSinkBase &out, const char *name)
{ {
ASSERT(name[strlen(name) - 1] != '('); ASSERT(name[strlen(name) - 1] != '(');
out << "webgl_" << name << "_emu"; out << name << "_emu";
} }
FunctionId::FunctionId() FunctionId::FunctionId()
......
...@@ -99,7 +99,7 @@ class BuiltInFunctionEmulator ...@@ -99,7 +99,7 @@ class BuiltInFunctionEmulator
void cleanup(); void cleanup();
// "name" gets written as "webgl_name_emu". // "name" gets written as "name_emu".
static void WriteEmulatedFunctionName(TInfoSinkBase &out, const char *name); static void WriteEmulatedFunctionName(TInfoSinkBase &out, const char *name);
bool isOutputEmpty() const; bool isOutputEmpty() const;
......
...@@ -20,7 +20,7 @@ void InitBuiltInAbsFunctionEmulatorForGLSLWorkarounds(BuiltInFunctionEmulator *e ...@@ -20,7 +20,7 @@ void InitBuiltInAbsFunctionEmulatorForGLSLWorkarounds(BuiltInFunctionEmulator *e
if (shaderType == GL_VERTEX_SHADER) if (shaderType == GL_VERTEX_SHADER)
{ {
const TType *int1 = TCache::getType(EbtInt); const TType *int1 = TCache::getType(EbtInt);
emu->addEmulatedFunction(EOpAbs, int1, "int webgl_abs_emu(int x) { return x * sign(x); }"); emu->addEmulatedFunction(EOpAbs, int1, "int abs_emu(int x) { return x * sign(x); }");
} }
} }
...@@ -39,10 +39,10 @@ void InitBuiltInIsnanFunctionEmulatorForGLSLWorkarounds(BuiltInFunctionEmulator ...@@ -39,10 +39,10 @@ void InitBuiltInIsnanFunctionEmulatorForGLSLWorkarounds(BuiltInFunctionEmulator
// !(x > 0.0 || x < 0.0 || x == 0.0) will be optimized and always equal to false. // !(x > 0.0 || x < 0.0 || x == 0.0) will be optimized and always equal to false.
emu->addEmulatedFunction( emu->addEmulatedFunction(
EOpIsNan, float1, EOpIsNan, float1,
"bool webgl_isnan_emu(float x) { return (x > 0.0 || x < 0.0) ? false : x != 0.0; }"); "bool isnan_emu(float x) { return (x > 0.0 || x < 0.0) ? false : x != 0.0; }");
emu->addEmulatedFunction( emu->addEmulatedFunction(
EOpIsNan, float2, EOpIsNan, float2,
"bvec2 webgl_isnan_emu(vec2 x)\n" "bvec2 isnan_emu(vec2 x)\n"
"{\n" "{\n"
" bvec2 isnan;\n" " bvec2 isnan;\n"
" for (int i = 0; i < 2; i++)\n" " for (int i = 0; i < 2; i++)\n"
...@@ -53,7 +53,7 @@ void InitBuiltInIsnanFunctionEmulatorForGLSLWorkarounds(BuiltInFunctionEmulator ...@@ -53,7 +53,7 @@ void InitBuiltInIsnanFunctionEmulatorForGLSLWorkarounds(BuiltInFunctionEmulator
"}\n"); "}\n");
emu->addEmulatedFunction( emu->addEmulatedFunction(
EOpIsNan, float3, EOpIsNan, float3,
"bvec3 webgl_isnan_emu(vec3 x)\n" "bvec3 isnan_emu(vec3 x)\n"
"{\n" "{\n"
" bvec3 isnan;\n" " bvec3 isnan;\n"
" for (int i = 0; i < 3; i++)\n" " for (int i = 0; i < 3; i++)\n"
...@@ -64,7 +64,7 @@ void InitBuiltInIsnanFunctionEmulatorForGLSLWorkarounds(BuiltInFunctionEmulator ...@@ -64,7 +64,7 @@ void InitBuiltInIsnanFunctionEmulatorForGLSLWorkarounds(BuiltInFunctionEmulator
"}\n"); "}\n");
emu->addEmulatedFunction( emu->addEmulatedFunction(
EOpIsNan, float4, EOpIsNan, float4,
"bvec4 webgl_isnan_emu(vec4 x)\n" "bvec4 isnan_emu(vec4 x)\n"
"{\n" "{\n"
" bvec4 isnan;\n" " bvec4 isnan;\n"
" for (int i = 0; i < 4; i++)\n" " for (int i = 0; i < 4; i++)\n"
...@@ -80,7 +80,7 @@ void InitBuiltInAtanFunctionEmulatorForGLSLWorkarounds(BuiltInFunctionEmulator * ...@@ -80,7 +80,7 @@ void InitBuiltInAtanFunctionEmulatorForGLSLWorkarounds(BuiltInFunctionEmulator *
const TType *float1 = TCache::getType(EbtFloat); const TType *float1 = TCache::getType(EbtFloat);
auto floatFuncId = emu->addEmulatedFunction( auto floatFuncId = emu->addEmulatedFunction(
EOpAtan, float1, float1, EOpAtan, float1, float1,
"webgl_emu_precision float webgl_atan_emu(webgl_emu_precision float y, webgl_emu_precision " "emu_precision float atan_emu(emu_precision float y, emu_precision "
"float x)\n" "float x)\n"
"{\n" "{\n"
" if (x > 0.0) return atan(y / x);\n" " if (x > 0.0) return atan(y / x);\n"
...@@ -92,14 +92,14 @@ void InitBuiltInAtanFunctionEmulatorForGLSLWorkarounds(BuiltInFunctionEmulator * ...@@ -92,14 +92,14 @@ void InitBuiltInAtanFunctionEmulatorForGLSLWorkarounds(BuiltInFunctionEmulator *
{ {
const TType *floatVec = TCache::getType(EbtFloat, static_cast<unsigned char>(dim)); const TType *floatVec = TCache::getType(EbtFloat, static_cast<unsigned char>(dim));
std::stringstream ss; std::stringstream ss;
ss << "webgl_emu_precision vec" << dim << " webgl_atan_emu(webgl_emu_precision vec" << dim ss << "emu_precision vec" << dim << " atan_emu(emu_precision vec" << dim
<< " y, webgl_emu_precision vec" << dim << " x)\n" << " y, emu_precision vec" << dim << " x)\n"
"{\n" << "{\n"
" return vec" " return vec"
<< dim << "("; << dim << "(";
for (int i = 0; i < dim; ++i) for (int i = 0; i < dim; ++i)
{ {
ss << "webgl_atan_emu(y[" << i << "], x[" << i << "])"; ss << "atan_emu(y[" << i << "], x[" << i << "])";
if (i < dim - 1) if (i < dim - 1)
{ {
ss << ", "; ss << ", ";
...@@ -125,7 +125,7 @@ void InitBuiltInFunctionEmulatorForGLSLMissingFunctions(BuiltInFunctionEmulator ...@@ -125,7 +125,7 @@ void InitBuiltInFunctionEmulatorForGLSLMissingFunctions(BuiltInFunctionEmulator
// clang-format off // clang-format off
emu->addEmulatedFunction(EOpPackUnorm2x16, float2, emu->addEmulatedFunction(EOpPackUnorm2x16, float2,
"uint webgl_packUnorm2x16_emu(vec2 v)\n" "uint packUnorm2x16_emu(vec2 v)\n"
"{\n" "{\n"
" int x = int(round(clamp(v.x, 0.0, 1.0) * 65535.0));\n" " int x = int(round(clamp(v.x, 0.0, 1.0) * 65535.0));\n"
" int y = int(round(clamp(v.y, 0.0, 1.0) * 65535.0));\n" " int y = int(round(clamp(v.y, 0.0, 1.0) * 65535.0));\n"
...@@ -133,7 +133,7 @@ void InitBuiltInFunctionEmulatorForGLSLMissingFunctions(BuiltInFunctionEmulator ...@@ -133,7 +133,7 @@ void InitBuiltInFunctionEmulatorForGLSLMissingFunctions(BuiltInFunctionEmulator
"}\n"); "}\n");
emu->addEmulatedFunction(EOpUnpackUnorm2x16, uint1, emu->addEmulatedFunction(EOpUnpackUnorm2x16, uint1,
"vec2 webgl_unpackUnorm2x16_emu(uint u)\n" "vec2 unpackUnorm2x16_emu(uint u)\n"
"{\n" "{\n"
" float x = float(u & 0xFFFFu) / 65535.0;\n" " float x = float(u & 0xFFFFu) / 65535.0;\n"
" float y = float(u >> 16) / 65535.0;\n" " float y = float(u >> 16) / 65535.0;\n"
...@@ -151,7 +151,7 @@ void InitBuiltInFunctionEmulatorForGLSLMissingFunctions(BuiltInFunctionEmulator ...@@ -151,7 +151,7 @@ void InitBuiltInFunctionEmulatorForGLSLMissingFunctions(BuiltInFunctionEmulator
// clang-format off // clang-format off
emu->addEmulatedFunction(EOpPackSnorm2x16, float2, emu->addEmulatedFunction(EOpPackSnorm2x16, float2,
"uint webgl_packSnorm2x16_emu(vec2 v)\n" "uint packSnorm2x16_emu(vec2 v)\n"
"{\n" "{\n"
" #if defined(GL_ARB_shading_language_packing)\n" " #if defined(GL_ARB_shading_language_packing)\n"
" return packSnorm2x16(v);\n" " return packSnorm2x16(v);\n"
...@@ -163,28 +163,28 @@ void InitBuiltInFunctionEmulatorForGLSLMissingFunctions(BuiltInFunctionEmulator ...@@ -163,28 +163,28 @@ void InitBuiltInFunctionEmulatorForGLSLMissingFunctions(BuiltInFunctionEmulator
"}\n"); "}\n");
emu->addEmulatedFunction(EOpUnpackSnorm2x16, uint1, emu->addEmulatedFunction(EOpUnpackSnorm2x16, uint1,
"#if !defined(GL_ARB_shading_language_packing)\n" "#if !defined(GL_ARB_shading_language_packing)\n"
" float webgl_fromSnorm(uint x)\n" " float fromSnorm(uint x)\n"
" {\n" " {\n"
" int xi = (int(x) & 0x7FFF) - (int(x) & 0x8000);\n" " int xi = (int(x) & 0x7FFF) - (int(x) & 0x8000);\n"
" return clamp(float(xi) / 32767.0, -1.0, 1.0);\n" " return clamp(float(xi) / 32767.0, -1.0, 1.0);\n"
" }\n" " }\n"
"#endif\n" "#endif\n"
"\n" "\n"
"vec2 webgl_unpackSnorm2x16_emu(uint u)\n" "vec2 unpackSnorm2x16_emu(uint u)\n"
"{\n" "{\n"
" #if defined(GL_ARB_shading_language_packing)\n" " #if defined(GL_ARB_shading_language_packing)\n"
" return unpackSnorm2x16(u);\n" " return unpackSnorm2x16(u);\n"
" #else\n" " #else\n"
" uint y = (u >> 16);\n" " uint y = (u >> 16);\n"
" uint x = u;\n" " uint x = u;\n"
" return vec2(webgl_fromSnorm(x), webgl_fromSnorm(y));\n" " return vec2(fromSnorm(x), fromSnorm(y));\n"
" #endif\n" " #endif\n"
"}\n"); "}\n");
// Functions uint webgl_f32tof16(float val) and float webgl_f16tof32(uint val) are // Functions uint f32tof16(float val) and float f16tof32(uint val) are
// based on the OpenGL redbook Appendix Session "Floating-Point Formats Used in OpenGL". // based on the OpenGL redbook Appendix Session "Floating-Point Formats Used in OpenGL".
emu->addEmulatedFunction(EOpPackHalf2x16, float2, emu->addEmulatedFunction(EOpPackHalf2x16, float2,
"#if !defined(GL_ARB_shading_language_packing)\n" "#if !defined(GL_ARB_shading_language_packing)\n"
" uint webgl_f32tof16(float val)\n" " uint f32tof16(float val)\n"
" {\n" " {\n"
" uint f32 = floatBitsToUint(val);\n" " uint f32 = floatBitsToUint(val);\n"
" uint f16 = 0u;\n" " uint f16 = 0u;\n"
...@@ -219,19 +219,19 @@ void InitBuiltInFunctionEmulatorForGLSLMissingFunctions(BuiltInFunctionEmulator ...@@ -219,19 +219,19 @@ void InitBuiltInFunctionEmulatorForGLSLMissingFunctions(BuiltInFunctionEmulator
" }\n" " }\n"
"#endif\n" "#endif\n"
"\n" "\n"
"uint webgl_packHalf2x16_emu(vec2 v)\n" "uint packHalf2x16_emu(vec2 v)\n"
"{\n" "{\n"
" #if defined(GL_ARB_shading_language_packing)\n" " #if defined(GL_ARB_shading_language_packing)\n"
" return packHalf2x16(v);\n" " return packHalf2x16(v);\n"
" #else\n" " #else\n"
" uint x = webgl_f32tof16(v.x);\n" " uint x = f32tof16(v.x);\n"
" uint y = webgl_f32tof16(v.y);\n" " uint y = f32tof16(v.y);\n"
" return (y << 16) | x;\n" " return (y << 16) | x;\n"
" #endif\n" " #endif\n"
"}\n"); "}\n");
emu->addEmulatedFunction(EOpUnpackHalf2x16, uint1, emu->addEmulatedFunction(EOpUnpackHalf2x16, uint1,
"#if !defined(GL_ARB_shading_language_packing)\n" "#if !defined(GL_ARB_shading_language_packing)\n"
" float webgl_f16tof32(uint val)\n" " float f16tof32(uint val)\n"
" {\n" " {\n"
" uint sign = (val & 0x8000u) << 16;\n" " uint sign = (val & 0x8000u) << 16;\n"
" int exponent = int((val & 0x7C00u) >> 10);\n" " int exponent = int((val & 0x7C00u) >> 10);\n"
...@@ -276,14 +276,14 @@ void InitBuiltInFunctionEmulatorForGLSLMissingFunctions(BuiltInFunctionEmulator ...@@ -276,14 +276,14 @@ void InitBuiltInFunctionEmulatorForGLSLMissingFunctions(BuiltInFunctionEmulator
" }\n" " }\n"
"#endif\n" "#endif\n"
"\n" "\n"
"vec2 webgl_unpackHalf2x16_emu(uint u)\n" "vec2 unpackHalf2x16_emu(uint u)\n"
"{\n" "{\n"
" #if defined(GL_ARB_shading_language_packing)\n" " #if defined(GL_ARB_shading_language_packing)\n"
" return unpackHalf2x16(u);\n" " return unpackHalf2x16(u);\n"
" #else\n" " #else\n"
" uint y = (u >> 16);\n" " uint y = (u >> 16);\n"
" uint x = u & 0xFFFFu;\n" " uint x = u & 0xFFFFu;\n"
" return vec2(webgl_f16tof32(x), webgl_f16tof32(y));\n" " return vec2(f16tof32(x), f16tof32(y));\n"
" #endif\n" " #endif\n"
"}\n"); "}\n");
// clang-format on // clang-format on
......
...@@ -28,7 +28,7 @@ void InitBuiltInIsnanFunctionEmulatorForHLSLWorkarounds(BuiltInFunctionEmulator ...@@ -28,7 +28,7 @@ void InitBuiltInIsnanFunctionEmulatorForHLSLWorkarounds(BuiltInFunctionEmulator
TType *float4 = new TType(EbtFloat, 4); TType *float4 = new TType(EbtFloat, 4);
emu->addEmulatedFunction(EOpIsNan, float1, emu->addEmulatedFunction(EOpIsNan, float1,
"bool webgl_isnan_emu(float x)\n" "bool isnan_emu(float x)\n"
"{\n" "{\n"
" return (x > 0.0 || x < 0.0) ? false : x != 0.0;\n" " return (x > 0.0 || x < 0.0) ? false : x != 0.0;\n"
"}\n" "}\n"
...@@ -36,7 +36,7 @@ void InitBuiltInIsnanFunctionEmulatorForHLSLWorkarounds(BuiltInFunctionEmulator ...@@ -36,7 +36,7 @@ void InitBuiltInIsnanFunctionEmulatorForHLSLWorkarounds(BuiltInFunctionEmulator
emu->addEmulatedFunction( emu->addEmulatedFunction(
EOpIsNan, float2, EOpIsNan, float2,
"bool2 webgl_isnan_emu(float2 x)\n" "bool2 isnan_emu(float2 x)\n"
"{\n" "{\n"
" bool2 isnan;\n" " bool2 isnan;\n"
" for (int i = 0; i < 2; i++)\n" " for (int i = 0; i < 2; i++)\n"
...@@ -48,7 +48,7 @@ void InitBuiltInIsnanFunctionEmulatorForHLSLWorkarounds(BuiltInFunctionEmulator ...@@ -48,7 +48,7 @@ void InitBuiltInIsnanFunctionEmulatorForHLSLWorkarounds(BuiltInFunctionEmulator
emu->addEmulatedFunction( emu->addEmulatedFunction(
EOpIsNan, float3, EOpIsNan, float3,
"bool3 webgl_isnan_emu(float3 x)\n" "bool3 isnan_emu(float3 x)\n"
"{\n" "{\n"
" bool3 isnan;\n" " bool3 isnan;\n"
" for (int i = 0; i < 3; i++)\n" " for (int i = 0; i < 3; i++)\n"
...@@ -60,7 +60,7 @@ void InitBuiltInIsnanFunctionEmulatorForHLSLWorkarounds(BuiltInFunctionEmulator ...@@ -60,7 +60,7 @@ void InitBuiltInIsnanFunctionEmulatorForHLSLWorkarounds(BuiltInFunctionEmulator
emu->addEmulatedFunction( emu->addEmulatedFunction(
EOpIsNan, float4, EOpIsNan, float4,
"bool4 webgl_isnan_emu(float4 x)\n" "bool4 isnan_emu(float4 x)\n"
"{\n" "{\n"
" bool4 isnan;\n" " bool4 isnan;\n"
" for (int i = 0; i < 4; i++)\n" " for (int i = 0; i < 4; i++)\n"
...@@ -89,7 +89,7 @@ void InitBuiltInFunctionEmulatorForHLSL(BuiltInFunctionEmulator *emu) ...@@ -89,7 +89,7 @@ void InitBuiltInFunctionEmulatorForHLSL(BuiltInFunctionEmulator *emu)
// a <= 0xffff, d <= 0xffff, ((a * c) >> 16) <= 0xffff and 0xffff * 0xffff + 0xffff = 0xffff0000 // a <= 0xffff, d <= 0xffff, ((a * c) >> 16) <= 0xffff and 0xffff * 0xffff + 0xffff = 0xffff0000
FunctionId umulExtendedUint1 = emu->addEmulatedFunction( FunctionId umulExtendedUint1 = emu->addEmulatedFunction(
EOpUmulExtended, uint1, uint1, uint1, uint1, EOpUmulExtended, uint1, uint1, uint1, uint1,
"void webgl_umulExtended_emu(uint x, uint y, out uint msb, out uint lsb)\n" "void umulExtended_emu(uint x, uint y, out uint msb, out uint lsb)\n"
"{\n" "{\n"
" lsb = x * y;\n" " lsb = x * y;\n"
" uint a = (x & 0xffffu);\n" " uint a = (x & 0xffffu);\n"
...@@ -103,27 +103,27 @@ void InitBuiltInFunctionEmulatorForHLSL(BuiltInFunctionEmulator *emu) ...@@ -103,27 +103,27 @@ void InitBuiltInFunctionEmulatorForHLSL(BuiltInFunctionEmulator *emu)
"}\n"); "}\n");
emu->addEmulatedFunctionWithDependency( emu->addEmulatedFunctionWithDependency(
umulExtendedUint1, EOpUmulExtended, uint2, uint2, uint2, uint2, umulExtendedUint1, EOpUmulExtended, uint2, uint2, uint2, uint2,
"void webgl_umulExtended_emu(uint2 x, uint2 y, out uint2 msb, out uint2 lsb)\n" "void umulExtended_emu(uint2 x, uint2 y, out uint2 msb, out uint2 lsb)\n"
"{\n" "{\n"
" webgl_umulExtended_emu(x.x, y.x, msb.x, lsb.x);\n" " umulExtended_emu(x.x, y.x, msb.x, lsb.x);\n"
" webgl_umulExtended_emu(x.y, y.y, msb.y, lsb.y);\n" " umulExtended_emu(x.y, y.y, msb.y, lsb.y);\n"
"}\n"); "}\n");
emu->addEmulatedFunctionWithDependency( emu->addEmulatedFunctionWithDependency(
umulExtendedUint1, EOpUmulExtended, uint3, uint3, uint3, uint3, umulExtendedUint1, EOpUmulExtended, uint3, uint3, uint3, uint3,
"void webgl_umulExtended_emu(uint3 x, uint3 y, out uint3 msb, out uint3 lsb)\n" "void umulExtended_emu(uint3 x, uint3 y, out uint3 msb, out uint3 lsb)\n"
"{\n" "{\n"
" webgl_umulExtended_emu(x.x, y.x, msb.x, lsb.x);\n" " umulExtended_emu(x.x, y.x, msb.x, lsb.x);\n"
" webgl_umulExtended_emu(x.y, y.y, msb.y, lsb.y);\n" " umulExtended_emu(x.y, y.y, msb.y, lsb.y);\n"
" webgl_umulExtended_emu(x.z, y.z, msb.z, lsb.z);\n" " umulExtended_emu(x.z, y.z, msb.z, lsb.z);\n"
"}\n"); "}\n");
emu->addEmulatedFunctionWithDependency( emu->addEmulatedFunctionWithDependency(
umulExtendedUint1, EOpUmulExtended, uint4, uint4, uint4, uint4, umulExtendedUint1, EOpUmulExtended, uint4, uint4, uint4, uint4,
"void webgl_umulExtended_emu(uint4 x, uint4 y, out uint4 msb, out uint4 lsb)\n" "void umulExtended_emu(uint4 x, uint4 y, out uint4 msb, out uint4 lsb)\n"
"{\n" "{\n"
" webgl_umulExtended_emu(x.x, y.x, msb.x, lsb.x);\n" " umulExtended_emu(x.x, y.x, msb.x, lsb.x);\n"
" webgl_umulExtended_emu(x.y, y.y, msb.y, lsb.y);\n" " umulExtended_emu(x.y, y.y, msb.y, lsb.y);\n"
" webgl_umulExtended_emu(x.z, y.z, msb.z, lsb.z);\n" " umulExtended_emu(x.z, y.z, msb.z, lsb.z);\n"
" webgl_umulExtended_emu(x.w, y.w, msb.w, lsb.w);\n" " umulExtended_emu(x.w, y.w, msb.w, lsb.w);\n"
"}\n"); "}\n");
// The imul emulation does two's complement negation on the lsb and msb manually in case the // The imul emulation does two's complement negation on the lsb and msb manually in case the
...@@ -132,12 +132,12 @@ void InitBuiltInFunctionEmulatorForHLSL(BuiltInFunctionEmulator *emu) ...@@ -132,12 +132,12 @@ void InitBuiltInFunctionEmulatorForHLSL(BuiltInFunctionEmulator *emu)
// -2^31. abs(-2^31) is undefined. // -2^31. abs(-2^31) is undefined.
FunctionId imulExtendedInt1 = emu->addEmulatedFunctionWithDependency( FunctionId imulExtendedInt1 = emu->addEmulatedFunctionWithDependency(
umulExtendedUint1, EOpImulExtended, int1, int1, int1, int1, umulExtendedUint1, EOpImulExtended, int1, int1, int1, int1,
"void webgl_imulExtended_emu(int x, int y, out int msb, out int lsb)\n" "void imulExtended_emu(int x, int y, out int msb, out int lsb)\n"
"{\n" "{\n"
" uint unsignedMsb;\n" " uint unsignedMsb;\n"
" uint unsignedLsb;\n" " uint unsignedLsb;\n"
" bool negative = (x < 0) != (y < 0);\n" " bool negative = (x < 0) != (y < 0);\n"
" webgl_umulExtended_emu(uint(abs(x)), uint(abs(y)), unsignedMsb, unsignedLsb);\n" " umulExtended_emu(uint(abs(x)), uint(abs(y)), unsignedMsb, unsignedLsb);\n"
" lsb = asint(unsignedLsb);\n" " lsb = asint(unsignedLsb);\n"
" msb = asint(unsignedMsb);\n" " msb = asint(unsignedMsb);\n"
" if (negative)\n" " if (negative)\n"
...@@ -157,27 +157,27 @@ void InitBuiltInFunctionEmulatorForHLSL(BuiltInFunctionEmulator *emu) ...@@ -157,27 +157,27 @@ void InitBuiltInFunctionEmulatorForHLSL(BuiltInFunctionEmulator *emu)
"}\n"); "}\n");
emu->addEmulatedFunctionWithDependency( emu->addEmulatedFunctionWithDependency(
imulExtendedInt1, EOpImulExtended, int2, int2, int2, int2, imulExtendedInt1, EOpImulExtended, int2, int2, int2, int2,
"void webgl_imulExtended_emu(int2 x, int2 y, out int2 msb, out int2 lsb)\n" "void imulExtended_emu(int2 x, int2 y, out int2 msb, out int2 lsb)\n"
"{\n" "{\n"
" webgl_imulExtended_emu(x.x, y.x, msb.x, lsb.x);\n" " imulExtended_emu(x.x, y.x, msb.x, lsb.x);\n"
" webgl_imulExtended_emu(x.y, y.y, msb.y, lsb.y);\n" " imulExtended_emu(x.y, y.y, msb.y, lsb.y);\n"
"}\n"); "}\n");
emu->addEmulatedFunctionWithDependency( emu->addEmulatedFunctionWithDependency(
imulExtendedInt1, EOpImulExtended, int3, int3, int3, int3, imulExtendedInt1, EOpImulExtended, int3, int3, int3, int3,
"void webgl_imulExtended_emu(int3 x, int3 y, out int3 msb, out int3 lsb)\n" "void imulExtended_emu(int3 x, int3 y, out int3 msb, out int3 lsb)\n"
"{\n" "{\n"
" webgl_imulExtended_emu(x.x, y.x, msb.x, lsb.x);\n" " imulExtended_emu(x.x, y.x, msb.x, lsb.x);\n"
" webgl_imulExtended_emu(x.y, y.y, msb.y, lsb.y);\n" " imulExtended_emu(x.y, y.y, msb.y, lsb.y);\n"
" webgl_imulExtended_emu(x.z, y.z, msb.z, lsb.z);\n" " imulExtended_emu(x.z, y.z, msb.z, lsb.z);\n"
"}\n"); "}\n");
emu->addEmulatedFunctionWithDependency( emu->addEmulatedFunctionWithDependency(
imulExtendedInt1, EOpImulExtended, int4, int4, int4, int4, imulExtendedInt1, EOpImulExtended, int4, int4, int4, int4,
"void webgl_imulExtended_emu(int4 x, int4 y, out int4 msb, out int4 lsb)\n" "void imulExtended_emu(int4 x, int4 y, out int4 msb, out int4 lsb)\n"
"{\n" "{\n"
" webgl_imulExtended_emu(x.x, y.x, msb.x, lsb.x);\n" " imulExtended_emu(x.x, y.x, msb.x, lsb.x);\n"
" webgl_imulExtended_emu(x.y, y.y, msb.y, lsb.y);\n" " imulExtended_emu(x.y, y.y, msb.y, lsb.y);\n"
" webgl_imulExtended_emu(x.z, y.z, msb.z, lsb.z);\n" " imulExtended_emu(x.z, y.z, msb.z, lsb.z);\n"
" webgl_imulExtended_emu(x.w, y.w, msb.w, lsb.w);\n" " imulExtended_emu(x.w, y.w, msb.w, lsb.w);\n"
"}\n"); "}\n");
} }
......
...@@ -71,14 +71,14 @@ void TranslatorESSL::translate(TIntermBlock *root, ShCompileOptions compileOptio ...@@ -71,14 +71,14 @@ void TranslatorESSL::translate(TIntermBlock *root, ShCompileOptions compileOptio
if (getShaderType() == GL_FRAGMENT_SHADER) if (getShaderType() == GL_FRAGMENT_SHADER)
{ {
sink << "#if defined(GL_FRAGMENT_PRECISION_HIGH)\n" sink << "#if defined(GL_FRAGMENT_PRECISION_HIGH)\n"
<< "#define webgl_emu_precision highp\n" << "#define emu_precision highp\n"
<< "#else\n" << "#else\n"
<< "#define webgl_emu_precision mediump\n" << "#define emu_precision mediump\n"
<< "#endif\n\n"; << "#endif\n\n";
} }
else else
{ {
sink << "#define webgl_emu_precision highp\n"; sink << "#define emu_precision highp\n";
} }
getBuiltInFunctionEmulator().outputEmulatedFunctions(sink); getBuiltInFunctionEmulator().outputEmulatedFunctions(sink);
......
...@@ -117,7 +117,7 @@ void TranslatorGLSL::translate(TIntermBlock *root, ShCompileOptions compileOptio ...@@ -117,7 +117,7 @@ void TranslatorGLSL::translate(TIntermBlock *root, ShCompileOptions compileOptio
if (!getBuiltInFunctionEmulator().isOutputEmpty()) if (!getBuiltInFunctionEmulator().isOutputEmpty())
{ {
sink << "// BEGIN: Generated code for built-in function emulation\n\n"; sink << "// BEGIN: Generated code for built-in function emulation\n\n";
sink << "#define webgl_emu_precision\n\n"; sink << "#define emu_precision\n\n";
getBuiltInFunctionEmulator().outputEmulatedFunctions(sink); getBuiltInFunctionEmulator().outputEmulatedFunctions(sink);
sink << "// END: Generated code for built-in function emulation\n\n"; sink << "// END: Generated code for built-in function emulation\n\n";
} }
......
...@@ -29,42 +29,42 @@ struct FunctionPair ...@@ -29,42 +29,42 @@ struct FunctionPair
constexpr FunctionPair g_hlslFunctions[] = { constexpr FunctionPair g_hlslFunctions[] = {
{{EOpMod, ParamType::Float1, ParamType::Float1}, {{EOpMod, ParamType::Float1, ParamType::Float1},
"float webgl_mod_emu(float x, float y)\n" "float mod_emu(float x, float y)\n"
"{\n" "{\n"
" return x - y * floor(x / y);\n" " return x - y * floor(x / y);\n"
"}\n"}, "}\n"},
{{EOpMod, ParamType::Float2, ParamType::Float2}, {{EOpMod, ParamType::Float2, ParamType::Float2},
"float2 webgl_mod_emu(float2 x, float2 y)\n" "float2 mod_emu(float2 x, float2 y)\n"
"{\n" "{\n"
" return x - y * floor(x / y);\n" " return x - y * floor(x / y);\n"
"}\n"}, "}\n"},
{{EOpMod, ParamType::Float2, ParamType::Float1}, {{EOpMod, ParamType::Float2, ParamType::Float1},
"float2 webgl_mod_emu(float2 x, float y)\n" "float2 mod_emu(float2 x, float y)\n"
"{\n" "{\n"
" return x - y * floor(x / y);\n" " return x - y * floor(x / y);\n"
"}\n"}, "}\n"},
{{EOpMod, ParamType::Float3, ParamType::Float3}, {{EOpMod, ParamType::Float3, ParamType::Float3},
"float3 webgl_mod_emu(float3 x, float3 y)\n" "float3 mod_emu(float3 x, float3 y)\n"
"{\n" "{\n"
" return x - y * floor(x / y);\n" " return x - y * floor(x / y);\n"
"}\n"}, "}\n"},
{{EOpMod, ParamType::Float3, ParamType::Float1}, {{EOpMod, ParamType::Float3, ParamType::Float1},
"float3 webgl_mod_emu(float3 x, float y)\n" "float3 mod_emu(float3 x, float y)\n"
"{\n" "{\n"
" return x - y * floor(x / y);\n" " return x - y * floor(x / y);\n"
"}\n"}, "}\n"},
{{EOpMod, ParamType::Float4, ParamType::Float4}, {{EOpMod, ParamType::Float4, ParamType::Float4},
"float4 webgl_mod_emu(float4 x, float4 y)\n" "float4 mod_emu(float4 x, float4 y)\n"
"{\n" "{\n"
" return x - y * floor(x / y);\n" " return x - y * floor(x / y);\n"
"}\n"}, "}\n"},
{{EOpMod, ParamType::Float4, ParamType::Float1}, {{EOpMod, ParamType::Float4, ParamType::Float1},
"float4 webgl_mod_emu(float4 x, float y)\n" "float4 mod_emu(float4 x, float y)\n"
"{\n" "{\n"
" return x - y * floor(x / y);\n" " return x - y * floor(x / y);\n"
"}\n"}, "}\n"},
{{EOpFrexp, ParamType::Float1, ParamType::Int1}, {{EOpFrexp, ParamType::Float1, ParamType::Int1},
"float webgl_frexp_emu(float x, out int exp)\n" "float frexp_emu(float x, out int exp)\n"
"{\n" "{\n"
" float fexp;\n" " float fexp;\n"
" float mantissa = frexp(abs(x), fexp) * sign(x);\n" " float mantissa = frexp(abs(x), fexp) * sign(x);\n"
...@@ -72,7 +72,7 @@ constexpr FunctionPair g_hlslFunctions[] = { ...@@ -72,7 +72,7 @@ constexpr FunctionPair g_hlslFunctions[] = {
" return mantissa;\n" " return mantissa;\n"
"}\n"}, "}\n"},
{{EOpFrexp, ParamType::Float2, ParamType::Int2}, {{EOpFrexp, ParamType::Float2, ParamType::Int2},
"float2 webgl_frexp_emu(float2 x, out int2 exp)\n" "float2 frexp_emu(float2 x, out int2 exp)\n"
"{\n" "{\n"
" float2 fexp;\n" " float2 fexp;\n"
" float2 mantissa = frexp(abs(x), fexp) * sign(x);\n" " float2 mantissa = frexp(abs(x), fexp) * sign(x);\n"
...@@ -80,7 +80,7 @@ constexpr FunctionPair g_hlslFunctions[] = { ...@@ -80,7 +80,7 @@ constexpr FunctionPair g_hlslFunctions[] = {
" return mantissa;\n" " return mantissa;\n"
"}\n"}, "}\n"},
{{EOpFrexp, ParamType::Float3, ParamType::Int3}, {{EOpFrexp, ParamType::Float3, ParamType::Int3},
"float3 webgl_frexp_emu(float3 x, out int3 exp)\n" "float3 frexp_emu(float3 x, out int3 exp)\n"
"{\n" "{\n"
" float3 fexp;\n" " float3 fexp;\n"
" float3 mantissa = frexp(abs(x), fexp) * sign(x);\n" " float3 mantissa = frexp(abs(x), fexp) * sign(x);\n"
...@@ -88,7 +88,7 @@ constexpr FunctionPair g_hlslFunctions[] = { ...@@ -88,7 +88,7 @@ constexpr FunctionPair g_hlslFunctions[] = {
" return mantissa;\n" " return mantissa;\n"
"}\n"}, "}\n"},
{{EOpFrexp, ParamType::Float4, ParamType::Int4}, {{EOpFrexp, ParamType::Float4, ParamType::Int4},
"float4 webgl_frexp_emu(float4 x, out int4 exp)\n" "float4 frexp_emu(float4 x, out int4 exp)\n"
"{\n" "{\n"
" float4 fexp;\n" " float4 fexp;\n"
" float4 mantissa = frexp(abs(x), fexp) * sign(x);\n" " float4 mantissa = frexp(abs(x), fexp) * sign(x);\n"
...@@ -96,27 +96,27 @@ constexpr FunctionPair g_hlslFunctions[] = { ...@@ -96,27 +96,27 @@ constexpr FunctionPair g_hlslFunctions[] = {
" return mantissa;\n" " return mantissa;\n"
"}\n"}, "}\n"},
{{EOpLdexp, ParamType::Float1, ParamType::Int1}, {{EOpLdexp, ParamType::Float1, ParamType::Int1},
"float webgl_ldexp_emu(float x, int exp)\n" "float ldexp_emu(float x, int exp)\n"
"{\n" "{\n"
" return ldexp(x, float(exp));\n" " return ldexp(x, float(exp));\n"
"}\n"}, "}\n"},
{{EOpLdexp, ParamType::Float2, ParamType::Int2}, {{EOpLdexp, ParamType::Float2, ParamType::Int2},
"float2 webgl_ldexp_emu(float2 x, int2 exp)\n" "float2 ldexp_emu(float2 x, int2 exp)\n"
"{\n" "{\n"
" return ldexp(x, float2(exp));\n" " return ldexp(x, float2(exp));\n"
"}\n"}, "}\n"},
{{EOpLdexp, ParamType::Float3, ParamType::Int3}, {{EOpLdexp, ParamType::Float3, ParamType::Int3},
"float3 webgl_ldexp_emu(float3 x, int3 exp)\n" "float3 ldexp_emu(float3 x, int3 exp)\n"
"{\n" "{\n"
" return ldexp(x, float3(exp));\n" " return ldexp(x, float3(exp));\n"
"}\n"}, "}\n"},
{{EOpLdexp, ParamType::Float4, ParamType::Int4}, {{EOpLdexp, ParamType::Float4, ParamType::Int4},
"float4 webgl_ldexp_emu(float4 x, int4 exp)\n" "float4 ldexp_emu(float4 x, int4 exp)\n"
"{\n" "{\n"
" return ldexp(x, float4(exp));\n" " return ldexp(x, float4(exp));\n"
"}\n"}, "}\n"},
{{EOpFaceforward, ParamType::Float1, ParamType::Float1, ParamType::Float1}, {{EOpFaceforward, ParamType::Float1, ParamType::Float1, ParamType::Float1},
"float webgl_faceforward_emu(float N, float I, float Nref)\n" "float faceforward_emu(float N, float I, float Nref)\n"
"{\n" "{\n"
" if(dot(Nref, I) >= 0)\n" " if(dot(Nref, I) >= 0)\n"
" {\n" " {\n"
...@@ -128,7 +128,7 @@ constexpr FunctionPair g_hlslFunctions[] = { ...@@ -128,7 +128,7 @@ constexpr FunctionPair g_hlslFunctions[] = {
" }\n" " }\n"
"}\n"}, "}\n"},
{{EOpFaceforward, ParamType::Float2, ParamType::Float2, ParamType::Float2}, {{EOpFaceforward, ParamType::Float2, ParamType::Float2, ParamType::Float2},
"float2 webgl_faceforward_emu(float2 N, float2 I, float2 Nref)\n" "float2 faceforward_emu(float2 N, float2 I, float2 Nref)\n"
"{\n" "{\n"
" if(dot(Nref, I) >= 0)\n" " if(dot(Nref, I) >= 0)\n"
" {\n" " {\n"
...@@ -140,7 +140,7 @@ constexpr FunctionPair g_hlslFunctions[] = { ...@@ -140,7 +140,7 @@ constexpr FunctionPair g_hlslFunctions[] = {
" }\n" " }\n"
"}\n"}, "}\n"},
{{EOpFaceforward, ParamType::Float3, ParamType::Float3, ParamType::Float3}, {{EOpFaceforward, ParamType::Float3, ParamType::Float3, ParamType::Float3},
"float3 webgl_faceforward_emu(float3 N, float3 I, float3 Nref)\n" "float3 faceforward_emu(float3 N, float3 I, float3 Nref)\n"
"{\n" "{\n"
" if(dot(Nref, I) >= 0)\n" " if(dot(Nref, I) >= 0)\n"
" {\n" " {\n"
...@@ -152,7 +152,7 @@ constexpr FunctionPair g_hlslFunctions[] = { ...@@ -152,7 +152,7 @@ constexpr FunctionPair g_hlslFunctions[] = {
" }\n" " }\n"
"}\n"}, "}\n"},
{{EOpFaceforward, ParamType::Float4, ParamType::Float4, ParamType::Float4}, {{EOpFaceforward, ParamType::Float4, ParamType::Float4, ParamType::Float4},
"float4 webgl_faceforward_emu(float4 N, float4 I, float4 Nref)\n" "float4 faceforward_emu(float4 N, float4 I, float4 Nref)\n"
"{\n" "{\n"
" if(dot(Nref, I) >= 0)\n" " if(dot(Nref, I) >= 0)\n"
" {\n" " {\n"
...@@ -164,20 +164,20 @@ constexpr FunctionPair g_hlslFunctions[] = { ...@@ -164,20 +164,20 @@ constexpr FunctionPair g_hlslFunctions[] = {
" }\n" " }\n"
"}\n"}, "}\n"},
{{EOpAtan, ParamType::Float1, ParamType::Float1}, {{EOpAtan, ParamType::Float1, ParamType::Float1},
"float webgl_atan_emu(float y, float x)\n" "float atan_emu(float y, float x)\n"
"{\n" "{\n"
" if(x == 0 && y == 0) x = 1;\n" " if(x == 0 && y == 0) x = 1;\n"
" return atan2(y, x);\n" " return atan2(y, x);\n"
"}\n"}, "}\n"},
{{EOpAtan, ParamType::Float2, ParamType::Float2}, {{EOpAtan, ParamType::Float2, ParamType::Float2},
"float2 webgl_atan_emu(float2 y, float2 x)\n" "float2 atan_emu(float2 y, float2 x)\n"
"{\n" "{\n"
" if(x[0] == 0 && y[0] == 0) x[0] = 1;\n" " if(x[0] == 0 && y[0] == 0) x[0] = 1;\n"
" if(x[1] == 0 && y[1] == 0) x[1] = 1;\n" " if(x[1] == 0 && y[1] == 0) x[1] = 1;\n"
" return float2(atan2(y[0], x[0]), atan2(y[1], x[1]));\n" " return float2(atan2(y[0], x[0]), atan2(y[1], x[1]));\n"
"}\n"}, "}\n"},
{{EOpAtan, ParamType::Float3, ParamType::Float3}, {{EOpAtan, ParamType::Float3, ParamType::Float3},
"float3 webgl_atan_emu(float3 y, float3 x)\n" "float3 atan_emu(float3 y, float3 x)\n"
"{\n" "{\n"
" if(x[0] == 0 && y[0] == 0) x[0] = 1;\n" " if(x[0] == 0 && y[0] == 0) x[0] = 1;\n"
" if(x[1] == 0 && y[1] == 0) x[1] = 1;\n" " if(x[1] == 0 && y[1] == 0) x[1] = 1;\n"
...@@ -185,7 +185,7 @@ constexpr FunctionPair g_hlslFunctions[] = { ...@@ -185,7 +185,7 @@ constexpr FunctionPair g_hlslFunctions[] = {
" return float3(atan2(y[0], x[0]), atan2(y[1], x[1]), atan2(y[2], x[2]));\n" " return float3(atan2(y[0], x[0]), atan2(y[1], x[1]), atan2(y[2], x[2]));\n"
"}\n"}, "}\n"},
{{EOpAtan, ParamType::Float4, ParamType::Float4}, {{EOpAtan, ParamType::Float4, ParamType::Float4},
"float4 webgl_atan_emu(float4 y, float4 x)\n" "float4 atan_emu(float4 y, float4 x)\n"
"{\n" "{\n"
" if(x[0] == 0 && y[0] == 0) x[0] = 1;\n" " if(x[0] == 0 && y[0] == 0) x[0] = 1;\n"
" if(x[1] == 0 && y[1] == 0) x[1] = 1;\n" " if(x[1] == 0 && y[1] == 0) x[1] = 1;\n"
...@@ -195,72 +195,72 @@ constexpr FunctionPair g_hlslFunctions[] = { ...@@ -195,72 +195,72 @@ constexpr FunctionPair g_hlslFunctions[] = {
" x[2]), atan2(y[3], x[3]));\n" " x[2]), atan2(y[3], x[3]));\n"
"}\n"}, "}\n"},
{{EOpAsinh, ParamType::Float1}, {{EOpAsinh, ParamType::Float1},
"float webgl_asinh_emu(in float x)\n" "float asinh_emu(in float x)\n"
"{\n" "{\n"
" return log(x + sqrt(pow(x, 2.0) + 1.0));\n" " return log(x + sqrt(pow(x, 2.0) + 1.0));\n"
"}\n"}, "}\n"},
{{EOpAsinh, ParamType::Float2}, {{EOpAsinh, ParamType::Float2},
"float2 webgl_asinh_emu(in float2 x)\n" "float2 asinh_emu(in float2 x)\n"
"{\n" "{\n"
" return log(x + sqrt(pow(x, 2.0) + 1.0));\n" " return log(x + sqrt(pow(x, 2.0) + 1.0));\n"
"}\n"}, "}\n"},
{{EOpAsinh, ParamType::Float3}, {{EOpAsinh, ParamType::Float3},
"float3 webgl_asinh_emu(in float3 x)\n" "float3 asinh_emu(in float3 x)\n"
"{\n" "{\n"
" return log(x + sqrt(pow(x, 2.0) + 1.0));\n" " return log(x + sqrt(pow(x, 2.0) + 1.0));\n"
"}\n"}, "}\n"},
{{EOpAsinh, ParamType::Float4}, {{EOpAsinh, ParamType::Float4},
"float4 webgl_asinh_emu(in float4 x)\n" "float4 asinh_emu(in float4 x)\n"
"{\n" "{\n"
" return log(x + sqrt(pow(x, 2.0) + 1.0));\n" " return log(x + sqrt(pow(x, 2.0) + 1.0));\n"
"}\n"}, "}\n"},
{{EOpAcosh, ParamType::Float1}, {{EOpAcosh, ParamType::Float1},
"float webgl_acosh_emu(in float x)\n" "float acosh_emu(in float x)\n"
"{\n" "{\n"
" return log(x + sqrt(x + 1.0) * sqrt(x - 1.0));\n" " return log(x + sqrt(x + 1.0) * sqrt(x - 1.0));\n"
"}\n"}, "}\n"},
{{EOpAcosh, ParamType::Float2}, {{EOpAcosh, ParamType::Float2},
"float2 webgl_acosh_emu(in float2 x)\n" "float2 acosh_emu(in float2 x)\n"
"{\n" "{\n"
" return log(x + sqrt(x + 1.0) * sqrt(x - 1.0));\n" " return log(x + sqrt(x + 1.0) * sqrt(x - 1.0));\n"
"}\n"}, "}\n"},
{{EOpAcosh, ParamType::Float3}, {{EOpAcosh, ParamType::Float3},
"float3 webgl_acosh_emu(in float3 x)\n" "float3 acosh_emu(in float3 x)\n"
"{\n" "{\n"
" return log(x + sqrt(x + 1.0) * sqrt(x - 1.0));\n" " return log(x + sqrt(x + 1.0) * sqrt(x - 1.0));\n"
"}\n"}, "}\n"},
{{EOpAcosh, ParamType::Float4}, {{EOpAcosh, ParamType::Float4},
"float4 webgl_acosh_emu(in float4 x)\n" "float4 acosh_emu(in float4 x)\n"
"{\n" "{\n"
" return log(x + sqrt(x + 1.0) * sqrt(x - 1.0));\n" " return log(x + sqrt(x + 1.0) * sqrt(x - 1.0));\n"
"}\n"}, "}\n"},
{{EOpAtanh, ParamType::Float1}, {{EOpAtanh, ParamType::Float1},
"float webgl_atanh_emu(in float x)\n" "float atanh_emu(in float x)\n"
"{\n" "{\n"
" return 0.5 * log((1.0 + x) / (1.0 - x));\n" " return 0.5 * log((1.0 + x) / (1.0 - x));\n"
"}\n"}, "}\n"},
{{EOpAtanh, ParamType::Float2}, {{EOpAtanh, ParamType::Float2},
"float2 webgl_atanh_emu(in float2 x)\n" "float2 atanh_emu(in float2 x)\n"
"{\n" "{\n"
" return 0.5 * log((1.0 + x) / (1.0 - x));\n" " return 0.5 * log((1.0 + x) / (1.0 - x));\n"
"}\n"}, "}\n"},
{{EOpAtanh, ParamType::Float3}, {{EOpAtanh, ParamType::Float3},
"float3 webgl_atanh_emu(in float3 x)\n" "float3 atanh_emu(in float3 x)\n"
"{\n" "{\n"
" return 0.5 * log((1.0 + x) / (1.0 - x));\n" " return 0.5 * log((1.0 + x) / (1.0 - x));\n"
"}\n"}, "}\n"},
{{EOpAtanh, ParamType::Float4}, {{EOpAtanh, ParamType::Float4},
"float4 webgl_atanh_emu(in float4 x)\n" "float4 atanh_emu(in float4 x)\n"
"{\n" "{\n"
" return 0.5 * log((1.0 + x) / (1.0 - x));\n" " return 0.5 * log((1.0 + x) / (1.0 - x));\n"
"}\n"}, "}\n"},
{{EOpRoundEven, ParamType::Float1}, {{EOpRoundEven, ParamType::Float1},
"float webgl_roundEven_emu(in float x)\n" "float roundEven_emu(in float x)\n"
"{\n" "{\n"
" return (frac(x) == 0.5 && trunc(x) % 2.0 == 0.0) ? trunc(x) : round(x);\n" " return (frac(x) == 0.5 && trunc(x) % 2.0 == 0.0) ? trunc(x) : round(x);\n"
"}\n"}, "}\n"},
{{EOpRoundEven, ParamType::Float2}, {{EOpRoundEven, ParamType::Float2},
"float2 webgl_roundEven_emu(in float2 x)\n" "float2 roundEven_emu(in float2 x)\n"
"{\n" "{\n"
" float2 v;\n" " float2 v;\n"
" v[0] = (frac(x[0]) == 0.5 && trunc(x[0]) % 2.0 == 0.0) ? trunc(x[0]) : round(x[0]);\n" " v[0] = (frac(x[0]) == 0.5 && trunc(x[0]) % 2.0 == 0.0) ? trunc(x[0]) : round(x[0]);\n"
...@@ -268,7 +268,7 @@ constexpr FunctionPair g_hlslFunctions[] = { ...@@ -268,7 +268,7 @@ constexpr FunctionPair g_hlslFunctions[] = {
" return v;\n" " return v;\n"
"}\n"}, "}\n"},
{{EOpRoundEven, ParamType::Float3}, {{EOpRoundEven, ParamType::Float3},
"float3 webgl_roundEven_emu(in float3 x)\n" "float3 roundEven_emu(in float3 x)\n"
"{\n" "{\n"
" float3 v;\n" " float3 v;\n"
" v[0] = (frac(x[0]) == 0.5 && trunc(x[0]) % 2.0 == 0.0) ? trunc(x[0]) : round(x[0]);\n" " v[0] = (frac(x[0]) == 0.5 && trunc(x[0]) % 2.0 == 0.0) ? trunc(x[0]) : round(x[0]);\n"
...@@ -277,7 +277,7 @@ constexpr FunctionPair g_hlslFunctions[] = { ...@@ -277,7 +277,7 @@ constexpr FunctionPair g_hlslFunctions[] = {
" return v;\n" " return v;\n"
"}\n"}, "}\n"},
{{EOpRoundEven, ParamType::Float4}, {{EOpRoundEven, ParamType::Float4},
"float4 webgl_roundEven_emu(in float4 x)\n" "float4 roundEven_emu(in float4 x)\n"
"{\n" "{\n"
" float4 v;\n" " float4 v;\n"
" v[0] = (frac(x[0]) == 0.5 && trunc(x[0]) % 2.0 == 0.0) ? trunc(x[0]) : round(x[0]);\n" " v[0] = (frac(x[0]) == 0.5 && trunc(x[0]) % 2.0 == 0.0) ? trunc(x[0]) : round(x[0]);\n"
...@@ -290,7 +290,7 @@ constexpr FunctionPair g_hlslFunctions[] = { ...@@ -290,7 +290,7 @@ constexpr FunctionPair g_hlslFunctions[] = {
"int webgl_toSnorm16(in float x) {\n" "int webgl_toSnorm16(in float x) {\n"
" return int(round(clamp(x, -1.0, 1.0) * 32767.0));\n" " return int(round(clamp(x, -1.0, 1.0) * 32767.0));\n"
"}\n" "}\n"
"uint webgl_packSnorm2x16_emu(in float2 v)\n" "uint packSnorm2x16_emu(in float2 v)\n"
"{\n" "{\n"
" int x = webgl_toSnorm16(v.x);\n" " int x = webgl_toSnorm16(v.x);\n"
" int y = webgl_toSnorm16(v.y);\n" " int y = webgl_toSnorm16(v.y);\n"
...@@ -300,14 +300,14 @@ constexpr FunctionPair g_hlslFunctions[] = { ...@@ -300,14 +300,14 @@ constexpr FunctionPair g_hlslFunctions[] = {
"uint webgl_toUnorm16(in float x) {\n" "uint webgl_toUnorm16(in float x) {\n"
" return uint(round(clamp(x, 0.0, 1.0) * 65535.0));\n" " return uint(round(clamp(x, 0.0, 1.0) * 65535.0));\n"
"}\n" "}\n"
"uint webgl_packUnorm2x16_emu(in float2 v)\n" "uint packUnorm2x16_emu(in float2 v)\n"
"{\n" "{\n"
" uint x = webgl_toUnorm16(v.x);\n" " uint x = webgl_toUnorm16(v.x);\n"
" uint y = webgl_toUnorm16(v.y);\n" " uint y = webgl_toUnorm16(v.y);\n"
" return (y << 16) | x;\n" " return (y << 16) | x;\n"
"}\n"}, "}\n"},
{{EOpPackHalf2x16, ParamType::Float2}, {{EOpPackHalf2x16, ParamType::Float2},
"uint webgl_packHalf2x16_emu(in float2 v)\n" "uint packHalf2x16_emu(in float2 v)\n"
"{\n" "{\n"
" uint x = f32tof16(v.x);\n" " uint x = f32tof16(v.x);\n"
" uint y = f32tof16(v.y);\n" " uint y = f32tof16(v.y);\n"
...@@ -318,7 +318,7 @@ constexpr FunctionPair g_hlslFunctions[] = { ...@@ -318,7 +318,7 @@ constexpr FunctionPair g_hlslFunctions[] = {
" int xi = asint(x & 0x7fffu) - asint(x & 0x8000u);\n" " int xi = asint(x & 0x7fffu) - asint(x & 0x8000u);\n"
" return clamp(float(xi) / 32767.0, -1.0, 1.0);\n" " return clamp(float(xi) / 32767.0, -1.0, 1.0);\n"
"}\n" "}\n"
"float2 webgl_unpackSnorm2x16_emu(in uint u)\n" "float2 unpackSnorm2x16_emu(in uint u)\n"
"{\n" "{\n"
" uint y = (u >> 16);\n" " uint y = (u >> 16);\n"
" uint x = u;\n" " uint x = u;\n"
...@@ -328,14 +328,14 @@ constexpr FunctionPair g_hlslFunctions[] = { ...@@ -328,14 +328,14 @@ constexpr FunctionPair g_hlslFunctions[] = {
"float webgl_fromUnorm16(in uint x) {\n" "float webgl_fromUnorm16(in uint x) {\n"
" return float(x) / 65535.0;\n" " return float(x) / 65535.0;\n"
"}\n" "}\n"
"float2 webgl_unpackUnorm2x16_emu(in uint u)\n" "float2 unpackUnorm2x16_emu(in uint u)\n"
"{\n" "{\n"
" uint y = (u >> 16);\n" " uint y = (u >> 16);\n"
" uint x = u & 0xffffu;\n" " uint x = u & 0xffffu;\n"
" return float2(webgl_fromUnorm16(x), webgl_fromUnorm16(y));\n" " return float2(webgl_fromUnorm16(x), webgl_fromUnorm16(y));\n"
"}\n"}, "}\n"},
{{EOpUnpackHalf2x16, ParamType::Uint1}, {{EOpUnpackHalf2x16, ParamType::Uint1},
"float2 webgl_unpackHalf2x16_emu(in uint u)\n" "float2 unpackHalf2x16_emu(in uint u)\n"
"{\n" "{\n"
" uint y = (u >> 16);\n" " uint y = (u >> 16);\n"
" uint x = u & 0xffffu;\n" " uint x = u & 0xffffu;\n"
...@@ -345,7 +345,7 @@ constexpr FunctionPair g_hlslFunctions[] = { ...@@ -345,7 +345,7 @@ constexpr FunctionPair g_hlslFunctions[] = {
"int webgl_toSnorm8(in float x) {\n" "int webgl_toSnorm8(in float x) {\n"
" return int(round(clamp(x, -1.0, 1.0) * 127.0));\n" " return int(round(clamp(x, -1.0, 1.0) * 127.0));\n"
"}\n" "}\n"
"uint webgl_packSnorm4x8_emu(in float4 v)\n" "uint packSnorm4x8_emu(in float4 v)\n"
"{\n" "{\n"
" int x = webgl_toSnorm8(v.x);\n" " int x = webgl_toSnorm8(v.x);\n"
" int y = webgl_toSnorm8(v.y);\n" " int y = webgl_toSnorm8(v.y);\n"
...@@ -358,7 +358,7 @@ constexpr FunctionPair g_hlslFunctions[] = { ...@@ -358,7 +358,7 @@ constexpr FunctionPair g_hlslFunctions[] = {
"uint webgl_toUnorm8(in float x) {\n" "uint webgl_toUnorm8(in float x) {\n"
" return uint(round(clamp(x, 0.0, 1.0) * 255.0));\n" " return uint(round(clamp(x, 0.0, 1.0) * 255.0));\n"
"}\n" "}\n"
"uint webgl_packUnorm4x8_emu(in float4 v)\n" "uint packUnorm4x8_emu(in float4 v)\n"
"{\n" "{\n"
" uint x = webgl_toUnorm8(v.x);\n" " uint x = webgl_toUnorm8(v.x);\n"
" uint y = webgl_toUnorm8(v.y);\n" " uint y = webgl_toUnorm8(v.y);\n"
...@@ -371,7 +371,7 @@ constexpr FunctionPair g_hlslFunctions[] = { ...@@ -371,7 +371,7 @@ constexpr FunctionPair g_hlslFunctions[] = {
" int xi = asint(x & 0x7fu) - asint(x & 0x80u);\n" " int xi = asint(x & 0x7fu) - asint(x & 0x80u);\n"
" return clamp(float(xi) / 127.0, -1.0, 1.0);\n" " return clamp(float(xi) / 127.0, -1.0, 1.0);\n"
"}\n" "}\n"
"float4 webgl_unpackSnorm4x8_emu(in uint u)\n" "float4 unpackSnorm4x8_emu(in uint u)\n"
"{\n" "{\n"
" uint w = (u >> 24);\n" " uint w = (u >> 24);\n"
" uint z = (u >> 16);\n" " uint z = (u >> 16);\n"
...@@ -384,7 +384,7 @@ constexpr FunctionPair g_hlslFunctions[] = { ...@@ -384,7 +384,7 @@ constexpr FunctionPair g_hlslFunctions[] = {
"float webgl_fromUnorm8(in uint x) {\n" "float webgl_fromUnorm8(in uint x) {\n"
" return float(x) / 255.0;\n" " return float(x) / 255.0;\n"
"}\n" "}\n"
"float4 webgl_unpackUnorm4x8_emu(in uint u)\n" "float4 unpackUnorm4x8_emu(in uint u)\n"
"{\n" "{\n"
" uint w = (u >> 24) & 0xffu;\n" " uint w = (u >> 24) & 0xffu;\n"
" uint z = (u >> 16) & 0xffu;\n" " uint z = (u >> 16) & 0xffu;\n"
...@@ -403,47 +403,47 @@ constexpr FunctionPair g_hlslFunctions[] = { ...@@ -403,47 +403,47 @@ constexpr FunctionPair g_hlslFunctions[] = {
// transpose of r, we simply can build a column matrix out of the original // transpose of r, we simply can build a column matrix out of the original
// vector instead of a row matrix. // vector instead of a row matrix.
{{EOpOuterProduct, ParamType::Float2, ParamType::Float2}, {{EOpOuterProduct, ParamType::Float2, ParamType::Float2},
"float2x2 webgl_outerProduct_emu(in float2 c, in float2 r)\n" "float2x2 outerProduct_emu(in float2 c, in float2 r)\n"
"{\n" "{\n"
" return mul(float2x1(r), float1x2(c));\n" " return mul(float2x1(r), float1x2(c));\n"
"}\n"}, "}\n"},
{{EOpOuterProduct, ParamType::Float3, ParamType::Float3}, {{EOpOuterProduct, ParamType::Float3, ParamType::Float3},
"float3x3 webgl_outerProduct_emu(in float3 c, in float3 r)\n" "float3x3 outerProduct_emu(in float3 c, in float3 r)\n"
"{\n" "{\n"
" return mul(float3x1(r), float1x3(c));\n" " return mul(float3x1(r), float1x3(c));\n"
"}\n"}, "}\n"},
{{EOpOuterProduct, ParamType::Float4, ParamType::Float4}, {{EOpOuterProduct, ParamType::Float4, ParamType::Float4},
"float4x4 webgl_outerProduct_emu(in float4 c, in float4 r)\n" "float4x4 outerProduct_emu(in float4 c, in float4 r)\n"
"{\n" "{\n"
" return mul(float4x1(r), float1x4(c));\n" " return mul(float4x1(r), float1x4(c));\n"
"}\n"}, "}\n"},
{{EOpOuterProduct, ParamType::Float3, ParamType::Float2}, {{EOpOuterProduct, ParamType::Float3, ParamType::Float2},
"float2x3 webgl_outerProduct_emu(in float3 c, in float2 r)\n" "float2x3 outerProduct_emu(in float3 c, in float2 r)\n"
"{\n" "{\n"
" return mul(float2x1(r), float1x3(c));\n" " return mul(float2x1(r), float1x3(c));\n"
"}\n"}, "}\n"},
{{EOpOuterProduct, ParamType::Float2, ParamType::Float3}, {{EOpOuterProduct, ParamType::Float2, ParamType::Float3},
"float3x2 webgl_outerProduct_emu(in float2 c, in float3 r)\n" "float3x2 outerProduct_emu(in float2 c, in float3 r)\n"
"{\n" "{\n"
" return mul(float3x1(r), float1x2(c));\n" " return mul(float3x1(r), float1x2(c));\n"
"}\n"}, "}\n"},
{{EOpOuterProduct, ParamType::Float4, ParamType::Float2}, {{EOpOuterProduct, ParamType::Float4, ParamType::Float2},
"float2x4 webgl_outerProduct_emu(in float4 c, in float2 r)\n" "float2x4 outerProduct_emu(in float4 c, in float2 r)\n"
"{\n" "{\n"
" return mul(float2x1(r), float1x4(c));\n" " return mul(float2x1(r), float1x4(c));\n"
"}\n"}, "}\n"},
{{EOpOuterProduct, ParamType::Float2, ParamType::Float4}, {{EOpOuterProduct, ParamType::Float2, ParamType::Float4},
"float4x2 webgl_outerProduct_emu(in float2 c, in float4 r)\n" "float4x2 outerProduct_emu(in float2 c, in float4 r)\n"
"{\n" "{\n"
" return mul(float4x1(r), float1x2(c));\n" " return mul(float4x1(r), float1x2(c));\n"
"}\n"}, "}\n"},
{{EOpOuterProduct, ParamType::Float4, ParamType::Float3}, {{EOpOuterProduct, ParamType::Float4, ParamType::Float3},
"float3x4 webgl_outerProduct_emu(in float4 c, in float3 r)\n" "float3x4 outerProduct_emu(in float4 c, in float3 r)\n"
"{\n" "{\n"
" return mul(float3x1(r), float1x4(c));\n" " return mul(float3x1(r), float1x4(c));\n"
"}\n"}, "}\n"},
{{EOpOuterProduct, ParamType::Float3, ParamType::Float4}, {{EOpOuterProduct, ParamType::Float3, ParamType::Float4},
"float4x3 webgl_outerProduct_emu(in float3 c, in float4 r)\n" "float4x3 outerProduct_emu(in float3 c, in float4 r)\n"
"{\n" "{\n"
" return mul(float4x1(r), float1x3(c));\n" " return mul(float4x1(r), float1x3(c));\n"
"}\n"}, "}\n"},
...@@ -459,14 +459,14 @@ constexpr FunctionPair g_hlslFunctions[] = { ...@@ -459,14 +459,14 @@ constexpr FunctionPair g_hlslFunctions[] = {
// We don't need to care about divide-by-zero since results are undefined // We don't need to care about divide-by-zero since results are undefined
// for singular or poorly-conditioned matrices. // for singular or poorly-conditioned matrices.
{{EOpInverse, ParamType::Mat2}, {{EOpInverse, ParamType::Mat2},
"float2x2 webgl_inverse_emu(in float2x2 m)\n" "float2x2 inverse_emu(in float2x2 m)\n"
"{\n" "{\n"
" float2x2 cof = { m[1][1], -m[0][1], -m[1][0], m[0][0] };\n" " float2x2 cof = { m[1][1], -m[0][1], -m[1][0], m[0][0] };\n"
" return cof / determinant(transpose(m));\n" " return cof / determinant(transpose(m));\n"
"}\n"}, "}\n"},
// cofAB is the cofactor for column A and row B. // cofAB is the cofactor for column A and row B.
{{EOpInverse, ParamType::Mat3}, {{EOpInverse, ParamType::Mat3},
"float3x3 webgl_inverse_emu(in float3x3 m)\n" "float3x3 inverse_emu(in float3x3 m)\n"
"{\n" "{\n"
" float cof00 = m[1][1] * m[2][2] - m[2][1] * m[1][2];\n" " float cof00 = m[1][1] * m[2][2] - m[2][1] * m[1][2];\n"
" float cof01 = -(m[1][0] * m[2][2] - m[2][0] * m[1][2]);\n" " float cof01 = -(m[1][0] * m[2][2] - m[2][0] * m[1][2]);\n"
...@@ -481,7 +481,7 @@ constexpr FunctionPair g_hlslFunctions[] = { ...@@ -481,7 +481,7 @@ constexpr FunctionPair g_hlslFunctions[] = {
" return cof / determinant(transpose(m));\n" " return cof / determinant(transpose(m));\n"
"}\n"}, "}\n"},
{{EOpInverse, ParamType::Mat4}, {{EOpInverse, ParamType::Mat4},
"float4x4 webgl_inverse_emu(in float4x4 m)\n" "float4x4 inverse_emu(in float4x4 m)\n"
"{\n" "{\n"
" float cof00 = m[1][1] * m[2][2] * m[3][3] + m[2][1] * m[3][2] * m[1][3] + m[3][1] * \n" " float cof00 = m[1][1] * m[2][2] * m[3][3] + m[2][1] * m[3][2] * m[1][3] + m[3][1] * \n"
" m[1][2] * m[2][3]\n" " m[1][2] * m[2][3]\n"
...@@ -557,27 +557,27 @@ constexpr FunctionPair g_hlslFunctions[] = { ...@@ -557,27 +557,27 @@ constexpr FunctionPair g_hlslFunctions[] = {
// returned. For a component of 'a' that is true, the corresponding component of 'y' is // returned. For a component of 'a' that is true, the corresponding component of 'y' is
// returned. // returned.
{{EOpMix, ParamType::Float1, ParamType::Float1, ParamType::Bool1}, {{EOpMix, ParamType::Float1, ParamType::Float1, ParamType::Bool1},
"float webgl_mix_emu(float x, float y, bool a)\n" "float mix_emu(float x, float y, bool a)\n"
"{\n" "{\n"
" return a ? y : x;\n" " return a ? y : x;\n"
"}\n"}, "}\n"},
{{EOpMix, ParamType::Float2, ParamType::Float2, ParamType::Bool2}, {{EOpMix, ParamType::Float2, ParamType::Float2, ParamType::Bool2},
"float2 webgl_mix_emu(float2 x, float2 y, bool2 a)\n" "float2 mix_emu(float2 x, float2 y, bool2 a)\n"
"{\n" "{\n"
" return a ? y : x;\n" " return a ? y : x;\n"
"}\n"}, "}\n"},
{{EOpMix, ParamType::Float3, ParamType::Float3, ParamType::Bool3}, {{EOpMix, ParamType::Float3, ParamType::Float3, ParamType::Bool3},
"float3 webgl_mix_emu(float3 x, float3 y, bool3 a)\n" "float3 mix_emu(float3 x, float3 y, bool3 a)\n"
"{\n" "{\n"
" return a ? y : x;\n" " return a ? y : x;\n"
"}\n"}, "}\n"},
{{EOpMix, ParamType::Float4, ParamType::Float4, ParamType::Bool4}, {{EOpMix, ParamType::Float4, ParamType::Float4, ParamType::Bool4},
"float4 webgl_mix_emu(float4 x, float4 y, bool4 a)\n" "float4 mix_emu(float4 x, float4 y, bool4 a)\n"
"{\n" "{\n"
" return a ? y : x;\n" " return a ? y : x;\n"
"}\n"}, "}\n"},
{{EOpBitfieldExtract, ParamType::Uint1, ParamType::Int1, ParamType::Int1}, {{EOpBitfieldExtract, ParamType::Uint1, ParamType::Int1, ParamType::Int1},
"uint webgl_bitfieldExtract_emu(uint value, int offset, int bits)\n" "uint bitfieldExtract_emu(uint value, int offset, int bits)\n"
"{\n" "{\n"
" if (offset < 0 || bits <= 0 || offset >= 32 || bits > 32 || offset + bits > 32)\n" " if (offset < 0 || bits <= 0 || offset >= 32 || bits > 32 || offset + bits > 32)\n"
" {\n" " {\n"
...@@ -588,7 +588,7 @@ constexpr FunctionPair g_hlslFunctions[] = { ...@@ -588,7 +588,7 @@ constexpr FunctionPair g_hlslFunctions[] = {
" return (value & mask) >> offset;\n" " return (value & mask) >> offset;\n"
"}\n"}, "}\n"},
{{EOpBitfieldExtract, ParamType::Uint2, ParamType::Int1, ParamType::Int1}, {{EOpBitfieldExtract, ParamType::Uint2, ParamType::Int1, ParamType::Int1},
"uint2 webgl_bitfieldExtract_emu(uint2 value, int offset, int bits)\n" "uint2 bitfieldExtract_emu(uint2 value, int offset, int bits)\n"
"{\n" "{\n"
" if (offset < 0 || bits <= 0 || offset >= 32 || bits > 32 || offset + bits > 32)\n" " if (offset < 0 || bits <= 0 || offset >= 32 || bits > 32 || offset + bits > 32)\n"
" {\n" " {\n"
...@@ -599,7 +599,7 @@ constexpr FunctionPair g_hlslFunctions[] = { ...@@ -599,7 +599,7 @@ constexpr FunctionPair g_hlslFunctions[] = {
" return (value & mask) >> offset;\n" " return (value & mask) >> offset;\n"
"}\n"}, "}\n"},
{{EOpBitfieldExtract, ParamType::Uint3, ParamType::Int1, ParamType::Int1}, {{EOpBitfieldExtract, ParamType::Uint3, ParamType::Int1, ParamType::Int1},
"uint3 webgl_bitfieldExtract_emu(uint3 value, int offset, int bits)\n" "uint3 bitfieldExtract_emu(uint3 value, int offset, int bits)\n"
"{\n" "{\n"
" if (offset < 0 || bits <= 0 || offset >= 32 || bits > 32 || offset + bits > 32)\n" " if (offset < 0 || bits <= 0 || offset >= 32 || bits > 32 || offset + bits > 32)\n"
" {\n" " {\n"
...@@ -610,7 +610,7 @@ constexpr FunctionPair g_hlslFunctions[] = { ...@@ -610,7 +610,7 @@ constexpr FunctionPair g_hlslFunctions[] = {
" return (value & mask) >> offset;\n" " return (value & mask) >> offset;\n"
"}\n"}, "}\n"},
{{EOpBitfieldExtract, ParamType::Uint4, ParamType::Int1, ParamType::Int1}, {{EOpBitfieldExtract, ParamType::Uint4, ParamType::Int1, ParamType::Int1},
"uint4 webgl_bitfieldExtract_emu(uint4 value, int offset, int bits)\n" "uint4 bitfieldExtract_emu(uint4 value, int offset, int bits)\n"
"{\n" "{\n"
" if (offset < 0 || bits <= 0 || offset >= 32 || bits > 32 || offset + bits > 32)\n" " if (offset < 0 || bits <= 0 || offset >= 32 || bits > 32 || offset + bits > 32)\n"
" {\n" " {\n"
...@@ -621,7 +621,7 @@ constexpr FunctionPair g_hlslFunctions[] = { ...@@ -621,7 +621,7 @@ constexpr FunctionPair g_hlslFunctions[] = {
" return (value & mask) >> offset;\n" " return (value & mask) >> offset;\n"
"}\n"}, "}\n"},
{{EOpBitfieldExtract, ParamType::Int1, ParamType::Int1, ParamType::Int1}, {{EOpBitfieldExtract, ParamType::Int1, ParamType::Int1, ParamType::Int1},
"int webgl_bitfieldExtract_emu(int value, int offset, int bits)\n" "int bitfieldExtract_emu(int value, int offset, int bits)\n"
"{\n" "{\n"
" if (offset < 0 || bits <= 0 || offset >= 32 || bits > 32 || offset + bits > 32)\n" " if (offset < 0 || bits <= 0 || offset >= 32 || bits > 32 || offset + bits > 32)\n"
" {\n" " {\n"
...@@ -638,7 +638,7 @@ constexpr FunctionPair g_hlslFunctions[] = { ...@@ -638,7 +638,7 @@ constexpr FunctionPair g_hlslFunctions[] = {
" return asint(resultUnsigned);\n" " return asint(resultUnsigned);\n"
"}\n"}, "}\n"},
{{EOpBitfieldExtract, ParamType::Int2, ParamType::Int1, ParamType::Int1}, {{EOpBitfieldExtract, ParamType::Int2, ParamType::Int1, ParamType::Int1},
"int2 webgl_bitfieldExtract_emu(int2 value, int offset, int bits)\n" "int2 bitfieldExtract_emu(int2 value, int offset, int bits)\n"
"{\n" "{\n"
" if (offset < 0 || bits <= 0 || offset >= 32 || bits > 32 || offset + bits > 32)\n" " if (offset < 0 || bits <= 0 || offset >= 32 || bits > 32 || offset + bits > 32)\n"
" {\n" " {\n"
...@@ -655,7 +655,7 @@ constexpr FunctionPair g_hlslFunctions[] = { ...@@ -655,7 +655,7 @@ constexpr FunctionPair g_hlslFunctions[] = {
" return asint(resultUnsigned);\n" " return asint(resultUnsigned);\n"
"}\n"}, "}\n"},
{{EOpBitfieldExtract, ParamType::Int3, ParamType::Int1, ParamType::Int1}, {{EOpBitfieldExtract, ParamType::Int3, ParamType::Int1, ParamType::Int1},
"int3 webgl_bitfieldExtract_emu(int3 value, int offset, int bits)\n" "int3 bitfieldExtract_emu(int3 value, int offset, int bits)\n"
"{\n" "{\n"
" if (offset < 0 || bits <= 0 || offset >= 32 || bits > 32 || offset + bits > 32)\n" " if (offset < 0 || bits <= 0 || offset >= 32 || bits > 32 || offset + bits > 32)\n"
" {\n" " {\n"
...@@ -672,7 +672,7 @@ constexpr FunctionPair g_hlslFunctions[] = { ...@@ -672,7 +672,7 @@ constexpr FunctionPair g_hlslFunctions[] = {
" return asint(resultUnsigned);\n" " return asint(resultUnsigned);\n"
"}\n"}, "}\n"},
{{EOpBitfieldExtract, ParamType::Int4, ParamType::Int1, ParamType::Int1}, {{EOpBitfieldExtract, ParamType::Int4, ParamType::Int1, ParamType::Int1},
"int4 webgl_bitfieldExtract_emu(int4 value, int offset, int bits)\n" "int4 bitfieldExtract_emu(int4 value, int offset, int bits)\n"
"{\n" "{\n"
" if (offset < 0 || bits <= 0 || offset >= 32 || bits > 32 || offset + bits > 32)\n" " if (offset < 0 || bits <= 0 || offset >= 32 || bits > 32 || offset + bits > 32)\n"
" {\n" " {\n"
...@@ -689,7 +689,7 @@ constexpr FunctionPair g_hlslFunctions[] = { ...@@ -689,7 +689,7 @@ constexpr FunctionPair g_hlslFunctions[] = {
" return asint(resultUnsigned);\n" " return asint(resultUnsigned);\n"
"}\n"}, "}\n"},
{{EOpBitfieldInsert, ParamType::Uint1, ParamType::Uint1, ParamType::Int1, ParamType::Int1}, {{EOpBitfieldInsert, ParamType::Uint1, ParamType::Uint1, ParamType::Int1, ParamType::Int1},
"uint webgl_bitfieldInsert_emu(uint base, uint insert, int offset, int bits)\n" "uint bitfieldInsert_emu(uint base, uint insert, int offset, int bits)\n"
"{\n" "{\n"
" if (offset < 0 || bits <= 0 || offset >= 32 || bits > 32 || offset + bits > 32)\n" " if (offset < 0 || bits <= 0 || offset >= 32 || bits > 32 || offset + bits > 32)\n"
" {\n" " {\n"
...@@ -701,7 +701,7 @@ constexpr FunctionPair g_hlslFunctions[] = { ...@@ -701,7 +701,7 @@ constexpr FunctionPair g_hlslFunctions[] = {
" return (base & baseMask) | ((insert << offset) & insertMask);\n" " return (base & baseMask) | ((insert << offset) & insertMask);\n"
"}\n"}, "}\n"},
{{EOpBitfieldInsert, ParamType::Uint2, ParamType::Uint2, ParamType::Int1, ParamType::Int1}, {{EOpBitfieldInsert, ParamType::Uint2, ParamType::Uint2, ParamType::Int1, ParamType::Int1},
"uint2 webgl_bitfieldInsert_emu(uint2 base, uint2 insert, int offset, int bits)\n" "uint2 bitfieldInsert_emu(uint2 base, uint2 insert, int offset, int bits)\n"
"{\n" "{\n"
" if (offset < 0 || bits <= 0 || offset >= 32 || bits > 32 || offset + bits > 32)\n" " if (offset < 0 || bits <= 0 || offset >= 32 || bits > 32 || offset + bits > 32)\n"
" {\n" " {\n"
...@@ -713,7 +713,7 @@ constexpr FunctionPair g_hlslFunctions[] = { ...@@ -713,7 +713,7 @@ constexpr FunctionPair g_hlslFunctions[] = {
" return (base & baseMask) | ((insert << offset) & insertMask);\n" " return (base & baseMask) | ((insert << offset) & insertMask);\n"
"}\n"}, "}\n"},
{{EOpBitfieldInsert, ParamType::Uint3, ParamType::Uint3, ParamType::Int1, ParamType::Int1}, {{EOpBitfieldInsert, ParamType::Uint3, ParamType::Uint3, ParamType::Int1, ParamType::Int1},
"uint3 webgl_bitfieldInsert_emu(uint3 base, uint3 insert, int offset, int bits)\n" "uint3 bitfieldInsert_emu(uint3 base, uint3 insert, int offset, int bits)\n"
"{\n" "{\n"
" if (offset < 0 || bits <= 0 || offset >= 32 || bits > 32 || offset + bits > 32)\n" " if (offset < 0 || bits <= 0 || offset >= 32 || bits > 32 || offset + bits > 32)\n"
" {\n" " {\n"
...@@ -725,7 +725,7 @@ constexpr FunctionPair g_hlslFunctions[] = { ...@@ -725,7 +725,7 @@ constexpr FunctionPair g_hlslFunctions[] = {
" return (base & baseMask) | ((insert << offset) & insertMask);\n" " return (base & baseMask) | ((insert << offset) & insertMask);\n"
"}\n"}, "}\n"},
{{EOpBitfieldInsert, ParamType::Uint4, ParamType::Uint4, ParamType::Int1, ParamType::Int1}, {{EOpBitfieldInsert, ParamType::Uint4, ParamType::Uint4, ParamType::Int1, ParamType::Int1},
"uint4 webgl_bitfieldInsert_emu(uint4 base, uint4 insert, int offset, int bits)\n" "uint4 bitfieldInsert_emu(uint4 base, uint4 insert, int offset, int bits)\n"
"{\n" "{\n"
" if (offset < 0 || bits <= 0 || offset >= 32 || bits > 32 || offset + bits > 32)\n" " if (offset < 0 || bits <= 0 || offset >= 32 || bits > 32 || offset + bits > 32)\n"
" {\n" " {\n"
...@@ -737,7 +737,7 @@ constexpr FunctionPair g_hlslFunctions[] = { ...@@ -737,7 +737,7 @@ constexpr FunctionPair g_hlslFunctions[] = {
" return (base & baseMask) | ((insert << offset) & insertMask);\n" " return (base & baseMask) | ((insert << offset) & insertMask);\n"
"}\n"}, "}\n"},
{{EOpBitfieldInsert, ParamType::Int1, ParamType::Int1, ParamType::Int1, ParamType::Int1}, {{EOpBitfieldInsert, ParamType::Int1, ParamType::Int1, ParamType::Int1, ParamType::Int1},
"int webgl_bitfieldInsert_emu(int base, int insert, int offset, int bits)\n" "int bitfieldInsert_emu(int base, int insert, int offset, int bits)\n"
"{\n" "{\n"
" if (offset < 0 || bits <= 0 || offset >= 32 || bits > 32 || offset + bits > 32)\n" " if (offset < 0 || bits <= 0 || offset >= 32 || bits > 32 || offset + bits > 32)\n"
" {\n" " {\n"
...@@ -751,7 +751,7 @@ constexpr FunctionPair g_hlslFunctions[] = { ...@@ -751,7 +751,7 @@ constexpr FunctionPair g_hlslFunctions[] = {
" return asint(resultUnsigned);\n" " return asint(resultUnsigned);\n"
"}\n"}, "}\n"},
{{EOpBitfieldInsert, ParamType::Int2, ParamType::Int2, ParamType::Int1, ParamType::Int1}, {{EOpBitfieldInsert, ParamType::Int2, ParamType::Int2, ParamType::Int1, ParamType::Int1},
"int2 webgl_bitfieldInsert_emu(int2 base, int2 insert, int offset, int bits)\n" "int2 bitfieldInsert_emu(int2 base, int2 insert, int offset, int bits)\n"
"{\n" "{\n"
" if (offset < 0 || bits <= 0 || offset >= 32 || bits > 32 || offset + bits > 32)\n" " if (offset < 0 || bits <= 0 || offset >= 32 || bits > 32 || offset + bits > 32)\n"
" {\n" " {\n"
...@@ -765,7 +765,7 @@ constexpr FunctionPair g_hlslFunctions[] = { ...@@ -765,7 +765,7 @@ constexpr FunctionPair g_hlslFunctions[] = {
" return asint(resultUnsigned);\n" " return asint(resultUnsigned);\n"
"}\n"}, "}\n"},
{{EOpBitfieldInsert, ParamType::Int3, ParamType::Int3, ParamType::Int1, ParamType::Int1}, {{EOpBitfieldInsert, ParamType::Int3, ParamType::Int3, ParamType::Int1, ParamType::Int1},
"int3 webgl_bitfieldInsert_emu(int3 base, int3 insert, int offset, int bits)\n" "int3 bitfieldInsert_emu(int3 base, int3 insert, int offset, int bits)\n"
"{\n" "{\n"
" if (offset < 0 || bits <= 0 || offset >= 32 || bits > 32 || offset + bits > 32)\n" " if (offset < 0 || bits <= 0 || offset >= 32 || bits > 32 || offset + bits > 32)\n"
" {\n" " {\n"
...@@ -779,7 +779,7 @@ constexpr FunctionPair g_hlslFunctions[] = { ...@@ -779,7 +779,7 @@ constexpr FunctionPair g_hlslFunctions[] = {
" return asint(resultUnsigned);\n" " return asint(resultUnsigned);\n"
"}\n"}, "}\n"},
{{EOpBitfieldInsert, ParamType::Int4, ParamType::Int4, ParamType::Int1, ParamType::Int1}, {{EOpBitfieldInsert, ParamType::Int4, ParamType::Int4, ParamType::Int1, ParamType::Int1},
"int4 webgl_bitfieldInsert_emu(int4 base, int4 insert, int offset, int bits)\n" "int4 bitfieldInsert_emu(int4 base, int4 insert, int offset, int bits)\n"
"{\n" "{\n"
" if (offset < 0 || bits <= 0 || offset >= 32 || bits > 32 || offset + bits > 32)\n" " if (offset < 0 || bits <= 0 || offset >= 32 || bits > 32 || offset + bits > 32)\n"
" {\n" " {\n"
...@@ -793,49 +793,49 @@ constexpr FunctionPair g_hlslFunctions[] = { ...@@ -793,49 +793,49 @@ constexpr FunctionPair g_hlslFunctions[] = {
" return asint(resultUnsigned);\n" " return asint(resultUnsigned);\n"
"}\n"}, "}\n"},
{{EOpUaddCarry, ParamType::Uint1, ParamType::Uint1, ParamType::Uint1}, {{EOpUaddCarry, ParamType::Uint1, ParamType::Uint1, ParamType::Uint1},
"uint webgl_uaddCarry_emu(uint x, uint y, out uint carry)\n" "uint uaddCarry_emu(uint x, uint y, out uint carry)\n"
"{\n" "{\n"
" carry = uint(x > (0xffffffffu - y));\n" " carry = uint(x > (0xffffffffu - y));\n"
" return x + y;\n" " return x + y;\n"
"}\n"}, "}\n"},
{{EOpUaddCarry, ParamType::Uint2, ParamType::Uint2, ParamType::Uint2}, {{EOpUaddCarry, ParamType::Uint2, ParamType::Uint2, ParamType::Uint2},
"uint2 webgl_uaddCarry_emu(uint2 x, uint2 y, out uint2 carry)\n" "uint2 uaddCarry_emu(uint2 x, uint2 y, out uint2 carry)\n"
"{\n" "{\n"
" carry = uint2(x > (0xffffffffu - y));\n" " carry = uint2(x > (0xffffffffu - y));\n"
" return x + y;\n" " return x + y;\n"
"}\n"}, "}\n"},
{{EOpUaddCarry, ParamType::Uint3, ParamType::Uint3, ParamType::Uint3}, {{EOpUaddCarry, ParamType::Uint3, ParamType::Uint3, ParamType::Uint3},
"uint3 webgl_uaddCarry_emu(uint3 x, uint3 y, out uint3 carry)\n" "uint3 uaddCarry_emu(uint3 x, uint3 y, out uint3 carry)\n"
"{\n" "{\n"
" carry = uint3(x > (0xffffffffu - y));\n" " carry = uint3(x > (0xffffffffu - y));\n"
" return x + y;\n" " return x + y;\n"
"}\n"}, "}\n"},
{{EOpUaddCarry, ParamType::Uint4, ParamType::Uint4, ParamType::Uint4}, {{EOpUaddCarry, ParamType::Uint4, ParamType::Uint4, ParamType::Uint4},
"uint4 webgl_uaddCarry_emu(uint4 x, uint4 y, out uint4 carry)\n" "uint4 uaddCarry_emu(uint4 x, uint4 y, out uint4 carry)\n"
"{\n" "{\n"
" carry = uint4(x > (0xffffffffu - y));\n" " carry = uint4(x > (0xffffffffu - y));\n"
" return x + y;\n" " return x + y;\n"
"}\n"}, "}\n"},
{{EOpUsubBorrow, ParamType::Uint1, ParamType::Uint1, ParamType::Uint1}, {{EOpUsubBorrow, ParamType::Uint1, ParamType::Uint1, ParamType::Uint1},
"uint webgl_usubBorrow_emu(uint x, uint y, out uint borrow)\n" "uint usubBorrow_emu(uint x, uint y, out uint borrow)\n"
"{\n" "{\n"
" borrow = uint(x < y);\n" " borrow = uint(x < y);\n"
" return x - y;\n" " return x - y;\n"
"}\n"}, "}\n"},
{{EOpUsubBorrow, ParamType::Uint2, ParamType::Uint2, ParamType::Uint2}, {{EOpUsubBorrow, ParamType::Uint2, ParamType::Uint2, ParamType::Uint2},
"uint2 webgl_usubBorrow_emu(uint2 x, uint2 y, out uint2 borrow)\n" "uint2 usubBorrow_emu(uint2 x, uint2 y, out uint2 borrow)\n"
"{\n" "{\n"
" borrow = uint2(x < y);\n" " borrow = uint2(x < y);\n"
" return x - y;\n" " return x - y;\n"
"}\n"}, "}\n"},
{{EOpUsubBorrow, ParamType::Uint3, ParamType::Uint3, ParamType::Uint3}, {{EOpUsubBorrow, ParamType::Uint3, ParamType::Uint3, ParamType::Uint3},
"uint3 webgl_usubBorrow_emu(uint3 x, uint3 y, out uint3 borrow)\n" "uint3 usubBorrow_emu(uint3 x, uint3 y, out uint3 borrow)\n"
"{\n" "{\n"
" borrow = uint3(x < y);\n" " borrow = uint3(x < y);\n"
" return x - y;\n" " return x - y;\n"
"}\n"}, "}\n"},
{{EOpUsubBorrow, ParamType::Uint4, ParamType::Uint4, ParamType::Uint4}, {{EOpUsubBorrow, ParamType::Uint4, ParamType::Uint4, ParamType::Uint4},
"uint4 webgl_usubBorrow_emu(uint4 x, uint4 y, out uint4 borrow)\n" "uint4 usubBorrow_emu(uint4 x, uint4 y, out uint4 borrow)\n"
"{\n" "{\n"
" borrow = uint4(x < y);\n" " borrow = uint4(x < y);\n"
" return x - y;\n" " return x - y;\n"
......
...@@ -105,7 +105,7 @@ def gen_emulated_function(data): ...@@ -105,7 +105,7 @@ def gen_emulated_function(data):
if 'comment' in data: if 'comment' in data:
func += "".join([ "// " + line + "\n" for line in data['comment'] ]) func += "".join([ "// " + line + "\n" for line in data['comment'] ])
sig = data['return_type'] + ' webgl_' + data['op'] + '_emu(' + ', '.join(data['args']) + ')' sig = data['return_type'] + ' ' + data['op'] + '_emu(' + ', '.join(data['args']) + ')'
body = [ sig, '{' ] + [' ' + line for line in data['body']] + ['}'] body = [ sig, '{' ] + [' ' + line for line in data['body']] + ['}']
func += "{\n" func += "{\n"
......
...@@ -720,7 +720,7 @@ TEST_F(DebugShaderPrecisionTest, BuiltInMathFunctionRounding) ...@@ -720,7 +720,7 @@ TEST_F(DebugShaderPrecisionTest, BuiltInMathFunctionRounding)
ASSERT_TRUE(foundInHLSLCode("v6 = angle_frm(asin(angle_frm(_u1)))")); ASSERT_TRUE(foundInHLSLCode("v6 = angle_frm(asin(angle_frm(_u1)))"));
ASSERT_TRUE(foundInHLSLCode("v7 = angle_frm(acos(angle_frm(_u1)))")); ASSERT_TRUE(foundInHLSLCode("v7 = angle_frm(acos(angle_frm(_u1)))"));
ASSERT_TRUE(foundInHLSLCode("v8 = angle_frm(atan(angle_frm(_u1)))")); ASSERT_TRUE(foundInHLSLCode("v8 = angle_frm(atan(angle_frm(_u1)))"));
ASSERT_TRUE(foundInHLSLCode("v9 = angle_frm(webgl_atan_emu(angle_frm(_u1), angle_frm(_u2)))")); ASSERT_TRUE(foundInHLSLCode("v9 = angle_frm(atan_emu(angle_frm(_u1), angle_frm(_u2)))"));
ASSERT_TRUE(foundInHLSLCode("v10 = angle_frm(pow(angle_frm(_u1), angle_frm(_u2)))")); ASSERT_TRUE(foundInHLSLCode("v10 = angle_frm(pow(angle_frm(_u1), angle_frm(_u2)))"));
ASSERT_TRUE(foundInHLSLCode("v11 = angle_frm(exp(angle_frm(_u1)))")); ASSERT_TRUE(foundInHLSLCode("v11 = angle_frm(exp(angle_frm(_u1)))"));
ASSERT_TRUE(foundInHLSLCode("v12 = angle_frm(log(angle_frm(_u1)))")); ASSERT_TRUE(foundInHLSLCode("v12 = angle_frm(log(angle_frm(_u1)))"));
...@@ -733,8 +733,8 @@ TEST_F(DebugShaderPrecisionTest, BuiltInMathFunctionRounding) ...@@ -733,8 +733,8 @@ TEST_F(DebugShaderPrecisionTest, BuiltInMathFunctionRounding)
ASSERT_TRUE(foundInHLSLCode("v19 = angle_frm(floor(angle_frm(_u1)))")); ASSERT_TRUE(foundInHLSLCode("v19 = angle_frm(floor(angle_frm(_u1)))"));
ASSERT_TRUE(foundInHLSLCode("v20 = angle_frm(ceil(angle_frm(_u1)))")); ASSERT_TRUE(foundInHLSLCode("v20 = angle_frm(ceil(angle_frm(_u1)))"));
ASSERT_TRUE(foundInHLSLCode("v21 = angle_frm(frac(angle_frm(_u1)))")); ASSERT_TRUE(foundInHLSLCode("v21 = angle_frm(frac(angle_frm(_u1)))"));
ASSERT_TRUE(foundInHLSLCode("v22 = angle_frm(webgl_mod_emu(angle_frm(_u1), angle_frm(_uf)))")); ASSERT_TRUE(foundInHLSLCode("v22 = angle_frm(mod_emu(angle_frm(_u1), angle_frm(_uf)))"));
ASSERT_TRUE(foundInHLSLCode("v23 = angle_frm(webgl_mod_emu(angle_frm(_u1), angle_frm(_u2)))")); ASSERT_TRUE(foundInHLSLCode("v23 = angle_frm(mod_emu(angle_frm(_u1), angle_frm(_u2)))"));
ASSERT_TRUE(foundInHLSLCode("v24 = angle_frm(min(angle_frm(_u1), angle_frm(_uf)))")); ASSERT_TRUE(foundInHLSLCode("v24 = angle_frm(min(angle_frm(_u1), angle_frm(_uf)))"));
ASSERT_TRUE(foundInHLSLCode("v25 = angle_frm(min(angle_frm(_u1), angle_frm(_u2)))")); ASSERT_TRUE(foundInHLSLCode("v25 = angle_frm(min(angle_frm(_u1), angle_frm(_u2)))"));
ASSERT_TRUE(foundInHLSLCode("v26 = angle_frm(max(angle_frm(_u1), angle_frm(_uf)))")); ASSERT_TRUE(foundInHLSLCode("v26 = angle_frm(max(angle_frm(_u1), angle_frm(_uf)))"));
...@@ -755,7 +755,7 @@ TEST_F(DebugShaderPrecisionTest, BuiltInMathFunctionRounding) ...@@ -755,7 +755,7 @@ TEST_F(DebugShaderPrecisionTest, BuiltInMathFunctionRounding)
"v35 = angle_frm(smoothstep(angle_frm(_uf), angle_frm(_uf2), angle_frm(_u1)))")); "v35 = angle_frm(smoothstep(angle_frm(_uf), angle_frm(_uf2), angle_frm(_u1)))"));
ASSERT_TRUE(foundInHLSLCode("v36 = angle_frm(normalize(angle_frm(_u1)))")); ASSERT_TRUE(foundInHLSLCode("v36 = angle_frm(normalize(angle_frm(_u1)))"));
ASSERT_TRUE(foundInHLSLCode( ASSERT_TRUE(foundInHLSLCode(
"v37 = angle_frm(webgl_faceforward_emu(angle_frm(_u1), angle_frm(_u2), angle_frm(_u3)))")); "v37 = angle_frm(faceforward_emu(angle_frm(_u1), angle_frm(_u2), angle_frm(_u3)))"));
ASSERT_TRUE(foundInHLSLCode("v38 = angle_frm(reflect(angle_frm(_u1), angle_frm(_u2)))")); ASSERT_TRUE(foundInHLSLCode("v38 = angle_frm(reflect(angle_frm(_u1), angle_frm(_u2)))"));
ASSERT_TRUE(foundInHLSLCode( ASSERT_TRUE(foundInHLSLCode(
"v39 = angle_frm(refract(angle_frm(_u1), angle_frm(_u2), angle_frm(_uf)))")); "v39 = angle_frm(refract(angle_frm(_u1), angle_frm(_u2), angle_frm(_uf)))"));
......
...@@ -36,7 +36,7 @@ TEST_F(PackUnpackTest, PackSnorm2x16Emulation) ...@@ -36,7 +36,7 @@ TEST_F(PackUnpackTest, PackSnorm2x16Emulation)
" fragColor = vec4(0.0);\n" " fragColor = vec4(0.0);\n"
"}\n"; "}\n";
compile(shaderString); compile(shaderString);
ASSERT_TRUE(foundInCode("uint webgl_packSnorm2x16_emu(vec2 v)")); ASSERT_TRUE(foundInCode("uint packSnorm2x16_emu(vec2 v)"));
} }
// Check if UnpackSnorm2x16 Emulation for GLSL < 4.2 compile correctly. // Check if UnpackSnorm2x16 Emulation for GLSL < 4.2 compile correctly.
...@@ -52,7 +52,7 @@ TEST_F(PackUnpackTest, UnpackSnorm2x16Emulation) ...@@ -52,7 +52,7 @@ TEST_F(PackUnpackTest, UnpackSnorm2x16Emulation)
" fragColor = vec4(0.0);\n" " fragColor = vec4(0.0);\n"
"}\n"; "}\n";
compile(shaderString); compile(shaderString);
ASSERT_TRUE(foundInCode("vec2 webgl_unpackSnorm2x16_emu(uint u)")); ASSERT_TRUE(foundInCode("vec2 unpackSnorm2x16_emu(uint u)"));
} }
// Check if PackUnorm2x16 Emulation for GLSL < 4.1 compiles correctly. // Check if PackUnorm2x16 Emulation for GLSL < 4.1 compiles correctly.
...@@ -68,7 +68,7 @@ TEST_F(PackUnpackTest, PackUnorm2x16Emulation) ...@@ -68,7 +68,7 @@ TEST_F(PackUnpackTest, PackUnorm2x16Emulation)
" fragColor = vec4(0.0);\n" " fragColor = vec4(0.0);\n"
"}\n"; "}\n";
compile(shaderString); compile(shaderString);
ASSERT_TRUE(foundInCode("uint webgl_packUnorm2x16_emu(vec2 v)")); ASSERT_TRUE(foundInCode("uint packUnorm2x16_emu(vec2 v)"));
} }
// Check if UnpackSnorm2x16 Emulation for GLSL < 4.1 compiles correctly. // Check if UnpackSnorm2x16 Emulation for GLSL < 4.1 compiles correctly.
...@@ -84,7 +84,7 @@ TEST_F(PackUnpackTest, UnpackUnorm2x16Emulation) ...@@ -84,7 +84,7 @@ TEST_F(PackUnpackTest, UnpackUnorm2x16Emulation)
" fragColor = vec4(0.0);\n" " fragColor = vec4(0.0);\n"
"}\n"; "}\n";
compile(shaderString); compile(shaderString);
ASSERT_TRUE(foundInCode("vec2 webgl_unpackUnorm2x16_emu(uint u)")); ASSERT_TRUE(foundInCode("vec2 unpackUnorm2x16_emu(uint u)"));
} }
// Check if PackHalf2x16 Emulation for GLSL < 4.2 compiles correctly. // Check if PackHalf2x16 Emulation for GLSL < 4.2 compiles correctly.
...@@ -100,7 +100,7 @@ TEST_F(PackUnpackTest, PackHalf2x16Emulation) ...@@ -100,7 +100,7 @@ TEST_F(PackUnpackTest, PackHalf2x16Emulation)
" fragColor = vec4(0.0);\n" " fragColor = vec4(0.0);\n"
"}\n"; "}\n";
compile(shaderString); compile(shaderString);
ASSERT_TRUE(foundInCode("uint webgl_packHalf2x16_emu(vec2 v)")); ASSERT_TRUE(foundInCode("uint packHalf2x16_emu(vec2 v)"));
} }
// Check if UnpackHalf2x16 Emulation for GLSL < 4.2 compiles correctly. // Check if UnpackHalf2x16 Emulation for GLSL < 4.2 compiles correctly.
...@@ -116,7 +116,7 @@ TEST_F(PackUnpackTest, UnpackHalf2x16Emulation) ...@@ -116,7 +116,7 @@ TEST_F(PackUnpackTest, UnpackHalf2x16Emulation)
" fragColor = vec4(0.0);\n" " fragColor = vec4(0.0);\n"
"}\n"; "}\n";
compile(shaderString); compile(shaderString);
ASSERT_TRUE(foundInCode("vec2 webgl_unpackHalf2x16_emu(uint u)")); ASSERT_TRUE(foundInCode("vec2 unpackHalf2x16_emu(uint u)"));
} }
} // namespace } // namespace
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