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_types[] = { | |
194 {GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE}, | |
195 }; | |
196 | |
197 for (auto format_type : format_types) { | |
198 uint8_t pixels[1 * 4] = {0u, 255u, 0u, 255u}; | |
Zhenyao Mo
2017/02/13 18:36:18
Shouldn't this be part of the format_types structu
qiankun
2017/02/14 08:08:17
Done.
| |
199 glTexImage2D(GL_TEXTURE_2D, 0, format_type.internal_format, 1, 1, 0, | |
200 format_type.format, format_type.type, pixels); | |
201 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); | |
202 | |
203 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, | |
204 textures_, 0); | |
205 | |
206 // Only if the format is supported by FBO, supported by this extension. | |
207 if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) | |
208 continue; | |
209 | |
210 glApplyScreenSpaceAntialiasingCHROMIUM(); | |
211 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()) | |
212 << "internal_format: " | |
213 << gles2::GLES2Util::GetStringEnum(format_type.internal_format); | |
214 | |
215 GLTestHelper::CheckPixels(0, 0, 1, 1, 0, pixels, nullptr); | |
216 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); | |
217 } | |
218 } | |
219 | |
220 TEST_F(GLApplyScreenSpaceAntialiasingCHROMIUMES3Test, | |
221 InternalFormatNotSupported) { | |
222 if (!available_) | |
223 return; | |
224 | |
225 FormatType format_types[] = { | |
226 {GL_RGBA32UI, GL_RGBA_INTEGER, GL_UNSIGNED_INT}, | |
227 }; | |
228 | |
229 for (auto format_type : format_types) { | |
230 uint8_t pixels[1 * 4] = {0u, 255u, 0u, 255u}; | |
Zhenyao Mo
2017/02/13 18:36:18
This looks wrong to me as it doesn't fit the forma
qiankun
2017/02/14 08:08:17
Done.
| |
231 glTexImage2D(GL_TEXTURE_2D, 0, format_type.internal_format, 1, 1, 0, | |
232 format_type.format, format_type.type, pixels); | |
233 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); | |
234 | |
235 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, | |
236 textures_, 0); | |
237 | |
238 // Only if the format is supported by FBO, supported by this extension. | |
239 if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) | |
240 continue; | |
241 | |
242 glApplyScreenSpaceAntialiasingCHROMIUM(); | |
243 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()) | |
244 << "internal_format: " | |
245 << gles2::GLES2Util::GetStringEnum(format_type.internal_format); | |
246 } | |
247 } | |
248 | |
167 TEST_F(GLApplyScreenSpaceAntialiasingCHROMIUMTest, ImmutableTexture) { | 249 TEST_F(GLApplyScreenSpaceAntialiasingCHROMIUMTest, ImmutableTexture) { |
168 if (!available_) | 250 if (!available_) |
169 return; | 251 return; |
170 | 252 |
171 if (!GLTestHelper::HasExtension("GL_EXT_texture_storage")) { | 253 if (!GLTestHelper::HasExtension("GL_EXT_texture_storage")) { |
172 LOG(INFO) << "GL_EXT_texture_storage not supported. Skipping test..."; | 254 LOG(INFO) << "GL_EXT_texture_storage not supported. Skipping test..."; |
173 return; | 255 return; |
174 } | 256 } |
175 GLenum internal_formats[] = {GL_RGB8_OES, GL_RGBA8_OES, GL_BGRA8_EXT}; | 257 GLenum internal_formats[] = {GL_RGB8_OES, GL_RGBA8_OES, GL_BGRA8_EXT}; |
176 for (auto internal_format : internal_formats) { | 258 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)); | 496 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 1, 1, 0, expected, nullptr)); |
415 | 497 |
416 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); | 498 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); |
417 | 499 |
418 gl2.MakeCurrent(); | 500 gl2.MakeCurrent(); |
419 gl2.Destroy(); | 501 gl2.Destroy(); |
420 gl_.MakeCurrent(); | 502 gl_.MakeCurrent(); |
421 } | 503 } |
422 | 504 |
423 } // namespace gpu | 505 } // namespace gpu |
OLD | NEW |