1 // 2 // Copyright 2019 The ANGLE Project Authors. All rights reserved. 3 // Use of this source code is governed by a BSD-style license that can be 4 // found in the LICENSE file. 5 // 6 7 // SemaphoreTest.cpp : Tests of the GL_EXT_semaphore extension. 8 9 #include "test_utils/ANGLETest.h" 10 11 #include "test_utils/gl_raii.h" 12 13 namespace angle 14 { 15 16 class SemaphoreTest : public ANGLETest<> 17 { 18 protected: SemaphoreTest()19 SemaphoreTest() 20 { 21 setWindowWidth(1); 22 setWindowHeight(1); 23 setConfigRedBits(8); 24 setConfigGreenBits(8); 25 setConfigBlueBits(8); 26 setConfigAlphaBits(8); 27 } 28 }; 29 30 // glIsSemaphoreEXT must identify semaphores. TEST_P(SemaphoreTest,SemaphoreShouldBeSemaphore)31TEST_P(SemaphoreTest, SemaphoreShouldBeSemaphore) 32 { 33 ANGLE_SKIP_TEST_IF(!EnsureGLExtensionEnabled("GL_EXT_semaphore")); 34 35 constexpr GLsizei kSemaphoreCount = 2; 36 GLuint semaphores[kSemaphoreCount]; 37 glGenSemaphoresEXT(kSemaphoreCount, semaphores); 38 39 EXPECT_FALSE(glIsSemaphoreEXT(0)); 40 41 for (GLsizei i = 0; i < kSemaphoreCount; ++i) 42 { 43 EXPECT_TRUE(glIsSemaphoreEXT(semaphores[i])); 44 } 45 46 glDeleteSemaphoresEXT(kSemaphoreCount, semaphores); 47 48 EXPECT_GL_NO_ERROR(); 49 } 50 51 // glImportSemaphoreFdEXT must fail for handle types that are not file descriptors. TEST_P(SemaphoreTest,ShouldFailValidationOnImportFdUnsupportedHandleType)52TEST_P(SemaphoreTest, ShouldFailValidationOnImportFdUnsupportedHandleType) 53 { 54 ANGLE_SKIP_TEST_IF(!EnsureGLExtensionEnabled("GL_EXT_semaphore_fd")); 55 56 { 57 GLSemaphore semaphore; 58 int fd = -1; 59 glImportSemaphoreFdEXT(semaphore, GL_HANDLE_TYPE_OPAQUE_WIN32_EXT, fd); 60 EXPECT_GL_ERROR(GL_INVALID_ENUM); 61 } 62 63 EXPECT_GL_NO_ERROR(); 64 } 65 66 // Use this to select which configurations (e.g. which renderer, which GLES major version) these 67 // tests should be run against. 68 ANGLE_INSTANTIATE_TEST_ES2_AND_ES3(SemaphoreTest); 69 70 } // namespace angle 71