Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(13)

Side by Side Diff: gpu/command_buffer/service/framebuffer_manager_unittest.cc

Issue 7099007: Enforce RGB even on buggy drivers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add checks for reading GL_ALPHA_BITS etc. Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #include "gpu/command_buffer/service/framebuffer_manager.h" 5 #include "gpu/command_buffer/service/framebuffer_manager.h"
6 #include "gpu/command_buffer/service/feature_info.h" 6 #include "gpu/command_buffer/service/feature_info.h"
7 7
8 #include "gpu/command_buffer/common/gl_mock.h" 8 #include "gpu/command_buffer/common/gl_mock.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
11 namespace gpu { 11 namespace gpu {
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 const GLuint FramebufferInfoTest::kService1Id; 115 const GLuint FramebufferInfoTest::kService1Id;
116 #endif 116 #endif
117 117
118 TEST_F(FramebufferInfoTest, Basic) { 118 TEST_F(FramebufferInfoTest, Basic) {
119 EXPECT_EQ(kService1Id, info_->service_id()); 119 EXPECT_EQ(kService1Id, info_->service_id());
120 EXPECT_FALSE(info_->IsDeleted()); 120 EXPECT_FALSE(info_->IsDeleted());
121 EXPECT_TRUE(NULL == info_->GetAttachment(GL_COLOR_ATTACHMENT0)); 121 EXPECT_TRUE(NULL == info_->GetAttachment(GL_COLOR_ATTACHMENT0));
122 EXPECT_TRUE(NULL == info_->GetAttachment(GL_DEPTH_ATTACHMENT)); 122 EXPECT_TRUE(NULL == info_->GetAttachment(GL_DEPTH_ATTACHMENT));
123 EXPECT_TRUE(NULL == info_->GetAttachment(GL_STENCIL_ATTACHMENT)); 123 EXPECT_TRUE(NULL == info_->GetAttachment(GL_STENCIL_ATTACHMENT));
124 EXPECT_TRUE(NULL == info_->GetAttachment(GL_DEPTH_STENCIL_ATTACHMENT)); 124 EXPECT_TRUE(NULL == info_->GetAttachment(GL_DEPTH_STENCIL_ATTACHMENT));
125 EXPECT_FALSE(info_->HasDepthAttachment());
126 EXPECT_FALSE(info_->HasStencilAttachment());
127 EXPECT_EQ(static_cast<GLenum>(0), info_->GetColorAttachmentFormat());
125 } 128 }
126 129
127 TEST_F(FramebufferInfoTest, AttachRenderbuffer) { 130 TEST_F(FramebufferInfoTest, AttachRenderbuffer) {
128 const GLuint kRenderbufferClient1Id = 33; 131 const GLuint kRenderbufferClient1Id = 33;
129 const GLuint kRenderbufferService1Id = 333; 132 const GLuint kRenderbufferService1Id = 333;
130 const GLuint kRenderbufferClient2Id = 34; 133 const GLuint kRenderbufferClient2Id = 34;
131 const GLuint kRenderbufferService2Id = 334; 134 const GLuint kRenderbufferService2Id = 334;
132 const GLint kMaxRenderbufferSize = 128; 135 const GLint kMaxRenderbufferSize = 128;
133 const GLsizei kWidth1 = 16; 136 const GLsizei kWidth1 = 16;
134 const GLsizei kHeight1 = 32; 137 const GLsizei kHeight1 = 32;
(...skipping 19 matching lines...) Expand all
154 kRenderbufferClient1Id, kRenderbufferService1Id); 157 kRenderbufferClient1Id, kRenderbufferService1Id);
155 RenderbufferManager::RenderbufferInfo* rb_info1 = 158 RenderbufferManager::RenderbufferInfo* rb_info1 =
156 rb_manager.GetRenderbufferInfo(kRenderbufferClient1Id); 159 rb_manager.GetRenderbufferInfo(kRenderbufferClient1Id);
157 ASSERT_TRUE(rb_info1 != NULL); 160 ASSERT_TRUE(rb_info1 != NULL);
158 161
159 // check adding one attachment 162 // check adding one attachment
160 info_->AttachRenderbuffer(GL_COLOR_ATTACHMENT0, rb_info1); 163 info_->AttachRenderbuffer(GL_COLOR_ATTACHMENT0, rb_info1);
161 EXPECT_TRUE(info_->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0)); 164 EXPECT_TRUE(info_->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0));
162 EXPECT_FALSE(info_->HasUnclearedAttachment(GL_DEPTH_ATTACHMENT)); 165 EXPECT_FALSE(info_->HasUnclearedAttachment(GL_DEPTH_ATTACHMENT));
163 EXPECT_TRUE(info_->IsNotComplete()); 166 EXPECT_TRUE(info_->IsNotComplete());
167 EXPECT_EQ(static_cast<GLenum>(GL_RGBA4), info_->GetColorAttachmentFormat());
168 EXPECT_FALSE(info_->HasDepthAttachment());
169 EXPECT_FALSE(info_->HasStencilAttachment());
170
171 rb_info1->SetInfo(1, GL_RGB, 0, 0);
172 EXPECT_EQ(static_cast<GLenum>(GL_RGB), info_->GetColorAttachmentFormat());
173 EXPECT_FALSE(info_->HasDepthAttachment());
174 EXPECT_FALSE(info_->HasStencilAttachment());
164 175
165 // check adding another 176 // check adding another
166 info_->AttachRenderbuffer(GL_DEPTH_ATTACHMENT, rb_info1); 177 info_->AttachRenderbuffer(GL_DEPTH_ATTACHMENT, rb_info1);
167 EXPECT_TRUE(info_->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0)); 178 EXPECT_TRUE(info_->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0));
168 EXPECT_TRUE(info_->HasUnclearedAttachment(GL_DEPTH_ATTACHMENT)); 179 EXPECT_TRUE(info_->HasUnclearedAttachment(GL_DEPTH_ATTACHMENT));
169 EXPECT_TRUE(info_->IsNotComplete()); 180 EXPECT_TRUE(info_->IsNotComplete());
181 EXPECT_EQ(static_cast<GLenum>(GL_RGB), info_->GetColorAttachmentFormat());
182 EXPECT_TRUE(info_->HasDepthAttachment());
183 EXPECT_FALSE(info_->HasStencilAttachment());
170 184
171 // check marking them as cleared. 185 // check marking them as cleared.
172 info_->MarkAttachedRenderbuffersAsCleared(); 186 info_->MarkAttachedRenderbuffersAsCleared();
173 EXPECT_FALSE(info_->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0)); 187 EXPECT_FALSE(info_->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0));
174 EXPECT_FALSE(info_->HasUnclearedAttachment(GL_DEPTH_ATTACHMENT)); 188 EXPECT_FALSE(info_->HasUnclearedAttachment(GL_DEPTH_ATTACHMENT));
175 EXPECT_TRUE(info_->IsNotComplete()); 189 EXPECT_TRUE(info_->IsNotComplete());
176 190
177 // Check adding one that is already cleared. 191 // Check adding one that is already cleared.
178 info_->AttachRenderbuffer(GL_STENCIL_ATTACHMENT, rb_info1); 192 info_->AttachRenderbuffer(GL_STENCIL_ATTACHMENT, rb_info1);
179 EXPECT_FALSE(info_->HasUnclearedAttachment(GL_STENCIL_ATTACHMENT)); 193 EXPECT_FALSE(info_->HasUnclearedAttachment(GL_STENCIL_ATTACHMENT));
194 EXPECT_EQ(static_cast<GLenum>(GL_RGB), info_->GetColorAttachmentFormat());
195 EXPECT_TRUE(info_->HasDepthAttachment());
196 EXPECT_TRUE(info_->HasStencilAttachment());
180 197
181 // Check marking the renderbuffer as unclared. 198 // Check marking the renderbuffer as unclared.
182 rb_info1->SetInfo(kSamples1, kFormat1, kWidth1, kHeight1); 199 rb_info1->SetInfo(kSamples1, kFormat1, kWidth1, kHeight1);
183 EXPECT_FALSE(info_->IsNotComplete()); 200 EXPECT_FALSE(info_->IsNotComplete());
201 EXPECT_EQ(static_cast<GLenum>(kFormat1), info_->GetColorAttachmentFormat());
202 EXPECT_TRUE(info_->HasDepthAttachment());
203 EXPECT_TRUE(info_->HasStencilAttachment());
184 204
185 const FramebufferManager::FramebufferInfo::Attachment* attachment = 205 const FramebufferManager::FramebufferInfo::Attachment* attachment =
186 info_->GetAttachment(GL_COLOR_ATTACHMENT0); 206 info_->GetAttachment(GL_COLOR_ATTACHMENT0);
187 ASSERT_TRUE(attachment != NULL); 207 ASSERT_TRUE(attachment != NULL);
188 EXPECT_EQ(kWidth1, attachment->width()); 208 EXPECT_EQ(kWidth1, attachment->width());
189 EXPECT_EQ(kHeight1, attachment->height()); 209 EXPECT_EQ(kHeight1, attachment->height());
190 EXPECT_EQ(kSamples1, attachment->samples()); 210 EXPECT_EQ(kSamples1, attachment->samples());
191 EXPECT_EQ(kFormat1, attachment->internal_format()); 211 EXPECT_EQ(kFormat1, attachment->internal_format());
192 EXPECT_FALSE(attachment->cleared()); 212 EXPECT_FALSE(attachment->cleared());
193 213
(...skipping 29 matching lines...) Expand all
223 ASSERT_TRUE(attachment != NULL); 243 ASSERT_TRUE(attachment != NULL);
224 EXPECT_EQ(kWidth3, attachment->width()); 244 EXPECT_EQ(kWidth3, attachment->width());
225 EXPECT_EQ(kHeight3, attachment->height()); 245 EXPECT_EQ(kHeight3, attachment->height());
226 EXPECT_EQ(kSamples3, attachment->samples()); 246 EXPECT_EQ(kSamples3, attachment->samples());
227 EXPECT_EQ(kFormat3, attachment->internal_format()); 247 EXPECT_EQ(kFormat3, attachment->internal_format());
228 EXPECT_FALSE(attachment->cleared()); 248 EXPECT_FALSE(attachment->cleared());
229 249
230 // Check removing it. 250 // Check removing it.
231 info_->AttachRenderbuffer(GL_STENCIL_ATTACHMENT, NULL); 251 info_->AttachRenderbuffer(GL_STENCIL_ATTACHMENT, NULL);
232 EXPECT_FALSE(info_->HasUnclearedAttachment(GL_STENCIL_ATTACHMENT)); 252 EXPECT_FALSE(info_->HasUnclearedAttachment(GL_STENCIL_ATTACHMENT));
253 EXPECT_EQ(static_cast<GLenum>(kFormat1), info_->GetColorAttachmentFormat());
254 EXPECT_TRUE(info_->HasDepthAttachment());
255 EXPECT_FALSE(info_->HasStencilAttachment());
233 256
234 rb_manager.Destroy(false); 257 rb_manager.Destroy(false);
235 } 258 }
236 259
237 TEST_F(FramebufferInfoTest, AttachTexture) { 260 TEST_F(FramebufferInfoTest, AttachTexture) {
238 const GLuint kTextureClient1Id = 33; 261 const GLuint kTextureClient1Id = 33;
239 const GLuint kTextureService1Id = 333; 262 const GLuint kTextureService1Id = 333;
240 const GLuint kTextureClient2Id = 34; 263 const GLuint kTextureClient2Id = 34;
241 const GLuint kTextureService2Id = 334; 264 const GLuint kTextureService2Id = 334;
242 const GLint kMaxTextureSize = 128; 265 const GLint kMaxTextureSize = 128;
(...skipping 28 matching lines...) Expand all
271 tex_manager.CreateTextureInfo( 294 tex_manager.CreateTextureInfo(
272 &feature_info, kTextureClient1Id, kTextureService1Id); 295 &feature_info, kTextureClient1Id, kTextureService1Id);
273 TextureManager::TextureInfo* tex_info1 = 296 TextureManager::TextureInfo* tex_info1 =
274 tex_manager.GetTextureInfo(kTextureClient1Id); 297 tex_manager.GetTextureInfo(kTextureClient1Id);
275 ASSERT_TRUE(tex_info1 != NULL); 298 ASSERT_TRUE(tex_info1 != NULL);
276 299
277 // check adding one attachment 300 // check adding one attachment
278 info_->AttachTexture(GL_COLOR_ATTACHMENT0, tex_info1, kTarget1, kLevel1); 301 info_->AttachTexture(GL_COLOR_ATTACHMENT0, tex_info1, kTarget1, kLevel1);
279 EXPECT_FALSE(info_->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0)); 302 EXPECT_FALSE(info_->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0));
280 EXPECT_TRUE(info_->IsNotComplete()); 303 EXPECT_TRUE(info_->IsNotComplete());
304 EXPECT_EQ(static_cast<GLenum>(0), info_->GetColorAttachmentFormat());
281 305
282 tex_manager.SetInfoTarget(tex_info1, GL_TEXTURE_2D); 306 tex_manager.SetInfoTarget(tex_info1, GL_TEXTURE_2D);
283 tex_manager.SetLevelInfo( 307 tex_manager.SetLevelInfo(
284 &feature_info, tex_info1, GL_TEXTURE_2D, kLevel1, 308 &feature_info, tex_info1, GL_TEXTURE_2D, kLevel1,
285 kFormat1, kWidth1, kHeight1, kDepth, kBorder, kFormat1, kType); 309 kFormat1, kWidth1, kHeight1, kDepth, kBorder, kFormat1, kType);
286 EXPECT_FALSE(info_->IsNotComplete()); 310 EXPECT_FALSE(info_->IsNotComplete());
311 EXPECT_EQ(static_cast<GLenum>(kFormat1), info_->GetColorAttachmentFormat());
287 312
288 const FramebufferManager::FramebufferInfo::Attachment* attachment = 313 const FramebufferManager::FramebufferInfo::Attachment* attachment =
289 info_->GetAttachment(GL_COLOR_ATTACHMENT0); 314 info_->GetAttachment(GL_COLOR_ATTACHMENT0);
290 ASSERT_TRUE(attachment != NULL); 315 ASSERT_TRUE(attachment != NULL);
291 EXPECT_EQ(kWidth1, attachment->width()); 316 EXPECT_EQ(kWidth1, attachment->width());
292 EXPECT_EQ(kHeight1, attachment->height()); 317 EXPECT_EQ(kHeight1, attachment->height());
293 EXPECT_EQ(kSamples1, attachment->samples()); 318 EXPECT_EQ(kSamples1, attachment->samples());
294 EXPECT_EQ(kFormat1, attachment->internal_format()); 319 EXPECT_EQ(kFormat1, attachment->internal_format());
295 EXPECT_TRUE(attachment->cleared()); 320 EXPECT_TRUE(attachment->cleared());
296 321
297 // Check replacing an attachment 322 // Check replacing an attachment
298 tex_manager.CreateTextureInfo( 323 tex_manager.CreateTextureInfo(
299 &feature_info, kTextureClient2Id, kTextureService2Id); 324 &feature_info, kTextureClient2Id, kTextureService2Id);
300 TextureManager::TextureInfo* tex_info2 = 325 TextureManager::TextureInfo* tex_info2 =
301 tex_manager.GetTextureInfo(kTextureClient2Id); 326 tex_manager.GetTextureInfo(kTextureClient2Id);
302 ASSERT_TRUE(tex_info2 != NULL); 327 ASSERT_TRUE(tex_info2 != NULL);
303 tex_manager.SetInfoTarget(tex_info2, GL_TEXTURE_2D); 328 tex_manager.SetInfoTarget(tex_info2, GL_TEXTURE_2D);
304 tex_manager.SetLevelInfo( 329 tex_manager.SetLevelInfo(
305 &feature_info, tex_info2, GL_TEXTURE_2D, kLevel2, 330 &feature_info, tex_info2, GL_TEXTURE_2D, kLevel2,
306 kFormat2, kWidth2, kHeight2, kDepth, kBorder, kFormat2, kType); 331 kFormat2, kWidth2, kHeight2, kDepth, kBorder, kFormat2, kType);
307 332
308 info_->AttachTexture(GL_COLOR_ATTACHMENT0, tex_info2, kTarget2, kLevel2); 333 info_->AttachTexture(GL_COLOR_ATTACHMENT0, tex_info2, kTarget2, kLevel2);
334 EXPECT_EQ(static_cast<GLenum>(kFormat2), info_->GetColorAttachmentFormat());
309 335
310 attachment = info_->GetAttachment(GL_COLOR_ATTACHMENT0); 336 attachment = info_->GetAttachment(GL_COLOR_ATTACHMENT0);
311 ASSERT_TRUE(attachment != NULL); 337 ASSERT_TRUE(attachment != NULL);
312 EXPECT_EQ(kWidth2, attachment->width()); 338 EXPECT_EQ(kWidth2, attachment->width());
313 EXPECT_EQ(kHeight2, attachment->height()); 339 EXPECT_EQ(kHeight2, attachment->height());
314 EXPECT_EQ(kSamples2, attachment->samples()); 340 EXPECT_EQ(kSamples2, attachment->samples());
315 EXPECT_EQ(kFormat2, attachment->internal_format()); 341 EXPECT_EQ(kFormat2, attachment->internal_format());
316 EXPECT_TRUE(attachment->cleared()); 342 EXPECT_TRUE(attachment->cleared());
317 343
318 // Check changing attachment 344 // Check changing attachment
319 tex_manager.SetLevelInfo( 345 tex_manager.SetLevelInfo(
320 &feature_info, tex_info2, GL_TEXTURE_2D, kLevel3, 346 &feature_info, tex_info2, GL_TEXTURE_2D, kLevel3,
321 kFormat3, kWidth3, kHeight3, kDepth, kBorder, kFormat3, kType); 347 kFormat3, kWidth3, kHeight3, kDepth, kBorder, kFormat3, kType);
322 attachment = info_->GetAttachment(GL_COLOR_ATTACHMENT0); 348 attachment = info_->GetAttachment(GL_COLOR_ATTACHMENT0);
323 ASSERT_TRUE(attachment != NULL); 349 ASSERT_TRUE(attachment != NULL);
324 EXPECT_EQ(kWidth3, attachment->width()); 350 EXPECT_EQ(kWidth3, attachment->width());
325 EXPECT_EQ(kHeight3, attachment->height()); 351 EXPECT_EQ(kHeight3, attachment->height());
326 EXPECT_EQ(kSamples3, attachment->samples()); 352 EXPECT_EQ(kSamples3, attachment->samples());
327 EXPECT_EQ(kFormat3, attachment->internal_format()); 353 EXPECT_EQ(kFormat3, attachment->internal_format());
328 EXPECT_TRUE(attachment->cleared()); 354 EXPECT_TRUE(attachment->cleared());
355 EXPECT_EQ(static_cast<GLenum>(kFormat3), info_->GetColorAttachmentFormat());
329 356
330 // Check removing it. 357 // Check removing it.
331 info_->AttachTexture(GL_COLOR_ATTACHMENT0, NULL, 0, 0); 358 info_->AttachTexture(GL_COLOR_ATTACHMENT0, NULL, 0, 0);
332 EXPECT_TRUE(info_->GetAttachment(GL_COLOR_ATTACHMENT0) == NULL); 359 EXPECT_TRUE(info_->GetAttachment(GL_COLOR_ATTACHMENT0) == NULL);
360 EXPECT_EQ(static_cast<GLenum>(0), info_->GetColorAttachmentFormat());
333 361
334 tex_manager.Destroy(false); 362 tex_manager.Destroy(false);
335 } 363 }
336 364
337 } // namespace gles2 365 } // namespace gles2
338 } // namespace gpu 366 } // namespace gpu
339 367
340 368
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/framebuffer_manager.cc ('k') | gpu/command_buffer/service/gles2_cmd_decoder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698