OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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> |
(...skipping 27 matching lines...) Expand all Loading... |
38 command_line.AppendSwitchASCII(switches::kGpuDriverBugWorkarounds, | 38 command_line.AppendSwitchASCII(switches::kGpuDriverBugWorkarounds, |
39 base::IntToString(gpu::GL_CLEAR_BROKEN)); | 39 base::IntToString(gpu::GL_CLEAR_BROKEN)); |
40 gl_.InitializeWithCommandLine(GLManager::Options(), command_line); | 40 gl_.InitializeWithCommandLine(GLManager::Options(), command_line); |
41 DCHECK(gl_.workarounds().gl_clear_broken); | 41 DCHECK(gl_.workarounds().gl_clear_broken); |
42 } else { | 42 } else { |
43 gl_.Initialize(GLManager::Options()); | 43 gl_.Initialize(GLManager::Options()); |
44 DCHECK(!gl_.workarounds().gl_clear_broken); | 44 DCHECK(!gl_.workarounds().gl_clear_broken); |
45 } | 45 } |
46 } | 46 } |
47 | 47 |
48 bool IsApplicable() { | |
49 // The workaround doesn't use VAOs which would cause a failure on a core | |
50 // context and the hardware for each the workaround is necessary has a buggy | |
51 // VAO implementation. So we skip testing the workaround on core profiles. | |
52 return !GetParam() || | |
53 !gl_.context()->GetVersionInfo()->is_desktop_core_profile; | |
54 } | |
55 | |
56 void InitDraw(); | 48 void InitDraw(); |
57 void SetDrawColor(GLfloat r, GLfloat g, GLfloat b, GLfloat a); | 49 void SetDrawColor(GLfloat r, GLfloat g, GLfloat b, GLfloat a); |
58 void SetDrawDepth(GLfloat depth); | 50 void SetDrawDepth(GLfloat depth); |
59 void DrawQuad(); | 51 void DrawQuad(); |
60 | 52 |
61 void TearDown() override { | 53 void TearDown() override { |
62 GLTestHelper::CheckGLError("no errors", __LINE__); | 54 GLTestHelper::CheckGLError("no errors", __LINE__); |
63 gl_.Destroy(); | 55 gl_.Destroy(); |
64 } | 56 } |
65 | 57 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 | 103 |
112 void GLClearFramebufferTest::DrawQuad() { | 104 void GLClearFramebufferTest::DrawQuad() { |
113 glDrawArrays(GL_TRIANGLES, 0, 6); | 105 glDrawArrays(GL_TRIANGLES, 0, 6); |
114 } | 106 } |
115 | 107 |
116 INSTANTIATE_TEST_CASE_P(GLClearFramebufferTestWithParam, | 108 INSTANTIATE_TEST_CASE_P(GLClearFramebufferTestWithParam, |
117 GLClearFramebufferTest, | 109 GLClearFramebufferTest, |
118 ::testing::Values(true, false)); | 110 ::testing::Values(true, false)); |
119 | 111 |
120 TEST_P(GLClearFramebufferTest, ClearColor) { | 112 TEST_P(GLClearFramebufferTest, ClearColor) { |
121 if (!IsApplicable()) { | |
122 return; | |
123 } | |
124 | |
125 glClearColor(1.0f, 0.5f, 0.25f, 0.5f); | 113 glClearColor(1.0f, 0.5f, 0.25f, 0.5f); |
126 glClear(GL_COLOR_BUFFER_BIT); | 114 glClear(GL_COLOR_BUFFER_BIT); |
127 | 115 |
128 // Verify. | 116 // Verify. |
129 const uint8_t expected[] = {255, 128, 64, 128}; | 117 const uint8_t expected[] = {255, 128, 64, 128}; |
130 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 1, 1, 1 /* tolerance */, expected, | 118 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 1, 1, 1 /* tolerance */, expected, |
131 nullptr)); | 119 nullptr)); |
132 } | 120 } |
133 | 121 |
134 TEST_P(GLClearFramebufferTest, ClearColorWithMask) { | 122 TEST_P(GLClearFramebufferTest, ClearColorWithMask) { |
135 if (!IsApplicable()) { | |
136 return; | |
137 } | |
138 | |
139 glColorMask(GL_TRUE, GL_FALSE, GL_FALSE, GL_FALSE); | 123 glColorMask(GL_TRUE, GL_FALSE, GL_FALSE, GL_FALSE); |
140 glClearColor(1.0f, 1.0f, 1.0f, 1.0f); | 124 glClearColor(1.0f, 1.0f, 1.0f, 1.0f); |
141 glClear(GL_COLOR_BUFFER_BIT); | 125 glClear(GL_COLOR_BUFFER_BIT); |
142 | 126 |
143 // Verify. | 127 // Verify. |
144 const uint8_t expected[] = {255, 0, 0, 0}; | 128 const uint8_t expected[] = {255, 0, 0, 0}; |
145 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 1, 1, 0 /* tolerance */, expected, | 129 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 1, 1, 0 /* tolerance */, expected, |
146 nullptr)); | 130 nullptr)); |
147 } | 131 } |
148 | 132 |
149 // crbug.com/434094 | 133 // crbug.com/434094 |
150 #if !defined(OS_MACOSX) | 134 #if !defined(OS_MACOSX) |
151 TEST_P(GLClearFramebufferTest, ClearColorWithScissor) { | 135 TEST_P(GLClearFramebufferTest, ClearColorWithScissor) { |
152 if (!IsApplicable()) { | |
153 return; | |
154 } | |
155 | |
156 glClearColor(1.0f, 1.0f, 1.0f, 1.0f); | 136 glClearColor(1.0f, 1.0f, 1.0f, 1.0f); |
157 glClear(GL_COLOR_BUFFER_BIT); | 137 glClear(GL_COLOR_BUFFER_BIT); |
158 | 138 |
159 // Verify. | 139 // Verify. |
160 const uint8_t expected[] = {255, 255, 255, 255}; | 140 const uint8_t expected[] = {255, 255, 255, 255}; |
161 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 1, 1, 0 /* tolerance */, expected, | 141 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 1, 1, 0 /* tolerance */, expected, |
162 nullptr)); | 142 nullptr)); |
163 | 143 |
164 glScissor(0, 0, 0, 0); | 144 glScissor(0, 0, 0, 0); |
165 glEnable(GL_SCISSOR_TEST); | 145 glEnable(GL_SCISSOR_TEST); |
166 glClearColor(0, 0, 0, 0); | 146 glClearColor(0, 0, 0, 0); |
167 glClear(GL_COLOR_BUFFER_BIT); | 147 glClear(GL_COLOR_BUFFER_BIT); |
168 | 148 |
169 // Verify - no changes. | 149 // Verify - no changes. |
170 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 1, 1, 0 /* tolerance */, expected, | 150 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 1, 1, 0 /* tolerance */, expected, |
171 nullptr)); | 151 nullptr)); |
172 } | 152 } |
173 #endif | 153 #endif |
174 | 154 |
175 TEST_P(GLClearFramebufferTest, ClearDepthStencil) { | 155 TEST_P(GLClearFramebufferTest, ClearDepthStencil) { |
176 if (!IsApplicable()) { | |
177 return; | |
178 } | |
179 | |
180 const GLuint kStencilRef = 1 << 2; | 156 const GLuint kStencilRef = 1 << 2; |
181 InitDraw(); | 157 InitDraw(); |
182 SetDrawColor(1.0f, 0.0f, 0.0f, 1.0f); | 158 SetDrawColor(1.0f, 0.0f, 0.0f, 1.0f); |
183 DrawQuad(); | 159 DrawQuad(); |
184 // Verify. | 160 // Verify. |
185 const uint8_t kRed[] = {255, 0, 0, 255}; | 161 const uint8_t kRed[] = {255, 0, 0, 255}; |
186 const uint8_t kGreen[] = {0, 255, 0, 255}; | 162 const uint8_t kGreen[] = {0, 255, 0, 255}; |
187 EXPECT_TRUE( | 163 EXPECT_TRUE( |
188 GLTestHelper::CheckPixels(0, 0, 1, 1, 0 /* tolerance */, kRed, nullptr)); | 164 GLTestHelper::CheckPixels(0, 0, 1, 1, 0 /* tolerance */, kRed, nullptr)); |
189 | 165 |
(...skipping 28 matching lines...) Expand all Loading... |
218 | 194 |
219 glClearDepthf(0.9f); | 195 glClearDepthf(0.9f); |
220 glClear(GL_DEPTH_BUFFER_BIT); | 196 glClear(GL_DEPTH_BUFFER_BIT); |
221 DrawQuad(); | 197 DrawQuad(); |
222 // Verify - depth test should have passed, so red. | 198 // Verify - depth test should have passed, so red. |
223 EXPECT_TRUE( | 199 EXPECT_TRUE( |
224 GLTestHelper::CheckPixels(0, 0, 1, 1, 0 /* tolerance */, kRed, nullptr)); | 200 GLTestHelper::CheckPixels(0, 0, 1, 1, 0 /* tolerance */, kRed, nullptr)); |
225 } | 201 } |
226 | 202 |
227 } // namespace gpu | 203 } // namespace gpu |
OLD | NEW |