1 //
2 // Copyright 2015 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 // BindGeneratesResourceTest.cpp : Tests of the GL_CHROMIUM_bind_generates_resource extension.
8
9 #include "test_utils/ANGLETest.h"
10
11 namespace angle
12 {
13
14 class BindGeneratesResourceTest : public ANGLETest
15 {
16 protected:
BindGeneratesResourceTest()17 BindGeneratesResourceTest() { setBindGeneratesResource(false); }
18 };
19
20 // Context creation would fail if EGL_CHROMIUM_create_context_bind_generates_resource was not
21 // available so the GL extension should always be present
TEST_P(BindGeneratesResourceTest,ExtensionStringExposed)22 TEST_P(BindGeneratesResourceTest, ExtensionStringExposed)
23 {
24 EXPECT_TRUE(IsGLExtensionEnabled("GL_CHROMIUM_bind_generates_resource"));
25 }
26
27 // Verify that GL_BIND_GENERATES_RESOURCE_CHROMIUM can be queried but not changed
TEST_P(BindGeneratesResourceTest,QueryValidation)28 TEST_P(BindGeneratesResourceTest, QueryValidation)
29 {
30 GLint intValue = 2;
31 glGetIntegerv(GL_BIND_GENERATES_RESOURCE_CHROMIUM, &intValue);
32 EXPECT_GL_NO_ERROR();
33 EXPECT_GL_FALSE(intValue);
34
35 float floatValue = 2.0f;
36 glGetFloatv(GL_BIND_GENERATES_RESOURCE_CHROMIUM, &floatValue);
37 EXPECT_GL_NO_ERROR();
38 EXPECT_EQ(floatValue, 0.0f);
39
40 GLboolean boolValue = GL_TRUE;
41 glGetBooleanv(GL_BIND_GENERATES_RESOURCE_CHROMIUM, &boolValue);
42 EXPECT_GL_NO_ERROR();
43 EXPECT_GL_FALSE(boolValue);
44
45 boolValue = glIsEnabled(GL_BIND_GENERATES_RESOURCE_CHROMIUM);
46 EXPECT_GL_NO_ERROR();
47 EXPECT_GL_FALSE(boolValue);
48
49 glEnable(GL_BIND_GENERATES_RESOURCE_CHROMIUM);
50 EXPECT_GL_ERROR(GL_INVALID_ENUM);
51
52 glDisable(GL_BIND_GENERATES_RESOURCE_CHROMIUM);
53 EXPECT_GL_ERROR(GL_INVALID_ENUM);
54 }
55
56 // Test that buffers cannot be generated on bind
TEST_P(BindGeneratesResourceTest,Buffers)57 TEST_P(BindGeneratesResourceTest, Buffers)
58 {
59 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 2);
60 EXPECT_GL_ERROR(GL_INVALID_OPERATION);
61
62 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
63 EXPECT_GL_NO_ERROR();
64
65 if (getClientMajorVersion() >= 3)
66 {
67 glBindBufferBase(GL_UNIFORM_BUFFER, 0, 3);
68 EXPECT_GL_ERROR(GL_INVALID_OPERATION);
69
70 glBindBufferBase(GL_UNIFORM_BUFFER, 0, 0);
71 EXPECT_GL_NO_ERROR();
72
73 glBindBufferRange(GL_UNIFORM_BUFFER, 0, 4, 1, 2);
74 EXPECT_GL_ERROR(GL_INVALID_OPERATION);
75
76 glBindBufferRange(GL_UNIFORM_BUFFER, 0, 0, 1, 2);
77 EXPECT_GL_NO_ERROR();
78 }
79 }
80
81 // Test that textures cannot be generated on bind
TEST_P(BindGeneratesResourceTest,Textures)82 TEST_P(BindGeneratesResourceTest, Textures)
83 {
84 glBindTexture(GL_TEXTURE_2D, 2);
85 EXPECT_GL_ERROR(GL_INVALID_OPERATION);
86
87 glBindTexture(GL_TEXTURE_2D, 0);
88 EXPECT_GL_NO_ERROR();
89 }
90
91 // Test that framebuffers cannot be generated on bind
TEST_P(BindGeneratesResourceTest,Framebuffers)92 TEST_P(BindGeneratesResourceTest, Framebuffers)
93 {
94 glBindFramebuffer(GL_FRAMEBUFFER, 2);
95 EXPECT_GL_ERROR(GL_INVALID_OPERATION);
96
97 glBindFramebuffer(GL_FRAMEBUFFER, 0);
98 EXPECT_GL_NO_ERROR();
99 }
100
101 // Test that renderbuffer cannot be generated on bind
TEST_P(BindGeneratesResourceTest,Renderbuffers)102 TEST_P(BindGeneratesResourceTest, Renderbuffers)
103 {
104 glBindRenderbuffer(GL_RENDERBUFFER, 2);
105 EXPECT_GL_ERROR(GL_INVALID_OPERATION);
106
107 glBindRenderbuffer(GL_RENDERBUFFER, 0);
108 EXPECT_GL_NO_ERROR();
109 }
110
111 // Use this to select which configurations (e.g. which renderer, which GLES major version) these
112 // tests should be run against.
113 ANGLE_INSTANTIATE_TEST_ES2_AND_ES3(BindGeneratesResourceTest);
114
115 } // namespace angle
116