Yunchao He | a336b90 | 2017-08-02 16:05:21 +0800 | [diff] [blame] | 1 | // |
| 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 | |
| 13 | using namespace angle; |
| 14 | |
| 15 | namespace |
| 16 | { |
| 17 | |
| 18 | class 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. |
| 33 | TEST_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 | |
| 50 | class ProgramPipelineTest31 : public ProgramPipelineTest |
| 51 | { |
| 52 | }; |
| 53 | |
| 54 | // Test generate or delete program pipeline. |
| 55 | TEST_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. |
| 70 | TEST_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 |
| 89 | TEST_P(ProgramPipelineTest31, IsProgramPipelineTest) |
| 90 | { |
Yunchao He | 1f679cc | 2017-11-29 18:06:00 +0800 | [diff] [blame^] | 91 | EXPECT_GL_FALSE(glIsProgramPipeline(0)); |
Yunchao He | a336b90 | 2017-08-02 16:05:21 +0800 | [diff] [blame] | 92 | EXPECT_GL_NO_ERROR(); |
| 93 | |
Yunchao He | 1f679cc | 2017-11-29 18:06:00 +0800 | [diff] [blame^] | 94 | EXPECT_GL_FALSE(glIsProgramPipeline(2)); |
Yunchao He | a336b90 | 2017-08-02 16:05:21 +0800 | [diff] [blame] | 95 | EXPECT_GL_NO_ERROR(); |
| 96 | |
| 97 | GLuint pipeline; |
| 98 | glGenProgramPipelines(1, &pipeline); |
| 99 | glBindProgramPipeline(pipeline); |
Yunchao He | 1f679cc | 2017-11-29 18:06:00 +0800 | [diff] [blame^] | 100 | EXPECT_GL_TRUE(glIsProgramPipeline(pipeline)); |
Yunchao He | a336b90 | 2017-08-02 16:05:21 +0800 | [diff] [blame] | 101 | EXPECT_GL_NO_ERROR(); |
| 102 | |
| 103 | glBindProgramPipeline(0); |
| 104 | glDeleteProgramPipelines(1, &pipeline); |
Yunchao He | 1f679cc | 2017-11-29 18:06:00 +0800 | [diff] [blame^] | 105 | EXPECT_GL_FALSE(glIsProgramPipeline(pipeline)); |
Yunchao He | a336b90 | 2017-08-02 16:05:21 +0800 | [diff] [blame] | 106 | EXPECT_GL_NO_ERROR(); |
| 107 | } |
| 108 | |
| 109 | ANGLE_INSTANTIATE_TEST(ProgramPipelineTest, |
| 110 | ES3_OPENGL(), |
| 111 | ES3_OPENGLES(), |
| 112 | ES31_OPENGL(), |
| 113 | ES31_OPENGLES()); |
| 114 | ANGLE_INSTANTIATE_TEST(ProgramPipelineTest31, ES31_OPENGL(), ES31_OPENGLES()); |
| 115 | |
| 116 | } // namespace |