Commit 01c796ac by Geoff Lang

Revert "Emulate the pack/unpack functions for unorms."

Causing MSAN failures on Linux. This reverts commit 1915652e. Change-Id: Ib23bec16eab22288930be0b41186e54cd8d1f921 Reviewed-on: https://chromium-review.googlesource.com/287127Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Tested-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent a7c01c62
...@@ -42,29 +42,6 @@ void InitBuiltInFunctionEmulatorForGLSLWorkarounds(BuiltInFunctionEmulator *emu, ...@@ -42,29 +42,6 @@ void InitBuiltInFunctionEmulatorForGLSLWorkarounds(BuiltInFunctionEmulator *emu,
void InitBuiltInFunctionEmulatorForGLSLMissingFunctions(BuiltInFunctionEmulator *emu, sh::GLenum shaderType, void InitBuiltInFunctionEmulatorForGLSLMissingFunctions(BuiltInFunctionEmulator *emu, sh::GLenum shaderType,
int targetGLSLVersion) int targetGLSLVersion)
{ {
// Emulate packUnorm2x16 and unpackUnorm2x16 (GLSL 4.10)
if (targetGLSLVersion < GLSL_VERSION_410)
{
const TType *float2 = TCache::getType(EbtFloat, 2);
const TType *uint1 = TCache::getType(EbtUInt);
emu->addEmulatedFunction(EOpPackUnorm2x16, float2,
"uint webgl_packUnorm2x16_emu(vec2 v)\n"
"{\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"
" return uint((y << 16) | (x & 0xFFFF));\n"
"}\n");
emu->addEmulatedFunction(EOpUnpackUnorm2x16, uint1,
"vec2 webgl_unpackUnorm2x16_emu(uint u)\n"
"{\n"
" float x = float(u & 0xFFFFu) / 65535.0;\n"
" float y = float(u >> 16) / 65535.0;\n"
" return vec2(x, y);\n"
"}\n");
}
// Emulate packSnorm2x16, packHalf2x16, unpackSnorm2x16, and unpackHalf2x16 (GLSL 4.20) // Emulate packSnorm2x16, packHalf2x16, unpackSnorm2x16, and unpackHalf2x16 (GLSL 4.20)
// by using floatBitsToInt, floatBitsToUint, intBitsToFloat, and uintBitsToFloat (GLSL 3.30). // by using floatBitsToInt, floatBitsToUint, intBitsToFloat, and uintBitsToFloat (GLSL 3.30).
if (targetGLSLVersion >= GLSL_VERSION_330 && targetGLSLVersion < GLSL_VERSION_420) if (targetGLSLVersion >= GLSL_VERSION_330 && targetGLSLVersion < GLSL_VERSION_420)
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
// found in the LICENSE file. // found in the LICENSE file.
// //
// Pack_Unpack_test.cpp: // Pack_Unpack_test.cpp:
// Tests for the emulating pack_unpack functions for GLSL. // Tests for the emulating pack_unpack functions for GLSL 4.1.
// //
#include "angle_gl.h" #include "angle_gl.h"
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
namespace namespace
{ {
class PackUnpackTest : public testing::TestWithParam<ShShaderOutput> class PackUnpackTest : public testing::Test
{ {
public: public:
PackUnpackTest() {} PackUnpackTest() {}
...@@ -25,15 +25,15 @@ class PackUnpackTest : public testing::TestWithParam<ShShaderOutput> ...@@ -25,15 +25,15 @@ class PackUnpackTest : public testing::TestWithParam<ShShaderOutput>
{ {
std::string infoLog; std::string infoLog;
bool compilationSuccess = compileTestShader(GL_FRAGMENT_SHADER, SH_GLES3_SPEC, bool compilationSuccess = compileTestShader(GL_FRAGMENT_SHADER, SH_GLES3_SPEC,
GetParam(), SH_GLSL_410_CORE_OUTPUT,
shaderString, &mGLSLCode, &infoLog); shaderString, &mGLSLCode, &infoLog);
if (!compilationSuccess) if (!compilationSuccess)
{ {
FAIL() << "Shader compilation into GLSL failed " << infoLog; FAIL() << "Shader compilation into GLSL 4.1 failed " << infoLog;
} }
} }
bool foundInGLSLCode(const char* stringToFind) const bool foundInGLSLCode(const char* stringToFind)
{ {
return mGLSLCode.find(stringToFind) != std::string::npos; return mGLSLCode.find(stringToFind) != std::string::npos;
} }
...@@ -42,8 +42,8 @@ class PackUnpackTest : public testing::TestWithParam<ShShaderOutput> ...@@ -42,8 +42,8 @@ class PackUnpackTest : public testing::TestWithParam<ShShaderOutput>
std::string mGLSLCode; std::string mGLSLCode;
}; };
//Check if PackSnorm2x16 Emulation for GLSL < 4.2 compile correctly. //Check if PackSnorm2x16 Emulation for GLSL 4.1 compile correctly.
TEST_P(PackUnpackTest, PackSnorm2x16Emulation) TEST_F(PackUnpackTest, PackSnorm2x16Emulation)
{ {
const std::string &shaderString = const std::string &shaderString =
"#version 300 es\n" "#version 300 es\n"
...@@ -55,11 +55,11 @@ TEST_P(PackUnpackTest, PackSnorm2x16Emulation) ...@@ -55,11 +55,11 @@ TEST_P(PackUnpackTest, PackSnorm2x16Emulation)
" fragColor = vec4(0.0);\n" " fragColor = vec4(0.0);\n"
"}\n"; "}\n";
compile(shaderString); compile(shaderString);
ASSERT_EQ(GetParam() < SH_GLSL_420_CORE_OUTPUT, foundInGLSLCode("uint webgl_packSnorm2x16_emu(vec2 v)")); ASSERT_TRUE(foundInGLSLCode("uint webgl_packSnorm2x16_emu(vec2 v)"));
} }
//Check if UnpackSnorm2x16 Emulation for GLSL < 4.2 compile correctly. //Check if UnpackSnorm2x16 Emulation for GLSL 4.1 compile correctly.
TEST_P(PackUnpackTest, UnpackSnorm2x16Emulation) TEST_F(PackUnpackTest, UnpackSnorm2x16Emulation)
{ {
const std::string &shaderString = const std::string &shaderString =
"#version 300 es\n" "#version 300 es\n"
...@@ -71,43 +71,11 @@ TEST_P(PackUnpackTest, UnpackSnorm2x16Emulation) ...@@ -71,43 +71,11 @@ TEST_P(PackUnpackTest, UnpackSnorm2x16Emulation)
" fragColor = vec4(0.0);\n" " fragColor = vec4(0.0);\n"
"}\n"; "}\n";
compile(shaderString); compile(shaderString);
ASSERT_EQ(GetParam() < SH_GLSL_420_CORE_OUTPUT, foundInGLSLCode("vec2 webgl_unpackSnorm2x16_emu(uint u)")); ASSERT_TRUE(foundInGLSLCode("vec2 webgl_unpackSnorm2x16_emu(uint u)"));
} }
//Check if PackUnorm2x16 Emulation for GLSL < 4.1 compiles correctly. //Check if PackHalf2x16 Emulation for GLSL 4.1 compile correctly.
TEST_P(PackUnpackTest, PackUnorm2x16Emulation) TEST_F(PackUnpackTest, PackHalf2x16Emulation)
{
const std::string &shaderString =
"#version 300 es\n"
"precision mediump float;\n"
"layout(location = 0) out mediump vec4 fragColor;"
"void main() {\n"
" vec2 v;\n"
" uint u = packUnorm2x16(v);\n"
" fragColor = vec4(0.0);\n"
"}\n";
compile(shaderString);
ASSERT_EQ(GetParam() < SH_GLSL_410_CORE_OUTPUT, foundInGLSLCode("uint webgl_packUnorm2x16_emu(vec2 v)"));
}
//Check if UnpackSnorm2x16 Emulation for GLSL < 4.1 compiles correctly.
TEST_P(PackUnpackTest, UnpackUnorm2x16Emulation)
{
const std::string &shaderString =
"#version 300 es\n"
"precision mediump float;\n"
"layout(location = 0) out mediump vec4 fragColor;"
"void main() {\n"
" uint u;\n"
" vec2 v=unpackUnorm2x16(u);\n"
" fragColor = vec4(0.0);\n"
"}\n";
compile(shaderString);
ASSERT_EQ(GetParam() < SH_GLSL_410_CORE_OUTPUT, foundInGLSLCode("vec2 webgl_unpackUnorm2x16_emu(uint u)"));
}
//Check if PackHalf2x16 Emulation for GLSL < 4.2 compiles correctly.
TEST_P(PackUnpackTest, PackHalf2x16Emulation)
{ {
const std::string &shaderString = const std::string &shaderString =
"#version 300 es\n" "#version 300 es\n"
...@@ -119,11 +87,11 @@ TEST_P(PackUnpackTest, PackHalf2x16Emulation) ...@@ -119,11 +87,11 @@ TEST_P(PackUnpackTest, PackHalf2x16Emulation)
" fragColor = vec4(0.0);\n" " fragColor = vec4(0.0);\n"
"}\n"; "}\n";
compile(shaderString); compile(shaderString);
ASSERT_EQ(GetParam() < SH_GLSL_420_CORE_OUTPUT, foundInGLSLCode("uint webgl_packHalf2x16_emu(vec2 v)")); ASSERT_TRUE(foundInGLSLCode("uint webgl_packHalf2x16_emu(vec2 v)"));
} }
//Check if UnpackHalf2x16 Emulation for GLSL < 4.2 compiles correctly. //Check if UnpackHalf2x16 Emulation for GLSL 4.1 compile correctly.
TEST_P(PackUnpackTest, UnpackHalf2x16Emulation) TEST_F(PackUnpackTest, UnpackHalf2x16Emulation)
{ {
const std::string &shaderString = const std::string &shaderString =
"#version 300 es\n" "#version 300 es\n"
...@@ -135,13 +103,7 @@ TEST_P(PackUnpackTest, UnpackHalf2x16Emulation) ...@@ -135,13 +103,7 @@ TEST_P(PackUnpackTest, UnpackHalf2x16Emulation)
" fragColor = vec4(0.0);\n" " fragColor = vec4(0.0);\n"
"}\n"; "}\n";
compile(shaderString); compile(shaderString);
ASSERT_EQ(GetParam() < SH_GLSL_420_CORE_OUTPUT, foundInGLSLCode("vec2 webgl_unpackHalf2x16_emu(uint u)")); ASSERT_TRUE(foundInGLSLCode("vec2 webgl_unpackHalf2x16_emu(uint u)"));
} }
INSTANTIATE_TEST_CASE_P(, PackUnpackTest,
testing::Values(SH_GLSL_330_CORE_OUTPUT, SH_GLSL_400_CORE_OUTPUT,
SH_GLSL_410_CORE_OUTPUT, SH_GLSL_420_CORE_OUTPUT,
SH_GLSL_430_CORE_OUTPUT, SH_GLSL_440_CORE_OUTPUT,
SH_GLSL_450_CORE_OUTPUT));
} // namespace } // namespace
...@@ -59,21 +59,6 @@ class PackUnpackTest : public ANGLETest ...@@ -59,21 +59,6 @@ class PackUnpackTest : public ANGLETest
); );
// Fragment Shader source // Fragment Shader source
const std::string uNormFS = SHADER_SOURCE
( #version 300 es\n
precision mediump float;
uniform mediump vec2 v;
layout(location = 0) out mediump vec4 fragColor;
void main()
{
uint u = packUnorm2x16(v);
vec2 r = unpackUnorm2x16(u);
fragColor = vec4(r, 0.0, 1.0);
}
);
// Fragment Shader source
const std::string halfFS = SHADER_SOURCE const std::string halfFS = SHADER_SOURCE
( #version 300 es\n ( #version 300 es\n
precision mediump float; precision mediump float;
...@@ -89,9 +74,8 @@ class PackUnpackTest : public ANGLETest ...@@ -89,9 +74,8 @@ class PackUnpackTest : public ANGLETest
); );
mSNormProgram = CompileProgram(vs, sNormFS); mSNormProgram = CompileProgram(vs, sNormFS);
mUNormProgram = CompileProgram(vs, uNormFS);
mHalfProgram = CompileProgram(vs, halfFS); mHalfProgram = CompileProgram(vs, halfFS);
if (mSNormProgram == 0 || mUNormProgram == 0|| mHalfProgram == 0) if (mSNormProgram == 0 || mHalfProgram == 0)
{ {
FAIL() << "shader compilation failed."; FAIL() << "shader compilation failed.";
} }
...@@ -115,7 +99,6 @@ class PackUnpackTest : public ANGLETest ...@@ -115,7 +99,6 @@ class PackUnpackTest : public ANGLETest
glDeleteTextures(1, &mOffscreenTexture2D); glDeleteTextures(1, &mOffscreenTexture2D);
glDeleteFramebuffers(1, &mOffscreenFramebuffer); glDeleteFramebuffers(1, &mOffscreenFramebuffer);
glDeleteProgram(mSNormProgram); glDeleteProgram(mSNormProgram);
glDeleteProgram(mUNormProgram);
glDeleteProgram(mHalfProgram); glDeleteProgram(mHalfProgram);
ANGLETest::TearDown(); ANGLETest::TearDown();
...@@ -148,7 +131,6 @@ class PackUnpackTest : public ANGLETest ...@@ -148,7 +131,6 @@ class PackUnpackTest : public ANGLETest
} }
GLuint mSNormProgram; GLuint mSNormProgram;
GLuint mUNormProgram;
GLuint mHalfProgram; GLuint mHalfProgram;
GLuint mOffscreenFramebuffer; GLuint mOffscreenFramebuffer;
GLuint mOffscreenTexture2D; GLuint mOffscreenTexture2D;
...@@ -164,16 +146,6 @@ TEST_P(PackUnpackTest, PackUnpackSnormNormal) ...@@ -164,16 +146,6 @@ TEST_P(PackUnpackTest, PackUnpackSnormNormal)
compareBeforeAfter(mSNormProgram, 1.0f, -0.00392f); compareBeforeAfter(mSNormProgram, 1.0f, -0.00392f);
} }
// Test the correctness of packSnorm2x16 and unpackSnorm2x16 functions calculating normal floating numbers.
TEST_P(PackUnpackTest, PackUnpackUnormNormal)
{
// Expect the shader to output the same value as the input
compareBeforeAfter(mUNormProgram, 0.5f, 0.2f, 0.5f, 0.2f);
compareBeforeAfter(mUNormProgram, 0.35f, 0.75f, 0.35f, 0.75f);
compareBeforeAfter(mUNormProgram, 0.00392f, 0.99215f, 0.00392f, 0.99215f);
compareBeforeAfter(mUNormProgram, 1.0f, 0.00392f, 1.0f, 0.00392f);
}
// Test the correctness of packHalf2x16 and unpackHalf2x16 functions calculating normal floating numbers. // Test the correctness of packHalf2x16 and unpackHalf2x16 functions calculating normal floating numbers.
TEST_P(PackUnpackTest, PackUnpackHalfNormal) TEST_P(PackUnpackTest, PackUnpackHalfNormal)
{ {
...@@ -191,14 +163,6 @@ TEST_P(PackUnpackTest, PackUnpackSnormSubnormal) ...@@ -191,14 +163,6 @@ TEST_P(PackUnpackTest, PackUnpackSnormSubnormal)
compareBeforeAfter(mSNormProgram, 0.00001f, -0.00001f); compareBeforeAfter(mSNormProgram, 0.00001f, -0.00001f);
} }
// Test the correctness of packUnorm2x16 and unpackUnorm2x16 functions calculating subnormal floating numbers.
TEST_P(PackUnpackTest, PackUnpackUnormSubnormal)
{
// Expect the shader to output the same value as the input for positive numbers and clamp
// to [0, 1]
compareBeforeAfter(mUNormProgram, 0.00001f, -0.00001f, 0.00001f, 0.0f);
}
// Test the correctness of packHalf2x16 and unpackHalf2x16 functions calculating subnormal floating numbers. // Test the correctness of packHalf2x16 and unpackHalf2x16 functions calculating subnormal floating numbers.
TEST_P(PackUnpackTest, PackUnpackHalfSubnormal) TEST_P(PackUnpackTest, PackUnpackHalfSubnormal)
{ {
...@@ -213,12 +177,6 @@ TEST_P(PackUnpackTest, PackUnpackSnormZero) ...@@ -213,12 +177,6 @@ TEST_P(PackUnpackTest, PackUnpackSnormZero)
compareBeforeAfter(mSNormProgram, 0.00000f, -0.00000f); compareBeforeAfter(mSNormProgram, 0.00000f, -0.00000f);
} }
// Test the correctness of packUnorm2x16 and unpackUnorm2x16 functions calculating zero floating numbers.
TEST_P(PackUnpackTest, PackUnpackUnormZero)
{
compareBeforeAfter(mUNormProgram, 0.00000f, -0.00000f, 0.00000f, -0.00000f);
}
// Test the correctness of packHalf2x16 and unpackHalf2x16 functions calculating zero floating numbers. // Test the correctness of packHalf2x16 and unpackHalf2x16 functions calculating zero floating numbers.
TEST_P(PackUnpackTest, PackUnpackHalfZero) TEST_P(PackUnpackTest, PackUnpackHalfZero)
{ {
...@@ -226,13 +184,6 @@ TEST_P(PackUnpackTest, PackUnpackHalfZero) ...@@ -226,13 +184,6 @@ TEST_P(PackUnpackTest, PackUnpackHalfZero)
compareBeforeAfter(mHalfProgram, 0.00000f, -0.00000f); compareBeforeAfter(mHalfProgram, 0.00000f, -0.00000f);
} }
// Test the correctness of packUnorm2x16 and unpackUnorm2x16 functions calculating overflow floating numbers.
TEST_P(PackUnpackTest, PackUnpackUnormOverflow)
{
// Expect the shader to clamp the input to [0, 1]
compareBeforeAfter(mUNormProgram, 67000.0f, -67000.0f, 1.0f, 0.0f);
}
// Test the correctness of packSnorm2x16 and unpackSnorm2x16 functions calculating overflow floating numbers. // Test the correctness of packSnorm2x16 and unpackSnorm2x16 functions calculating overflow floating numbers.
TEST_P(PackUnpackTest, PackUnpackSnormOverflow) TEST_P(PackUnpackTest, PackUnpackSnormOverflow)
{ {
......
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