diff options
Diffstat (limited to 'src/tests/gl_tests')
-rw-r--r-- | src/tests/gl_tests/DrawBaseVertexBaseInstanceTest.cpp | 35 | ||||
-rw-r--r-- | src/tests/gl_tests/ExternalBufferTest.cpp | 30 | ||||
-rw-r--r-- | src/tests/gl_tests/GLSLTest.cpp | 39 | ||||
-rw-r--r-- | src/tests/gl_tests/MultiDrawTest.cpp | 71 | ||||
-rw-r--r-- | src/tests/gl_tests/PackUnpackTest.cpp | 3 | ||||
-rw-r--r-- | src/tests/gl_tests/VertexAttributeTest.cpp | 7 | ||||
-rw-r--r-- | src/tests/gl_tests/WebGLReadOutsideFramebufferTest.cpp | 47 |
7 files changed, 141 insertions, 91 deletions
diff --git a/src/tests/gl_tests/DrawBaseVertexBaseInstanceTest.cpp b/src/tests/gl_tests/DrawBaseVertexBaseInstanceTest.cpp index 63a9bddcf8..ea26fcc09a 100644 --- a/src/tests/gl_tests/DrawBaseVertexBaseInstanceTest.cpp +++ b/src/tests/gl_tests/DrawBaseVertexBaseInstanceTest.cpp @@ -1181,29 +1181,22 @@ TEST_P(DrawBaseInstanceTest, DrawElementsInstancedBaseVertexBaseInstance) checkDrawResult(true, true); } -const angle::PlatformParameters platforms[] = { - ES3_D3D11(), ES3_METAL(), ES3_OPENGL(), ES3_OPENGLES(), ES3_VULKAN(), -}; - GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(DrawBaseVertexBaseInstanceTest); -INSTANTIATE_TEST_SUITE_P( - , + +ANGLE_INSTANTIATE_TEST_COMBINE_3( DrawBaseVertexBaseInstanceTest, - testing::Combine( - testing::ValuesIn(::angle::FilterTestParams(platforms, ArraySize(platforms))), - testing::Values(BaseVertexOption::NoBaseVertex, BaseVertexOption::UseBaseVertex), - testing::Values(BaseInstanceOption::NoBaseInstance, BaseInstanceOption::UseBaseInstance), - testing::Values(BufferDataUsageOption::StaticDraw, BufferDataUsageOption::DynamicDraw)), - PrintToStringParamName()); - -INSTANTIATE_TEST_SUITE_P( - , + PrintToStringParamName(), + testing::Values(BaseVertexOption::NoBaseVertex, BaseVertexOption::UseBaseVertex), + testing::Values(BaseInstanceOption::NoBaseInstance, BaseInstanceOption::UseBaseInstance), + testing::Values(BufferDataUsageOption::StaticDraw, BufferDataUsageOption::DynamicDraw), + ANGLE_ALL_TEST_PLATFORMS_ES3); + +ANGLE_INSTANTIATE_TEST_COMBINE_3( DrawBaseInstanceTest, - testing::Combine( - testing::ValuesIn(::angle::FilterTestParams(platforms, ArraySize(platforms))), - testing::Values(BaseVertexOption::NoBaseVertex, BaseVertexOption::UseBaseVertex), - testing::Values(BaseInstanceOption::NoBaseInstance, BaseInstanceOption::UseBaseInstance), - testing::Values(BufferDataUsageOption::StaticDraw, BufferDataUsageOption::DynamicDraw)), - PrintToStringParamName()); + PrintToStringParamName(), + testing::Values(BaseVertexOption::NoBaseVertex, BaseVertexOption::UseBaseVertex), + testing::Values(BaseInstanceOption::NoBaseInstance, BaseInstanceOption::UseBaseInstance), + testing::Values(BufferDataUsageOption::StaticDraw, BufferDataUsageOption::DynamicDraw), + ANGLE_ALL_TEST_PLATFORMS_ES3); } // namespace diff --git a/src/tests/gl_tests/ExternalBufferTest.cpp b/src/tests/gl_tests/ExternalBufferTest.cpp index 465f7d66ae..59720c9cb9 100644 --- a/src/tests/gl_tests/ExternalBufferTest.cpp +++ b/src/tests/gl_tests/ExternalBufferTest.cpp @@ -60,7 +60,10 @@ class ExternalBufferTestES31 : public ANGLETest<> // Need to grab the stride the implementation might have enforced AHardwareBuffer_describe(aHardwareBuffer, &aHardwareBufferDescription); - memcpy(mappedMemory, data, size); + if (data) + { + memcpy(mappedMemory, data, size); + } EXPECT_EQ(0, AHardwareBuffer_unlock(aHardwareBuffer, nullptr)); return aHardwareBuffer; @@ -345,6 +348,31 @@ TEST_P(ExternalBufferTestES31, MapBufferDoesNotCauseOrphaning) destroyAndroidHardwareBuffer(aHardwareBuffer); } +// Verify that create and destroy external buffer backed by an AHB doesn't leak AHB +TEST_P(ExternalBufferTestES31, BufferDoesNotLeakAHB) +{ + ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_EXT_external_buffer") || + !IsGLExtensionEnabled("GL_EXT_buffer_storage")); + + // Create and destroy 128M AHB backed buffer in a loop. If we leak AHB, it will fail due to AHB + // allocation failure before loop ends. + constexpr size_t kBufferSize = 128 * 1024 * 1024; + for (int loop = 0; loop < 1000; loop++) + { + // Create the AHB + AHardwareBuffer *aHardwareBuffer; + constexpr GLbitfield kFlags = GL_DYNAMIC_STORAGE_BIT_EXT; + aHardwareBuffer = createAndroidHardwareBuffer(kBufferSize, nullptr); + GLBuffer buffer; + glBindBuffer(GL_SHADER_STORAGE_BUFFER, buffer); + glBufferStorageExternalEXT(GL_SHADER_STORAGE_BUFFER, 0, kBufferSize, + eglGetNativeClientBufferANDROID(aHardwareBuffer), kFlags); + ASSERT_GL_NO_ERROR(); + // Delete the source AHB + destroyAndroidHardwareBuffer(aHardwareBuffer); + } +} + GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(ExternalBufferTestES31); ANGLE_INSTANTIATE_TEST_ES31(ExternalBufferTestES31); } // namespace angle diff --git a/src/tests/gl_tests/GLSLTest.cpp b/src/tests/gl_tests/GLSLTest.cpp index 7b6e70d168..b34db39c4a 100644 --- a/src/tests/gl_tests/GLSLTest.cpp +++ b/src/tests/gl_tests/GLSLTest.cpp @@ -9094,6 +9094,45 @@ void main() EXPECT_NE(compileResult, 0); } +// Test that packing of excessive 3-column variables does not overflow the count of 3-column +// variables in VariablePacker +TEST_P(WebGL2GLSLTest, ExcessiveMat3UniformPacking) +{ + std::ostringstream srcStream; + + srcStream << "#version 300 es\n"; + srcStream << "precision mediump float;\n"; + srcStream << "out vec4 finalColor;\n"; + srcStream << "in vec4 color;\n"; + srcStream << "uniform mat4 r[254];\n"; + + srcStream << "uniform mat3 "; + constexpr size_t kNumUniforms = 10000; + for (size_t i = 0; i < kNumUniforms; ++i) + { + if (i > 0) + { + srcStream << ", "; + } + srcStream << "m3a_" << i << "[256]"; + } + srcStream << ";\n"; + + srcStream << "void main(void) { finalColor = color; }\n"; + std::string src = std::move(srcStream).str(); + + GLuint shader = glCreateShader(GL_VERTEX_SHADER); + + const char *sourceArray[1] = {src.c_str()}; + GLint lengths[1] = {static_cast<GLint>(src.length())}; + glShaderSource(shader, 1, sourceArray, lengths); + glCompileShader(shader); + + GLint compileResult; + glGetShaderiv(shader, GL_COMPILE_STATUS, &compileResult); + EXPECT_EQ(compileResult, 0); +} + // Test that a varying with a flat qualifier that is used as an operand of a folded ternary operator // is handled correctly. TEST_P(GLSLTest_ES3, FlatVaryingUsedInFoldedTernary) diff --git a/src/tests/gl_tests/MultiDrawTest.cpp b/src/tests/gl_tests/MultiDrawTest.cpp index b827b9f539..b11d3e5357 100644 --- a/src/tests/gl_tests/MultiDrawTest.cpp +++ b/src/tests/gl_tests/MultiDrawTest.cpp @@ -178,8 +178,7 @@ varying vec4 color; void main() { int id = )" << (IsDrawIDTest() ? "gl_DrawID" : "0") - << ";" - << R"( + << ";" << R"( float quad_id = float(id / 2); float color_id = quad_id - (3.0 * floor(quad_id / 3.0)); if (color_id == 0.0) { @@ -1247,48 +1246,32 @@ TEST_P(MultiDrawNoInstancingSupportTest, InvalidOperation) EXPECT_GL_ERROR(GL_INVALID_OPERATION); } -const angle::PlatformParameters platforms[] = { - ES2_D3D9(), ES2_OPENGL(), ES2_OPENGLES(), ES2_VULKAN(), ES3_D3D11(), ES3_OPENGL(), - ES3_OPENGLES(), ES3_VULKAN(), ES3_VULKAN_SWIFTSHADER(), -}; - -const angle::PlatformParameters es2_platforms[] = { - ES2_D3D9(), ES2_OPENGL(), ES2_OPENGLES(), ES2_VULKAN(), ES2_VULKAN_SWIFTSHADER(), -}; - -const angle::PlatformParameters es3_platforms[] = { - ES3_D3D11(), ES3_OPENGL(), ES3_OPENGLES(), ES3_VULKAN(), ES3_VULKAN_SWIFTSHADER(), -}; - -INSTANTIATE_TEST_SUITE_P( - , - MultiDrawTest, - testing::Combine( - testing::ValuesIn(::angle::FilterTestParams(platforms, ArraySize(platforms))), - testing::Values(DrawIDOption::NoDrawID, DrawIDOption::UseDrawID), - testing::Values(InstancingOption::NoInstancing, InstancingOption::UseInstancing), - testing::Values(BufferDataUsageOption::StaticDraw, BufferDataUsageOption::DynamicDraw)), - PrintToStringParamName()); - -INSTANTIATE_TEST_SUITE_P( - , - MultiDrawNoInstancingSupportTest, - testing::Combine( - testing::ValuesIn(::angle::FilterTestParams(es2_platforms, ArraySize(es2_platforms))), - testing::Values(DrawIDOption::NoDrawID, DrawIDOption::UseDrawID), - testing::Values(InstancingOption::UseInstancing), - testing::Values(BufferDataUsageOption::StaticDraw, BufferDataUsageOption::DynamicDraw)), - PrintToStringParamName()); - -INSTANTIATE_TEST_SUITE_P( - , - MultiDrawTestES3, - testing::Combine( - testing::ValuesIn(::angle::FilterTestParams(es3_platforms, ArraySize(es3_platforms))), - testing::Values(DrawIDOption::NoDrawID, DrawIDOption::UseDrawID), - testing::Values(InstancingOption::NoInstancing, InstancingOption::UseInstancing), - testing::Values(BufferDataUsageOption::StaticDraw, BufferDataUsageOption::DynamicDraw)), - PrintToStringParamName()); +ANGLE_INSTANTIATE_TEST_COMBINE_3(MultiDrawTest, + PrintToStringParamName(), + testing::Values(DrawIDOption::NoDrawID, DrawIDOption::UseDrawID), + testing::Values(InstancingOption::NoInstancing, + InstancingOption::UseInstancing), + testing::Values(BufferDataUsageOption::StaticDraw, + BufferDataUsageOption::DynamicDraw), + ANGLE_ALL_TEST_PLATFORMS_ES2, + ANGLE_ALL_TEST_PLATFORMS_ES3); + +ANGLE_INSTANTIATE_TEST_COMBINE_3(MultiDrawNoInstancingSupportTest, + PrintToStringParamName(), + testing::Values(DrawIDOption::NoDrawID, DrawIDOption::UseDrawID), + testing::Values(InstancingOption::UseInstancing), + testing::Values(BufferDataUsageOption::StaticDraw, + BufferDataUsageOption::DynamicDraw), + ANGLE_ALL_TEST_PLATFORMS_ES2); + +ANGLE_INSTANTIATE_TEST_COMBINE_3(MultiDrawTestES3, + PrintToStringParamName(), + testing::Values(DrawIDOption::NoDrawID, DrawIDOption::UseDrawID), + testing::Values(InstancingOption::NoInstancing, + InstancingOption::UseInstancing), + testing::Values(BufferDataUsageOption::StaticDraw, + BufferDataUsageOption::DynamicDraw), + ANGLE_ALL_TEST_PLATFORMS_ES3); GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(MultiDrawIndirectTest); ANGLE_INSTANTIATE_TEST_ES31_AND(MultiDrawIndirectTest, diff --git a/src/tests/gl_tests/PackUnpackTest.cpp b/src/tests/gl_tests/PackUnpackTest.cpp index 853a9661b9..a4189ab20d 100644 --- a/src/tests/gl_tests/PackUnpackTest.cpp +++ b/src/tests/gl_tests/PackUnpackTest.cpp @@ -237,7 +237,6 @@ TEST_P(PackUnpackTest, PackUnpackSnormOverflow) compareBeforeAfter(mSNormProgram, 67000.0f, -67000.0f, 1.0f, -1.0f); } -// http://anglebug.com/4092 Not instantiating on other backends currently GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(PackUnpackTest); -ANGLE_INSTANTIATE_TEST(PackUnpackTest, ES3_OPENGL(), ES3_OPENGLES()); +ANGLE_INSTANTIATE_TEST_ES3(PackUnpackTest); } // namespace diff --git a/src/tests/gl_tests/VertexAttributeTest.cpp b/src/tests/gl_tests/VertexAttributeTest.cpp index 2443ac8395..a11d77d40c 100644 --- a/src/tests/gl_tests/VertexAttributeTest.cpp +++ b/src/tests/gl_tests/VertexAttributeTest.cpp @@ -1832,11 +1832,11 @@ TEST_P(VertexAttributeTestES3, DrawWithUnalignedData) constexpr char kVS[] = R"(#version 300 es precision highp float; in highp vec4 a_position; -in highp ivec2 a_ColorTest; +in highp vec2 a_ColorTest; out highp vec2 v_colorTest; void main() { - v_colorTest = vec2(a_ColorTest); + v_colorTest = a_ColorTest; gl_Position = a_position; })"; @@ -1846,7 +1846,8 @@ in highp vec2 v_colorTest; out vec4 fragColor; void main() { - if(v_colorTest.x > 0.5) { + // The input value is 0x01000000 / 0x7FFFFFFF + if(abs(v_colorTest.x - 0.0078125) < 0.001) { fragColor = vec4(0.0, 1.0, 0.0, 1.0); } else { fragColor = vec4(1.0, 0.0, 0.0, 1.0); diff --git a/src/tests/gl_tests/WebGLReadOutsideFramebufferTest.cpp b/src/tests/gl_tests/WebGLReadOutsideFramebufferTest.cpp index 16d710f8e3..5b6edd8b74 100644 --- a/src/tests/gl_tests/WebGLReadOutsideFramebufferTest.cpp +++ b/src/tests/gl_tests/WebGLReadOutsideFramebufferTest.cpp @@ -63,22 +63,22 @@ class PixelRect glTexParameteri(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); } - void toTexture3D(GLuint texid, GLint depth) const + void toTexture3D(GLuint target, GLuint texid, GLint depth) const { - glBindTexture(GL_TEXTURE_3D, texid); + glBindTexture(target, texid); - glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, mWidth, mHeight, depth, 0, GL_RGBA, - GL_UNSIGNED_BYTE, nullptr); + glTexImage3D(target, 0, GL_RGBA, mWidth, mHeight, depth, 0, GL_RGBA, GL_UNSIGNED_BYTE, + nullptr); for (GLint z = 0; z < depth; z++) { - glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, z, mWidth, mHeight, 1, GL_RGBA, - GL_UNSIGNED_BYTE, mData.data()); + glTexSubImage3D(target, 0, 0, 0, z, mWidth, mHeight, 1, GL_RGBA, GL_UNSIGNED_BYTE, + mData.data()); } - glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE); + glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameteri(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + glTexParameteri(target, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE); } void readFB(int x, int y) @@ -169,12 +169,24 @@ class WebGLReadOutsideFramebufferTest : public ANGLETest<> pixelsOut); } + // Read framebuffer to 'pixelsOut' via glCopyTexSubImage3D and a 2D array texture. + void TestCopyTexSubImage2DArray(int x, int y, int z, PixelRect *pixelsOut) + { + // Init texture with given pixels. + GLTexture destTexture; + pixelsOut->toTexture3D(GL_TEXTURE_2D_ARRAY, destTexture.get(), kTextureDepth); + + // Read framebuffer -> texture -> 'pixelsOut' + glCopyTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, z, x, y, kReadWidth, kReadHeight); + readTexture3D(destTexture, kReadWidth, kReadHeight, z, pixelsOut); + } + // Read framebuffer to 'pixelsOut' via glCopyTexSubImage3D. void TestCopyTexSubImage3D(int x, int y, int z, PixelRect *pixelsOut) { // Init texture with given pixels. GLTexture destTexture; - pixelsOut->toTexture3D(destTexture.get(), kTextureDepth); + pixelsOut->toTexture3D(GL_TEXTURE_3D, destTexture.get(), kTextureDepth); // Read framebuffer -> texture -> 'pixelsOut' glCopyTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, z, x, y, kReadWidth, kReadHeight); @@ -228,6 +240,7 @@ class WebGLReadOutsideFramebufferTest : public ANGLETest<> setConfigGreenBits(8); setConfigBlueBits(8); setConfigAlphaBits(8); + setRobustResourceInit(true); setWebGLCompatibilityEnabled(true); } @@ -357,8 +370,6 @@ TEST_P(WebGLReadOutsideFramebufferTest, CopyTexSubImage2D) // Check that copyTexImage2D sets (0,0,0,0) for pixels outside the framebuffer. TEST_P(WebGLReadOutsideFramebufferTest, CopyTexImage2D) { - // http://anglebug.com/4092 - ANGLE_SKIP_TEST_IF(IsVulkan() || IsD3D9() || IsD3D11()); Main2D(&WebGLReadOutsideFramebufferTest::TestCopyTexImage2D, true); Main2D(&WebGLReadOutsideFramebufferTest::TestCopyTexImageCube, true); } @@ -367,16 +378,12 @@ TEST_P(WebGLReadOutsideFramebufferTest, CopyTexImage2D) // the corresponding source pixel is outside the framebuffer. TEST_P(WebGL2ReadOutsideFramebufferTest, CopyTexSubImage3D) { - // http://anglebug.com/4092 - ANGLE_SKIP_TEST_IF(IsVulkan() || IsD3D9() || IsD3D11()); - // Robust CopyTexSubImage3D behaviour is not implemented on OpenGL. - ANGLE_SKIP_TEST_IF(IsDesktopOpenGL() || IsOpenGLES()); - + Main3D(&WebGLReadOutsideFramebufferTest::TestCopyTexSubImage2DArray, false); Main3D(&WebGLReadOutsideFramebufferTest::TestCopyTexSubImage3D, false); } ANGLE_INSTANTIATE_TEST_ES2_AND_ES3(WebGLReadOutsideFramebufferTest); -ANGLE_INSTANTIATE_TEST_ES2_AND_ES3(WebGL2ReadOutsideFramebufferTest); +ANGLE_INSTANTIATE_TEST_ES3(WebGL2ReadOutsideFramebufferTest); } // namespace angle |