OLD | NEW |
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef GL_GLEXT_PROTOTYPES | 5 #ifndef GL_GLEXT_PROTOTYPES |
6 #define GL_GLEXT_PROTOTYPES | 6 #define GL_GLEXT_PROTOTYPES |
7 #endif | 7 #endif |
8 | 8 |
9 #include <GLES2/gl2.h> | 9 #include <GLES2/gl2.h> |
10 #include <GLES2/gl2ext.h> | 10 #include <GLES2/gl2ext.h> |
11 #include <GLES2/gl2extchromium.h> | 11 #include <GLES2/gl2extchromium.h> |
| 12 #include <GLES3/gl3.h> |
12 #include <stddef.h> | 13 #include <stddef.h> |
13 #include <stdint.h> | 14 #include <stdint.h> |
14 | 15 |
15 #include "base/command_line.h" | 16 #include "base/command_line.h" |
16 #include "gpu/command_buffer/tests/gl_manager.h" | 17 #include "gpu/command_buffer/tests/gl_manager.h" |
17 #include "gpu/command_buffer/tests/gl_test_utils.h" | 18 #include "gpu/command_buffer/tests/gl_test_utils.h" |
18 #include "testing/gmock/include/gmock/gmock.h" | 19 #include "testing/gmock/include/gmock/gmock.h" |
19 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
20 #include "ui/gl/gl_switches.h" | 21 #include "ui/gl/gl_switches.h" |
21 | 22 |
(...skipping 12 matching lines...) Expand all Loading... |
34 glTexParameterf(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); | 35 glTexParameterf(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
35 glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST); | 36 glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
36 glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST); | 37 glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
37 | 38 |
38 glGenFramebuffers(1, &framebuffer_id_); | 39 glGenFramebuffers(1, &framebuffer_id_); |
39 glBindFramebuffer(GL_FRAMEBUFFER, framebuffer_id_); | 40 glBindFramebuffer(GL_FRAMEBUFFER, framebuffer_id_); |
40 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, target, | 41 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, target, |
41 textures_, 0); | 42 textures_, 0); |
42 } | 43 } |
43 | 44 |
44 void SetUp() override { | 45 void CheckStatus() { |
45 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); | |
46 GLManager::Options options; | |
47 gl_.InitializeWithCommandLine(options, command_line); | |
48 | |
49 available_ = | 46 available_ = |
50 GLTestHelper::HasExtension("GL_CHROMIUM_screen_space_antialiasing"); | 47 GLTestHelper::HasExtension("GL_CHROMIUM_screen_space_antialiasing"); |
51 if (!available_) { | 48 if (!available_) { |
52 LOG(INFO) << "GL_CHROMIUM_screen_space_antialiasing not supported. " | 49 LOG(INFO) << "GL_CHROMIUM_screen_space_antialiasing not supported. " |
53 "Skipping test..."; | 50 "Skipping test..."; |
54 return; | 51 return; |
55 } | 52 } |
56 | 53 |
57 CreateAndBindDestinationTextureAndFBO(GL_TEXTURE_2D); | 54 CreateAndBindDestinationTextureAndFBO(GL_TEXTURE_2D); |
58 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, | 55 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
(...skipping 11 matching lines...) Expand all Loading... |
70 // For example, linux NVidia fails with this log. | 67 // For example, linux NVidia fails with this log. |
71 // ApplyFramebufferAttachmentCMAAINTEL: shader compilation failed: | 68 // ApplyFramebufferAttachmentCMAAINTEL: shader compilation failed: |
72 // GL_FRAGMENT_SHADER shader compilation failed: 0(98) : error C3013: | 69 // GL_FRAGMENT_SHADER shader compilation failed: 0(98) : error C3013: |
73 // input/output layout qualifiers supported above GL version 130 | 70 // input/output layout qualifiers supported above GL version 130 |
74 available_ = false; | 71 available_ = false; |
75 LOG(ERROR) << "GL_CHROMIUM_screen_space_antialiasing maybe not supported " | 72 LOG(ERROR) << "GL_CHROMIUM_screen_space_antialiasing maybe not supported " |
76 "in non-Intel GPU."; | 73 "in non-Intel GPU."; |
77 DeleteResources(); | 74 DeleteResources(); |
78 } | 75 } |
79 | 76 |
| 77 void SetUp() override { |
| 78 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); |
| 79 GLManager::Options options; |
| 80 gl_.InitializeWithCommandLine(options, command_line); |
| 81 CheckStatus(); |
| 82 } |
| 83 |
80 void TearDown() override { | 84 void TearDown() override { |
81 if (available_) | 85 if (available_) |
82 DeleteResources(); | 86 DeleteResources(); |
83 gl_.Destroy(); | 87 gl_.Destroy(); |
84 } | 88 } |
85 | 89 |
86 void DeleteResources() { | 90 void DeleteResources() { |
87 glDeleteTextures(1, &textures_); | 91 glDeleteTextures(1, &textures_); |
88 glDeleteFramebuffers(1, &framebuffer_id_); | 92 glDeleteFramebuffers(1, &framebuffer_id_); |
89 } | 93 } |
90 | 94 |
91 GLManager gl_; | 95 GLManager gl_; |
92 GLuint textures_ = 0; | 96 GLuint textures_ = 0; |
93 GLuint framebuffer_id_ = 0; | 97 GLuint framebuffer_id_ = 0; |
94 bool available_ = false; | 98 bool available_ = false; |
95 }; | 99 }; |
96 | 100 |
| 101 class GLApplyScreenSpaceAntialiasingCHROMIUMES3Test |
| 102 : public GLApplyScreenSpaceAntialiasingCHROMIUMTest { |
| 103 protected: |
| 104 void SetUp() override { |
| 105 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); |
| 106 GLManager::Options options; |
| 107 options.context_type = gles2::CONTEXT_TYPE_OPENGLES3; |
| 108 gl_.InitializeWithCommandLine(options, command_line); |
| 109 CheckStatus(); |
| 110 } |
| 111 }; |
| 112 |
97 // TODO(dongseong.hwang): This test fails on the Nexus 9 GPU fyi bot. | 113 // TODO(dongseong.hwang): This test fails on the Nexus 9 GPU fyi bot. |
98 // crbug.com/659638 | 114 // crbug.com/659638 |
99 #if defined(OS_ANDROID) | 115 #if defined(OS_ANDROID) |
100 #define MAYBE_Basic DISABLED_Basic | 116 #define MAYBE_Basic DISABLED_Basic |
101 #else | 117 #else |
102 #define MAYBE_Basic Basic | 118 #define MAYBE_Basic Basic |
103 #endif | 119 #endif |
104 // Test to ensure that the basic functionality of the extension works. | 120 // Test to ensure that the basic functionality of the extension works. |
105 TEST_F(GLApplyScreenSpaceAntialiasingCHROMIUMTest, MAYBE_Basic) { | 121 TEST_F(GLApplyScreenSpaceAntialiasingCHROMIUMTest, MAYBE_Basic) { |
106 if (!available_) | 122 if (!available_) |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 glApplyScreenSpaceAntialiasingCHROMIUM(); | 173 glApplyScreenSpaceAntialiasingCHROMIUM(); |
158 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()) << "index:" | 174 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()) << "index:" |
159 << index; | 175 << index; |
160 | 176 |
161 uint8_t pixels[1 * 4] = {0u, 255u, 0u, 255u}; | 177 uint8_t pixels[1 * 4] = {0u, 255u, 0u, 255u}; |
162 GLTestHelper::CheckPixels(0, 0, 1, 1, 0, pixels, nullptr); | 178 GLTestHelper::CheckPixels(0, 0, 1, 1, 0, pixels, nullptr); |
163 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); | 179 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); |
164 } | 180 } |
165 } | 181 } |
166 | 182 |
| 183 struct FormatType { |
| 184 GLenum internal_format; |
| 185 GLenum format; |
| 186 GLenum type; |
| 187 }; |
| 188 |
| 189 TEST_F(GLApplyScreenSpaceAntialiasingCHROMIUMES3Test, InternalFormat) { |
| 190 if (!available_) |
| 191 return; |
| 192 |
| 193 FormatType format_type = {GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE}; |
| 194 |
| 195 uint8_t pixels[1 * 4] = {0u, 255u, 0u, 255u}; |
| 196 glTexImage2D(GL_TEXTURE_2D, 0, format_type.internal_format, 1, 1, 0, |
| 197 format_type.format, format_type.type, pixels); |
| 198 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); |
| 199 |
| 200 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, |
| 201 textures_, 0); |
| 202 |
| 203 // Only if the format is supported by FBO, supported by this extension. |
| 204 if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) |
| 205 return; |
| 206 |
| 207 glApplyScreenSpaceAntialiasingCHROMIUM(); |
| 208 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()) |
| 209 << "internal_format: " |
| 210 << gles2::GLES2Util::GetStringEnum(format_type.internal_format); |
| 211 |
| 212 GLTestHelper::CheckPixels(0, 0, 1, 1, 0, pixels, nullptr); |
| 213 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); |
| 214 } |
| 215 |
| 216 TEST_F(GLApplyScreenSpaceAntialiasingCHROMIUMES3Test, |
| 217 InternalFormatNotSupported) { |
| 218 if (!available_) |
| 219 return; |
| 220 |
| 221 FormatType format_type = {GL_RGBA32UI, GL_RGBA_INTEGER, GL_UNSIGNED_INT}; |
| 222 |
| 223 uint32_t pixels[1 * 4] = {0u, 255u, 0u, 255u}; |
| 224 glTexImage2D(GL_TEXTURE_2D, 0, format_type.internal_format, 1, 1, 0, |
| 225 format_type.format, format_type.type, pixels); |
| 226 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); |
| 227 |
| 228 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, |
| 229 textures_, 0); |
| 230 |
| 231 // Only if the format is supported by FBO, supported by this extension. |
| 232 if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) |
| 233 return; |
| 234 |
| 235 glApplyScreenSpaceAntialiasingCHROMIUM(); |
| 236 EXPECT_EQ(static_cast<GLenum>(GL_INVALID_OPERATION), glGetError()) |
| 237 << "internal_format: " |
| 238 << gles2::GLES2Util::GetStringEnum(format_type.internal_format); |
| 239 } |
| 240 |
167 TEST_F(GLApplyScreenSpaceAntialiasingCHROMIUMTest, ImmutableTexture) { | 241 TEST_F(GLApplyScreenSpaceAntialiasingCHROMIUMTest, ImmutableTexture) { |
168 if (!available_) | 242 if (!available_) |
169 return; | 243 return; |
170 | 244 |
171 if (!GLTestHelper::HasExtension("GL_EXT_texture_storage")) { | 245 if (!GLTestHelper::HasExtension("GL_EXT_texture_storage")) { |
172 LOG(INFO) << "GL_EXT_texture_storage not supported. Skipping test..."; | 246 LOG(INFO) << "GL_EXT_texture_storage not supported. Skipping test..."; |
173 return; | 247 return; |
174 } | 248 } |
175 GLenum internal_formats[] = {GL_RGB8_OES, GL_RGBA8_OES, GL_BGRA8_EXT}; | 249 GLenum internal_formats[] = {GL_RGB8_OES, GL_RGBA8_OES, GL_BGRA8_EXT}; |
176 for (auto internal_format : internal_formats) { | 250 for (auto internal_format : internal_formats) { |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
414 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 1, 1, 0, expected, nullptr)); | 488 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 1, 1, 0, expected, nullptr)); |
415 | 489 |
416 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); | 490 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); |
417 | 491 |
418 gl2.MakeCurrent(); | 492 gl2.MakeCurrent(); |
419 gl2.Destroy(); | 493 gl2.Destroy(); |
420 gl_.MakeCurrent(); | 494 gl_.MakeCurrent(); |
421 } | 495 } |
422 | 496 |
423 } // namespace gpu | 497 } // namespace gpu |
OLD | NEW |