blob: cff14d3e91be935a9280dff921b3d68609181cd6 [file] [log] [blame]
Yunchao Hea336b902017-08-02 16:05:21 +08001//
2// Copyright 2017 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// ProgramPipelineTest:
7// Various tests related to Program Pipeline.
8//
9
10#include "test_utils/ANGLETest.h"
11#include "test_utils/gl_raii.h"
12
13using namespace angle;
14
15namespace
16{
17
18class ProgramPipelineTest : public ANGLETest
19{
20 protected:
21 ProgramPipelineTest()
22 {
23 setWindowWidth(64);
24 setWindowHeight(64);
25 setConfigRedBits(8);
26 setConfigGreenBits(8);
27 setConfigBlueBits(8);
28 setConfigAlphaBits(8);
29 }
30};
31
32// Verify that program pipeline is not supported in version lower than ES31.
33TEST_P(ProgramPipelineTest, GenerateProgramPipelineObject)
34{
35 GLuint pipeline;
36 glGenProgramPipelines(1, &pipeline);
37 if (getClientMajorVersion() < 3 || getClientMinorVersion() < 1)
38 {
39 EXPECT_GL_ERROR(GL_INVALID_OPERATION);
40 }
41 else
42 {
43 EXPECT_GL_NO_ERROR();
44
45 glDeleteProgramPipelines(1, &pipeline);
46 EXPECT_GL_NO_ERROR();
47 }
48}
49
50class ProgramPipelineTest31 : public ProgramPipelineTest
51{
52};
53
54// Test generate or delete program pipeline.
55TEST_P(ProgramPipelineTest31, GenOrDeleteProgramPipelineTest)
56{
57 GLuint pipeline;
58 glGenProgramPipelines(-1, &pipeline);
59 EXPECT_GL_ERROR(GL_INVALID_VALUE);
60 glGenProgramPipelines(0, &pipeline);
61 EXPECT_GL_NO_ERROR();
62
63 glDeleteProgramPipelines(-1, &pipeline);
64 EXPECT_GL_ERROR(GL_INVALID_VALUE);
65 glDeleteProgramPipelines(0, &pipeline);
66 EXPECT_GL_NO_ERROR();
67}
68
69// Test BindProgramPipeline.
70TEST_P(ProgramPipelineTest31, BindProgramPipelineTest)
71{
72 glBindProgramPipeline(0);
73 EXPECT_GL_NO_ERROR();
74
75 glBindProgramPipeline(2);
76 EXPECT_GL_ERROR(GL_INVALID_OPERATION);
77
78 GLuint pipeline;
79 glGenProgramPipelines(1, &pipeline);
80 glBindProgramPipeline(pipeline);
81 EXPECT_GL_NO_ERROR();
82
83 glDeleteProgramPipelines(1, &pipeline);
84 glBindProgramPipeline(pipeline);
85 EXPECT_GL_ERROR(GL_INVALID_OPERATION);
86}
87
88// Test IsProgramPipeline
89TEST_P(ProgramPipelineTest31, IsProgramPipelineTest)
90{
Yunchao He1f679cc2017-11-29 18:06:00 +080091 EXPECT_GL_FALSE(glIsProgramPipeline(0));
Yunchao Hea336b902017-08-02 16:05:21 +080092 EXPECT_GL_NO_ERROR();
93
Yunchao He1f679cc2017-11-29 18:06:00 +080094 EXPECT_GL_FALSE(glIsProgramPipeline(2));
Yunchao Hea336b902017-08-02 16:05:21 +080095 EXPECT_GL_NO_ERROR();
96
97 GLuint pipeline;
98 glGenProgramPipelines(1, &pipeline);
99 glBindProgramPipeline(pipeline);
Yunchao He1f679cc2017-11-29 18:06:00 +0800100 EXPECT_GL_TRUE(glIsProgramPipeline(pipeline));
Yunchao Hea336b902017-08-02 16:05:21 +0800101 EXPECT_GL_NO_ERROR();
102
103 glBindProgramPipeline(0);
104 glDeleteProgramPipelines(1, &pipeline);
Yunchao He1f679cc2017-11-29 18:06:00 +0800105 EXPECT_GL_FALSE(glIsProgramPipeline(pipeline));
Yunchao Hea336b902017-08-02 16:05:21 +0800106 EXPECT_GL_NO_ERROR();
107}
108
109ANGLE_INSTANTIATE_TEST(ProgramPipelineTest,
110 ES3_OPENGL(),
111 ES3_OPENGLES(),
112 ES31_OPENGL(),
113 ES31_OPENGLES());
114ANGLE_INSTANTIATE_TEST(ProgramPipelineTest31, ES31_OPENGL(), ES31_OPENGLES());
115
116} // namespace