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 // TextureExternalUpdateTest.cpp: Tests for GL_ANGLE_texture_external_update
8
9 #include "test_utils/ANGLETest.h"
10 #include "test_utils/gl_raii.h"
11
12 namespace angle
13 {
14
15 class TextureExternalUpdateTest : public ANGLETest
16 {};
17
18 // Test basic usage of glInvalidateTextureANGLE
TEST_P(TextureExternalUpdateTest,Invalidate)19 TEST_P(TextureExternalUpdateTest, Invalidate)
20 {
21 ANGLE_SKIP_TEST_IF(!EnsureGLExtensionEnabled("GL_ANGLE_texture_external_update"));
22
23 glInvalidateTextureANGLE(GL_TEXTURE_2D);
24 EXPECT_GL_NO_ERROR();
25
26 glInvalidateTextureANGLE(GL_TEXTURE_EXTERNAL_OES);
27 if (EnsureGLExtensionEnabled("GL_OES_EGL_image_external"))
28 {
29 EXPECT_GL_NO_ERROR();
30 }
31 else
32 {
33 EXPECT_GL_ERROR(GL_INVALID_ENUM);
34 }
35 }
36
37 // Test basic usage of glTexImage2DExternalANGLE
TEST_P(TextureExternalUpdateTest,TexImage2DExternal)38 TEST_P(TextureExternalUpdateTest, TexImage2DExternal)
39 {
40 ANGLE_SKIP_TEST_IF(!EnsureGLExtensionEnabled("GL_ANGLE_texture_external_update"));
41
42 GLenum bindingPoint = GL_TEXTURE_2D;
43 if (EnsureGLExtensionEnabled("GL_OES_EGL_image_external"))
44 {
45 // If external textures are available, try calling glTexImage2DExternalANGLE on them instead
46 // because it would be disallowed for regular glTexImage2D calls.
47 bindingPoint = GL_TEXTURE_EXTERNAL_OES;
48 }
49
50 GLTexture texture;
51 glBindTexture(bindingPoint, texture);
52
53 glTexImage2DExternalANGLE(bindingPoint, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE);
54 EXPECT_GL_NO_ERROR();
55
56 // No data to verify because the texture has not actually been modified externally
57 }
58
59 // Test the native ID query
TEST_P(TextureExternalUpdateTest,NativeID)60 TEST_P(TextureExternalUpdateTest, NativeID)
61 {
62 ANGLE_SKIP_TEST_IF(!EnsureGLExtensionEnabled("GL_ANGLE_texture_external_update"));
63
64 GLTexture texture;
65 glBindTexture(GL_TEXTURE_2D, texture);
66
67 GLint nativeId = 0;
68 glGetTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_NATIVE_ID_ANGLE, &nativeId);
69 EXPECT_GL_NO_ERROR();
70 EXPECT_NE(0, nativeId);
71 }
72
73 // Use this to select which configurations (e.g. which renderer, which GLES major version) these
74 // tests should be run against.
75 ANGLE_INSTANTIATE_TEST_ES2_AND_ES3(TextureExternalUpdateTest);
76
77 } // namespace angle
78