summaryrefslogtreecommitdiffstats
path: root/gfx/angle/src/tests/gl_tests/BindGeneratesResourceTest.cpp
blob: e8ae739f8657afc77faa4f0e52028e4c3fe987dc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
//
// Copyright 2015 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//

// BindGeneratesResourceTest.cpp : Tests of the GL_CHROMIUM_bind_generates_resource extension.

#include "test_utils/ANGLETest.h"

namespace angle
{

class BindGeneratesResourceTest : public ANGLETest
{
  protected:
    BindGeneratesResourceTest() { setBindGeneratesResource(false); }
};

// Context creation would fail if EGL_CHROMIUM_create_context_bind_generates_resource was not
// available so the GL extension should always be present
TEST_P(BindGeneratesResourceTest, ExtensionStringExposed)
{
    EXPECT_TRUE(extensionEnabled("GL_CHROMIUM_bind_generates_resource"));
}

// Verify that GL_BIND_GENERATES_RESOURCE_CHROMIUM can be queried but not changed
TEST_P(BindGeneratesResourceTest, QueryValidation)
{
    GLint intValue = 2;
    glGetIntegerv(GL_BIND_GENERATES_RESOURCE_CHROMIUM, &intValue);
    EXPECT_GL_NO_ERROR();
    EXPECT_EQ(intValue, GL_FALSE);

    float floatValue = 2.0f;
    glGetFloatv(GL_BIND_GENERATES_RESOURCE_CHROMIUM, &floatValue);
    EXPECT_GL_NO_ERROR();
    EXPECT_EQ(floatValue, 0.0f);

    GLboolean boolValue = GL_TRUE;
    glGetBooleanv(GL_BIND_GENERATES_RESOURCE_CHROMIUM, &boolValue);
    EXPECT_GL_NO_ERROR();
    EXPECT_EQ(boolValue, GL_FALSE);

    boolValue = glIsEnabled(GL_BIND_GENERATES_RESOURCE_CHROMIUM);
    EXPECT_GL_NO_ERROR();
    EXPECT_EQ(boolValue, GL_FALSE);

    glEnable(GL_BIND_GENERATES_RESOURCE_CHROMIUM);
    EXPECT_GL_ERROR(GL_INVALID_ENUM);

    glDisable(GL_BIND_GENERATES_RESOURCE_CHROMIUM);
    EXPECT_GL_ERROR(GL_INVALID_ENUM);
}

// Test that buffers cannot be generated on bind
TEST_P(BindGeneratesResourceTest, Buffers)
{
    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 2);
    EXPECT_GL_ERROR(GL_INVALID_OPERATION);

    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
    EXPECT_GL_NO_ERROR();

    if (getClientMajorVersion() >= 3)
    {
        glBindBufferBase(GL_UNIFORM_BUFFER, 0, 3);
        EXPECT_GL_ERROR(GL_INVALID_OPERATION);

        glBindBufferBase(GL_UNIFORM_BUFFER, 0, 0);
        EXPECT_GL_NO_ERROR();

        glBindBufferRange(GL_UNIFORM_BUFFER, 0, 4, 1, 2);
        EXPECT_GL_ERROR(GL_INVALID_OPERATION);

        glBindBufferRange(GL_UNIFORM_BUFFER, 0, 0, 1, 2);
        EXPECT_GL_NO_ERROR();
    }
}

// Test that textures cannot be generated on bind
TEST_P(BindGeneratesResourceTest, Textures)
{
    glBindTexture(GL_TEXTURE_2D, 2);
    EXPECT_GL_ERROR(GL_INVALID_OPERATION);

    glBindTexture(GL_TEXTURE_2D, 0);
    EXPECT_GL_NO_ERROR();
}

// Test that framebuffers cannot be generated on bind
TEST_P(BindGeneratesResourceTest, Framebuffers)
{
    glBindFramebuffer(GL_FRAMEBUFFER, 2);
    EXPECT_GL_ERROR(GL_INVALID_OPERATION);

    glBindFramebuffer(GL_FRAMEBUFFER, 0);
    EXPECT_GL_NO_ERROR();
}

// Test that renderbuffer cannot be generated on bind
TEST_P(BindGeneratesResourceTest, Renderbuffers)
{
    glBindRenderbuffer(GL_RENDERBUFFER, 2);
    EXPECT_GL_ERROR(GL_INVALID_OPERATION);

    glBindRenderbuffer(GL_RENDERBUFFER, 0);
    EXPECT_GL_NO_ERROR();
}

// Use this to select which configurations (e.g. which renderer, which GLES major version) these
// tests should be run against.
ANGLE_INSTANTIATE_TEST(BindGeneratesResourceTest,
                       ES2_D3D9(),
                       ES2_D3D11(),
                       ES3_D3D11(),
                       ES2_D3D11_FL9_3(),
                       ES2_OPENGL(),
                       ES3_OPENGL(),
                       ES2_OPENGLES(),
                       ES3_OPENGLES());

}  // namespace