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

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

Issue 139013008: Implement support for rendering to 32-bit float textures on ES3 (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Check that framebuffers really are supported and add tests Created 6 years, 10 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/error_state_mock.h" 5 #include "gpu/command_buffer/service/error_state_mock.h"
6 #include "gpu/command_buffer/service/framebuffer_manager.h" 6 #include "gpu/command_buffer/service/framebuffer_manager.h"
7 #include "gpu/command_buffer/service/feature_info.h" 7 #include "gpu/command_buffer/service/feature_info.h"
8 #include "gpu/command_buffer/service/renderbuffer_manager.h" 8 #include "gpu/command_buffer/service/renderbuffer_manager.h"
9 #include "gpu/command_buffer/service/test_helper.h" 9 #include "gpu/command_buffer/service/test_helper.h"
10 #include "gpu/command_buffer/service/texture_manager.h" 10 #include "gpu/command_buffer/service/texture_manager.h"
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 EXPECT_EQ(kService1Id, framebuffer_->service_id()); 155 EXPECT_EQ(kService1Id, framebuffer_->service_id());
156 EXPECT_FALSE(framebuffer_->IsDeleted()); 156 EXPECT_FALSE(framebuffer_->IsDeleted());
157 EXPECT_TRUE(NULL == framebuffer_->GetAttachment(GL_COLOR_ATTACHMENT0)); 157 EXPECT_TRUE(NULL == framebuffer_->GetAttachment(GL_COLOR_ATTACHMENT0));
158 EXPECT_TRUE(NULL == framebuffer_->GetAttachment(GL_DEPTH_ATTACHMENT)); 158 EXPECT_TRUE(NULL == framebuffer_->GetAttachment(GL_DEPTH_ATTACHMENT));
159 EXPECT_TRUE(NULL == framebuffer_->GetAttachment(GL_STENCIL_ATTACHMENT)); 159 EXPECT_TRUE(NULL == framebuffer_->GetAttachment(GL_STENCIL_ATTACHMENT));
160 EXPECT_TRUE( 160 EXPECT_TRUE(
161 NULL == framebuffer_->GetAttachment(GL_DEPTH_STENCIL_ATTACHMENT)); 161 NULL == framebuffer_->GetAttachment(GL_DEPTH_STENCIL_ATTACHMENT));
162 EXPECT_FALSE(framebuffer_->HasDepthAttachment()); 162 EXPECT_FALSE(framebuffer_->HasDepthAttachment());
163 EXPECT_FALSE(framebuffer_->HasStencilAttachment()); 163 EXPECT_FALSE(framebuffer_->HasStencilAttachment());
164 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT), 164 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT),
165 framebuffer_->IsPossiblyComplete()); 165 framebuffer_->IsPossiblyComplete(false));
166 EXPECT_TRUE(framebuffer_->IsCleared()); 166 EXPECT_TRUE(framebuffer_->IsCleared());
167 EXPECT_EQ(static_cast<GLenum>(0), framebuffer_->GetColorAttachmentFormat()); 167 EXPECT_EQ(static_cast<GLenum>(0), framebuffer_->GetColorAttachmentFormat());
168 EXPECT_FALSE(manager_.IsComplete(framebuffer_)); 168 EXPECT_FALSE(manager_.IsComplete(framebuffer_));
169 } 169 }
170 170
171 TEST_F(FramebufferInfoTest, AttachRenderbuffer) { 171 TEST_F(FramebufferInfoTest, AttachRenderbuffer) {
172 const GLuint kRenderbufferClient1Id = 33; 172 const GLuint kRenderbufferClient1Id = 33;
173 const GLuint kRenderbufferService1Id = 333; 173 const GLuint kRenderbufferService1Id = 333;
174 const GLuint kRenderbufferClient2Id = 34; 174 const GLuint kRenderbufferClient2Id = 34;
175 const GLuint kRenderbufferService2Id = 334; 175 const GLuint kRenderbufferService2Id = 334;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 209
210 // check adding one attachment 210 // check adding one attachment
211 framebuffer_->AttachRenderbuffer(GL_COLOR_ATTACHMENT0, renderbuffer1); 211 framebuffer_->AttachRenderbuffer(GL_COLOR_ATTACHMENT0, renderbuffer1);
212 EXPECT_FALSE(framebuffer_->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0)); 212 EXPECT_FALSE(framebuffer_->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0));
213 EXPECT_FALSE(framebuffer_->HasUnclearedAttachment(GL_DEPTH_ATTACHMENT)); 213 EXPECT_FALSE(framebuffer_->HasUnclearedAttachment(GL_DEPTH_ATTACHMENT));
214 EXPECT_EQ(static_cast<GLenum>(GL_RGBA4), 214 EXPECT_EQ(static_cast<GLenum>(GL_RGBA4),
215 framebuffer_->GetColorAttachmentFormat()); 215 framebuffer_->GetColorAttachmentFormat());
216 EXPECT_FALSE(framebuffer_->HasDepthAttachment()); 216 EXPECT_FALSE(framebuffer_->HasDepthAttachment());
217 EXPECT_FALSE(framebuffer_->HasStencilAttachment()); 217 EXPECT_FALSE(framebuffer_->HasStencilAttachment());
218 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT), 218 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT),
219 framebuffer_->IsPossiblyComplete()); 219 framebuffer_->IsPossiblyComplete(false));
220 EXPECT_TRUE(framebuffer_->IsCleared()); 220 EXPECT_TRUE(framebuffer_->IsCleared());
221 221
222 // Try a format that's not good for COLOR_ATTACHMENT0. 222 // Try a format that's not good for COLOR_ATTACHMENT0.
223 renderbuffer_manager_.SetInfo( 223 renderbuffer_manager_.SetInfo(
224 renderbuffer1, kSamples1, kBadFormat1, kWidth1, kHeight1); 224 renderbuffer1, kSamples1, kBadFormat1, kWidth1, kHeight1);
225 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT), 225 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT),
226 framebuffer_->IsPossiblyComplete()); 226 framebuffer_->IsPossiblyComplete(false));
227 227
228 // Try a good format. 228 // Try a good format.
229 renderbuffer_manager_.SetInfo( 229 renderbuffer_manager_.SetInfo(
230 renderbuffer1, kSamples1, kFormat1, kWidth1, kHeight1); 230 renderbuffer1, kSamples1, kFormat1, kWidth1, kHeight1);
231 EXPECT_EQ(static_cast<GLenum>(kFormat1), 231 EXPECT_EQ(static_cast<GLenum>(kFormat1),
232 framebuffer_->GetColorAttachmentFormat()); 232 framebuffer_->GetColorAttachmentFormat());
233 EXPECT_FALSE(framebuffer_->HasDepthAttachment()); 233 EXPECT_FALSE(framebuffer_->HasDepthAttachment());
234 EXPECT_FALSE(framebuffer_->HasStencilAttachment()); 234 EXPECT_FALSE(framebuffer_->HasStencilAttachment());
235 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE), 235 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE),
236 framebuffer_->IsPossiblyComplete()); 236 framebuffer_->IsPossiblyComplete(false));
237 EXPECT_FALSE(framebuffer_->IsCleared()); 237 EXPECT_FALSE(framebuffer_->IsCleared());
238 238
239 // check adding another 239 // check adding another
240 renderbuffer_manager_.CreateRenderbuffer( 240 renderbuffer_manager_.CreateRenderbuffer(
241 kRenderbufferClient2Id, kRenderbufferService2Id); 241 kRenderbufferClient2Id, kRenderbufferService2Id);
242 Renderbuffer* renderbuffer2 = 242 Renderbuffer* renderbuffer2 =
243 renderbuffer_manager_.GetRenderbuffer(kRenderbufferClient2Id); 243 renderbuffer_manager_.GetRenderbuffer(kRenderbufferClient2Id);
244 ASSERT_TRUE(renderbuffer2 != NULL); 244 ASSERT_TRUE(renderbuffer2 != NULL);
245 framebuffer_->AttachRenderbuffer(GL_DEPTH_ATTACHMENT, renderbuffer2); 245 framebuffer_->AttachRenderbuffer(GL_DEPTH_ATTACHMENT, renderbuffer2);
246 EXPECT_TRUE(framebuffer_->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0)); 246 EXPECT_TRUE(framebuffer_->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0));
247 EXPECT_FALSE(framebuffer_->HasUnclearedAttachment(GL_DEPTH_ATTACHMENT)); 247 EXPECT_FALSE(framebuffer_->HasUnclearedAttachment(GL_DEPTH_ATTACHMENT));
248 EXPECT_EQ(static_cast<GLenum>(kFormat1), 248 EXPECT_EQ(static_cast<GLenum>(kFormat1),
249 framebuffer_->GetColorAttachmentFormat()); 249 framebuffer_->GetColorAttachmentFormat());
250 EXPECT_TRUE(framebuffer_->HasDepthAttachment()); 250 EXPECT_TRUE(framebuffer_->HasDepthAttachment());
251 EXPECT_FALSE(framebuffer_->HasStencilAttachment()); 251 EXPECT_FALSE(framebuffer_->HasStencilAttachment());
252 // The attachment has a size of 0,0 so depending on the order of the map 252 // The attachment has a size of 0,0 so depending on the order of the map
253 // of attachments it could either get INCOMPLETE_ATTACHMENT because it's 0,0 253 // of attachments it could either get INCOMPLETE_ATTACHMENT because it's 0,0
254 // or INCOMPLETE_DIMENSIONS because it's not the same size as the other 254 // or INCOMPLETE_DIMENSIONS because it's not the same size as the other
255 // attachment. 255 // attachment.
256 GLenum status = framebuffer_->IsPossiblyComplete(); 256 GLenum status = framebuffer_->IsPossiblyComplete(false);
257 EXPECT_TRUE( 257 EXPECT_TRUE(
258 status == GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT || 258 status == GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT ||
259 status == GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT); 259 status == GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT);
260 EXPECT_FALSE(framebuffer_->IsCleared()); 260 EXPECT_FALSE(framebuffer_->IsCleared());
261 261
262 renderbuffer_manager_.SetInfo( 262 renderbuffer_manager_.SetInfo(
263 renderbuffer2, kSamples2, kFormat2, kWidth2, kHeight2); 263 renderbuffer2, kSamples2, kFormat2, kWidth2, kHeight2);
264 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE), 264 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE),
265 framebuffer_->IsPossiblyComplete()); 265 framebuffer_->IsPossiblyComplete(false));
266 EXPECT_FALSE(framebuffer_->IsCleared()); 266 EXPECT_FALSE(framebuffer_->IsCleared());
267 EXPECT_TRUE(framebuffer_->HasUnclearedAttachment(GL_DEPTH_ATTACHMENT)); 267 EXPECT_TRUE(framebuffer_->HasUnclearedAttachment(GL_DEPTH_ATTACHMENT));
268 268
269 // check marking them as cleared. 269 // check marking them as cleared.
270 manager_.MarkAttachmentsAsCleared( 270 manager_.MarkAttachmentsAsCleared(
271 framebuffer_, &renderbuffer_manager_, &texture_manager_); 271 framebuffer_, &renderbuffer_manager_, &texture_manager_);
272 EXPECT_FALSE(framebuffer_->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0)); 272 EXPECT_FALSE(framebuffer_->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0));
273 EXPECT_FALSE(framebuffer_->HasUnclearedAttachment(GL_DEPTH_ATTACHMENT)); 273 EXPECT_FALSE(framebuffer_->HasUnclearedAttachment(GL_DEPTH_ATTACHMENT));
274 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE), 274 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE),
275 framebuffer_->IsPossiblyComplete()); 275 framebuffer_->IsPossiblyComplete(false));
276 EXPECT_TRUE(framebuffer_->IsCleared()); 276 EXPECT_TRUE(framebuffer_->IsCleared());
277 277
278 // Check adding one that is already cleared. 278 // Check adding one that is already cleared.
279 renderbuffer_manager_.CreateRenderbuffer( 279 renderbuffer_manager_.CreateRenderbuffer(
280 kRenderbufferClient3Id, kRenderbufferService3Id); 280 kRenderbufferClient3Id, kRenderbufferService3Id);
281 Renderbuffer* renderbuffer3 = 281 Renderbuffer* renderbuffer3 =
282 renderbuffer_manager_.GetRenderbuffer(kRenderbufferClient3Id); 282 renderbuffer_manager_.GetRenderbuffer(kRenderbufferClient3Id);
283 ASSERT_TRUE(renderbuffer3 != NULL); 283 ASSERT_TRUE(renderbuffer3 != NULL);
284 renderbuffer_manager_.SetInfo( 284 renderbuffer_manager_.SetInfo(
285 renderbuffer3, kSamples3, kFormat3, kWidth3, kHeight3); 285 renderbuffer3, kSamples3, kFormat3, kWidth3, kHeight3);
286 renderbuffer_manager_.SetCleared(renderbuffer3, true); 286 renderbuffer_manager_.SetCleared(renderbuffer3, true);
287 287
288 framebuffer_->AttachRenderbuffer(GL_STENCIL_ATTACHMENT, renderbuffer3); 288 framebuffer_->AttachRenderbuffer(GL_STENCIL_ATTACHMENT, renderbuffer3);
289 EXPECT_FALSE(framebuffer_->HasUnclearedAttachment(GL_STENCIL_ATTACHMENT)); 289 EXPECT_FALSE(framebuffer_->HasUnclearedAttachment(GL_STENCIL_ATTACHMENT));
290 EXPECT_EQ(static_cast<GLenum>(kFormat1), 290 EXPECT_EQ(static_cast<GLenum>(kFormat1),
291 framebuffer_->GetColorAttachmentFormat()); 291 framebuffer_->GetColorAttachmentFormat());
292 EXPECT_TRUE(framebuffer_->HasDepthAttachment()); 292 EXPECT_TRUE(framebuffer_->HasDepthAttachment());
293 EXPECT_TRUE(framebuffer_->HasStencilAttachment()); 293 EXPECT_TRUE(framebuffer_->HasStencilAttachment());
294 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE), 294 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE),
295 framebuffer_->IsPossiblyComplete()); 295 framebuffer_->IsPossiblyComplete(false));
296 EXPECT_TRUE(framebuffer_->IsCleared()); 296 EXPECT_TRUE(framebuffer_->IsCleared());
297 297
298 // Check marking the renderbuffer as unclared. 298 // Check marking the renderbuffer as unclared.
299 renderbuffer_manager_.SetInfo( 299 renderbuffer_manager_.SetInfo(
300 renderbuffer1, kSamples1, kFormat1, kWidth1, kHeight1); 300 renderbuffer1, kSamples1, kFormat1, kWidth1, kHeight1);
301 EXPECT_EQ(static_cast<GLenum>(kFormat1), 301 EXPECT_EQ(static_cast<GLenum>(kFormat1),
302 framebuffer_->GetColorAttachmentFormat()); 302 framebuffer_->GetColorAttachmentFormat());
303 EXPECT_TRUE(framebuffer_->HasDepthAttachment()); 303 EXPECT_TRUE(framebuffer_->HasDepthAttachment());
304 EXPECT_TRUE(framebuffer_->HasStencilAttachment()); 304 EXPECT_TRUE(framebuffer_->HasStencilAttachment());
305 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE), 305 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE),
306 framebuffer_->IsPossiblyComplete()); 306 framebuffer_->IsPossiblyComplete(false));
307 EXPECT_FALSE(framebuffer_->IsCleared()); 307 EXPECT_FALSE(framebuffer_->IsCleared());
308 308
309 const Framebuffer::Attachment* attachment = 309 const Framebuffer::Attachment* attachment =
310 framebuffer_->GetAttachment(GL_COLOR_ATTACHMENT0); 310 framebuffer_->GetAttachment(GL_COLOR_ATTACHMENT0);
311 ASSERT_TRUE(attachment != NULL); 311 ASSERT_TRUE(attachment != NULL);
312 EXPECT_EQ(kWidth1, attachment->width()); 312 EXPECT_EQ(kWidth1, attachment->width());
313 EXPECT_EQ(kHeight1, attachment->height()); 313 EXPECT_EQ(kHeight1, attachment->height());
314 EXPECT_EQ(kSamples1, attachment->samples()); 314 EXPECT_EQ(kSamples1, attachment->samples());
315 EXPECT_EQ(kFormat1, attachment->internal_format()); 315 EXPECT_EQ(kFormat1, attachment->internal_format());
316 EXPECT_FALSE(attachment->cleared()); 316 EXPECT_FALSE(attachment->cleared());
(...skipping 20 matching lines...) Expand all
337 EXPECT_FALSE(framebuffer_->IsCleared()); 337 EXPECT_FALSE(framebuffer_->IsCleared());
338 338
339 attachment = framebuffer_->GetAttachment(GL_STENCIL_ATTACHMENT); 339 attachment = framebuffer_->GetAttachment(GL_STENCIL_ATTACHMENT);
340 ASSERT_TRUE(attachment != NULL); 340 ASSERT_TRUE(attachment != NULL);
341 EXPECT_EQ(kWidth4, attachment->width()); 341 EXPECT_EQ(kWidth4, attachment->width());
342 EXPECT_EQ(kHeight4, attachment->height()); 342 EXPECT_EQ(kHeight4, attachment->height());
343 EXPECT_EQ(kSamples4, attachment->samples()); 343 EXPECT_EQ(kSamples4, attachment->samples());
344 EXPECT_EQ(kFormat4, attachment->internal_format()); 344 EXPECT_EQ(kFormat4, attachment->internal_format());
345 EXPECT_FALSE(attachment->cleared()); 345 EXPECT_FALSE(attachment->cleared());
346 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE), 346 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE),
347 framebuffer_->IsPossiblyComplete()); 347 framebuffer_->IsPossiblyComplete(false));
348 348
349 // Check changing an attachment. 349 // Check changing an attachment.
350 renderbuffer_manager_.SetInfo( 350 renderbuffer_manager_.SetInfo(
351 renderbuffer4, kSamples4, kFormat4, kWidth4 + 1, kHeight4); 351 renderbuffer4, kSamples4, kFormat4, kWidth4 + 1, kHeight4);
352 352
353 attachment = framebuffer_->GetAttachment(GL_STENCIL_ATTACHMENT); 353 attachment = framebuffer_->GetAttachment(GL_STENCIL_ATTACHMENT);
354 ASSERT_TRUE(attachment != NULL); 354 ASSERT_TRUE(attachment != NULL);
355 EXPECT_EQ(kWidth4 + 1, attachment->width()); 355 EXPECT_EQ(kWidth4 + 1, attachment->width());
356 EXPECT_EQ(kHeight4, attachment->height()); 356 EXPECT_EQ(kHeight4, attachment->height());
357 EXPECT_EQ(kSamples4, attachment->samples()); 357 EXPECT_EQ(kSamples4, attachment->samples());
358 EXPECT_EQ(kFormat4, attachment->internal_format()); 358 EXPECT_EQ(kFormat4, attachment->internal_format());
359 EXPECT_FALSE(attachment->cleared()); 359 EXPECT_FALSE(attachment->cleared());
360 EXPECT_FALSE(framebuffer_->IsCleared()); 360 EXPECT_FALSE(framebuffer_->IsCleared());
361 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT), 361 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT),
362 framebuffer_->IsPossiblyComplete()); 362 framebuffer_->IsPossiblyComplete(false));
363 363
364 // Check removing it. 364 // Check removing it.
365 framebuffer_->AttachRenderbuffer(GL_STENCIL_ATTACHMENT, NULL); 365 framebuffer_->AttachRenderbuffer(GL_STENCIL_ATTACHMENT, NULL);
366 EXPECT_FALSE(framebuffer_->HasUnclearedAttachment(GL_STENCIL_ATTACHMENT)); 366 EXPECT_FALSE(framebuffer_->HasUnclearedAttachment(GL_STENCIL_ATTACHMENT));
367 EXPECT_EQ(static_cast<GLenum>(kFormat1), 367 EXPECT_EQ(static_cast<GLenum>(kFormat1),
368 framebuffer_->GetColorAttachmentFormat()); 368 framebuffer_->GetColorAttachmentFormat());
369 EXPECT_TRUE(framebuffer_->HasDepthAttachment()); 369 EXPECT_TRUE(framebuffer_->HasDepthAttachment());
370 EXPECT_FALSE(framebuffer_->HasStencilAttachment()); 370 EXPECT_FALSE(framebuffer_->HasStencilAttachment());
371 371
372 EXPECT_TRUE(framebuffer_->IsCleared()); 372 EXPECT_TRUE(framebuffer_->IsCleared());
373 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE), 373 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE),
374 framebuffer_->IsPossiblyComplete()); 374 framebuffer_->IsPossiblyComplete(false));
375 375
376 // Remove depth, Set color to 0 size. 376 // Remove depth, Set color to 0 size.
377 framebuffer_->AttachRenderbuffer(GL_DEPTH_ATTACHMENT, NULL); 377 framebuffer_->AttachRenderbuffer(GL_DEPTH_ATTACHMENT, NULL);
378 renderbuffer_manager_.SetInfo(renderbuffer1, kSamples1, kFormat1, 0, 0); 378 renderbuffer_manager_.SetInfo(renderbuffer1, kSamples1, kFormat1, 0, 0);
379 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT), 379 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT),
380 framebuffer_->IsPossiblyComplete()); 380 framebuffer_->IsPossiblyComplete(false));
381 381
382 // Remove color. 382 // Remove color.
383 framebuffer_->AttachRenderbuffer(GL_COLOR_ATTACHMENT0, NULL); 383 framebuffer_->AttachRenderbuffer(GL_COLOR_ATTACHMENT0, NULL);
384 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT), 384 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT),
385 framebuffer_->IsPossiblyComplete()); 385 framebuffer_->IsPossiblyComplete(false));
386 } 386 }
387 387
388 TEST_F(FramebufferInfoTest, AttachTexture) { 388 TEST_F(FramebufferInfoTest, AttachTexture) {
389 const GLuint kTextureClient1Id = 33; 389 const GLuint kTextureClient1Id = 33;
390 const GLuint kTextureService1Id = 333; 390 const GLuint kTextureService1Id = 333;
391 const GLuint kTextureClient2Id = 34; 391 const GLuint kTextureClient2Id = 34;
392 const GLuint kTextureService2Id = 334; 392 const GLuint kTextureService2Id = 334;
393 const GLint kDepth = 1; 393 const GLint kDepth = 1;
394 const GLint kBorder = 0; 394 const GLint kBorder = 0;
395 const GLenum kType = GL_UNSIGNED_BYTE; 395 const GLenum kType = GL_UNSIGNED_BYTE;
(...skipping 14 matching lines...) Expand all
410 const GLsizei kHeight3 = 123; 410 const GLsizei kHeight3 = 123;
411 const GLint kLevel3 = 0; 411 const GLint kLevel3 = 0;
412 const GLenum kFormat3 = GL_RGB565; 412 const GLenum kFormat3 = GL_RGB565;
413 const GLsizei kSamples3 = 0; 413 const GLsizei kSamples3 = 0;
414 EXPECT_FALSE(framebuffer_->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0)); 414 EXPECT_FALSE(framebuffer_->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0));
415 EXPECT_FALSE(framebuffer_->HasUnclearedAttachment(GL_DEPTH_ATTACHMENT)); 415 EXPECT_FALSE(framebuffer_->HasUnclearedAttachment(GL_DEPTH_ATTACHMENT));
416 EXPECT_FALSE(framebuffer_->HasUnclearedAttachment(GL_STENCIL_ATTACHMENT)); 416 EXPECT_FALSE(framebuffer_->HasUnclearedAttachment(GL_STENCIL_ATTACHMENT));
417 EXPECT_FALSE( 417 EXPECT_FALSE(
418 framebuffer_->HasUnclearedAttachment(GL_DEPTH_STENCIL_ATTACHMENT)); 418 framebuffer_->HasUnclearedAttachment(GL_DEPTH_STENCIL_ATTACHMENT));
419 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT), 419 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT),
420 framebuffer_->IsPossiblyComplete()); 420 framebuffer_->IsPossiblyComplete(false));
421 421
422 texture_manager_.CreateTexture(kTextureClient1Id, kTextureService1Id); 422 texture_manager_.CreateTexture(kTextureClient1Id, kTextureService1Id);
423 scoped_refptr<TextureRef> texture1( 423 scoped_refptr<TextureRef> texture1(
424 texture_manager_.GetTexture(kTextureClient1Id)); 424 texture_manager_.GetTexture(kTextureClient1Id));
425 ASSERT_TRUE(texture1.get() != NULL); 425 ASSERT_TRUE(texture1.get() != NULL);
426 426
427 // check adding one attachment 427 // check adding one attachment
428 framebuffer_->AttachTexture( 428 framebuffer_->AttachTexture(
429 GL_COLOR_ATTACHMENT0, texture1.get(), kTarget1, kLevel1, kSamples1); 429 GL_COLOR_ATTACHMENT0, texture1.get(), kTarget1, kLevel1, kSamples1);
430 EXPECT_FALSE(framebuffer_->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0)); 430 EXPECT_FALSE(framebuffer_->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0));
431 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT), 431 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT),
432 framebuffer_->IsPossiblyComplete()); 432 framebuffer_->IsPossiblyComplete(false));
433 EXPECT_TRUE(framebuffer_->IsCleared()); 433 EXPECT_TRUE(framebuffer_->IsCleared());
434 EXPECT_EQ(static_cast<GLenum>(0), framebuffer_->GetColorAttachmentFormat()); 434 EXPECT_EQ(static_cast<GLenum>(0), framebuffer_->GetColorAttachmentFormat());
435 435
436 // Try format that doesn't work with COLOR_ATTACHMENT0 436 // Try format that doesn't work with COLOR_ATTACHMENT0
437 texture_manager_.SetTarget(texture1.get(), GL_TEXTURE_2D); 437 texture_manager_.SetTarget(texture1.get(), GL_TEXTURE_2D);
438 texture_manager_.SetLevelInfo(texture1.get(), 438 texture_manager_.SetLevelInfo(texture1.get(),
439 GL_TEXTURE_2D, 439 GL_TEXTURE_2D,
440 kLevel1, 440 kLevel1,
441 kBadFormat1, 441 kBadFormat1,
442 kWidth1, 442 kWidth1,
443 kHeight1, 443 kHeight1,
444 kDepth, 444 kDepth,
445 kBorder, 445 kBorder,
446 kBadFormat1, 446 kBadFormat1,
447 kType, 447 kType,
448 true); 448 true);
449 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT), 449 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT),
450 framebuffer_->IsPossiblyComplete()); 450 framebuffer_->IsPossiblyComplete(false));
451 451
452 // Try a good format. 452 // Try a good format.
453 texture_manager_.SetLevelInfo(texture1.get(), 453 texture_manager_.SetLevelInfo(texture1.get(),
454 GL_TEXTURE_2D, 454 GL_TEXTURE_2D,
455 kLevel1, 455 kLevel1,
456 kFormat1, 456 kFormat1,
457 kWidth1, 457 kWidth1,
458 kHeight1, 458 kHeight1,
459 kDepth, 459 kDepth,
460 kBorder, 460 kBorder,
461 kFormat1, 461 kFormat1,
462 kType, 462 kType,
463 false); 463 false);
464 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE), 464 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE),
465 framebuffer_->IsPossiblyComplete()); 465 framebuffer_->IsPossiblyComplete(false));
466 EXPECT_FALSE(framebuffer_->IsCleared()); 466 EXPECT_FALSE(framebuffer_->IsCleared());
467 texture_manager_.SetLevelInfo(texture1.get(), 467 texture_manager_.SetLevelInfo(texture1.get(),
468 GL_TEXTURE_2D, 468 GL_TEXTURE_2D,
469 kLevel1, 469 kLevel1,
470 kFormat1, 470 kFormat1,
471 kWidth1, 471 kWidth1,
472 kHeight1, 472 kHeight1,
473 kDepth, 473 kDepth,
474 kBorder, 474 kBorder,
475 kFormat1, 475 kFormat1,
476 kType, 476 kType,
477 true); 477 true);
478 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE), 478 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE),
479 framebuffer_->IsPossiblyComplete()); 479 framebuffer_->IsPossiblyComplete(false));
480 EXPECT_TRUE(framebuffer_->IsCleared()); 480 EXPECT_TRUE(framebuffer_->IsCleared());
481 EXPECT_EQ(static_cast<GLenum>(kFormat1), 481 EXPECT_EQ(static_cast<GLenum>(kFormat1),
482 framebuffer_->GetColorAttachmentFormat()); 482 framebuffer_->GetColorAttachmentFormat());
483 483
484 const Framebuffer::Attachment* attachment = 484 const Framebuffer::Attachment* attachment =
485 framebuffer_->GetAttachment(GL_COLOR_ATTACHMENT0); 485 framebuffer_->GetAttachment(GL_COLOR_ATTACHMENT0);
486 ASSERT_TRUE(attachment != NULL); 486 ASSERT_TRUE(attachment != NULL);
487 EXPECT_EQ(kWidth1, attachment->width()); 487 EXPECT_EQ(kWidth1, attachment->width());
488 EXPECT_EQ(kHeight1, attachment->height()); 488 EXPECT_EQ(kHeight1, attachment->height());
489 EXPECT_EQ(kSamples1, attachment->samples()); 489 EXPECT_EQ(kSamples1, attachment->samples());
(...skipping 16 matching lines...) Expand all
506 kBorder, 506 kBorder,
507 kFormat2, 507 kFormat2,
508 kType, 508 kType,
509 true); 509 true);
510 510
511 framebuffer_->AttachTexture( 511 framebuffer_->AttachTexture(
512 GL_COLOR_ATTACHMENT0, texture2.get(), kTarget2, kLevel2, kSamples2); 512 GL_COLOR_ATTACHMENT0, texture2.get(), kTarget2, kLevel2, kSamples2);
513 EXPECT_EQ(static_cast<GLenum>(kFormat2), 513 EXPECT_EQ(static_cast<GLenum>(kFormat2),
514 framebuffer_->GetColorAttachmentFormat()); 514 framebuffer_->GetColorAttachmentFormat());
515 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE), 515 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE),
516 framebuffer_->IsPossiblyComplete()); 516 framebuffer_->IsPossiblyComplete(false));
517 EXPECT_TRUE(framebuffer_->IsCleared()); 517 EXPECT_TRUE(framebuffer_->IsCleared());
518 518
519 attachment = framebuffer_->GetAttachment(GL_COLOR_ATTACHMENT0); 519 attachment = framebuffer_->GetAttachment(GL_COLOR_ATTACHMENT0);
520 ASSERT_TRUE(attachment != NULL); 520 ASSERT_TRUE(attachment != NULL);
521 EXPECT_EQ(kWidth2, attachment->width()); 521 EXPECT_EQ(kWidth2, attachment->width());
522 EXPECT_EQ(kHeight2, attachment->height()); 522 EXPECT_EQ(kHeight2, attachment->height());
523 EXPECT_EQ(kSamples2, attachment->samples()); 523 EXPECT_EQ(kSamples2, attachment->samples());
524 EXPECT_EQ(kFormat2, attachment->internal_format()); 524 EXPECT_EQ(kFormat2, attachment->internal_format());
525 EXPECT_TRUE(attachment->cleared()); 525 EXPECT_TRUE(attachment->cleared());
526 526
(...skipping 12 matching lines...) Expand all
539 attachment = framebuffer_->GetAttachment(GL_COLOR_ATTACHMENT0); 539 attachment = framebuffer_->GetAttachment(GL_COLOR_ATTACHMENT0);
540 ASSERT_TRUE(attachment != NULL); 540 ASSERT_TRUE(attachment != NULL);
541 EXPECT_EQ(kWidth3, attachment->width()); 541 EXPECT_EQ(kWidth3, attachment->width());
542 EXPECT_EQ(kHeight3, attachment->height()); 542 EXPECT_EQ(kHeight3, attachment->height());
543 EXPECT_EQ(kSamples3, attachment->samples()); 543 EXPECT_EQ(kSamples3, attachment->samples());
544 EXPECT_EQ(kFormat3, attachment->internal_format()); 544 EXPECT_EQ(kFormat3, attachment->internal_format());
545 EXPECT_FALSE(attachment->cleared()); 545 EXPECT_FALSE(attachment->cleared());
546 EXPECT_EQ(static_cast<GLenum>(kFormat3), 546 EXPECT_EQ(static_cast<GLenum>(kFormat3),
547 framebuffer_->GetColorAttachmentFormat()); 547 framebuffer_->GetColorAttachmentFormat());
548 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE), 548 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE),
549 framebuffer_->IsPossiblyComplete()); 549 framebuffer_->IsPossiblyComplete(false));
550 EXPECT_FALSE(framebuffer_->IsCleared()); 550 EXPECT_FALSE(framebuffer_->IsCleared());
551 551
552 // Set to size 0 552 // Set to size 0
553 texture_manager_.SetLevelInfo(texture2.get(), 553 texture_manager_.SetLevelInfo(texture2.get(),
554 GL_TEXTURE_2D, 554 GL_TEXTURE_2D,
555 kLevel3, 555 kLevel3,
556 kFormat3, 556 kFormat3,
557 0, 557 0,
558 0, 558 0,
559 kDepth, 559 kDepth,
560 kBorder, 560 kBorder,
561 kFormat3, 561 kFormat3,
562 kType, 562 kType,
563 false); 563 false);
564 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT), 564 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT),
565 framebuffer_->IsPossiblyComplete()); 565 framebuffer_->IsPossiblyComplete(false));
566 566
567 // Check removing it. 567 // Check removing it.
568 framebuffer_->AttachTexture(GL_COLOR_ATTACHMENT0, NULL, 0, 0, 0); 568 framebuffer_->AttachTexture(GL_COLOR_ATTACHMENT0, NULL, 0, 0, 0);
569 EXPECT_TRUE(framebuffer_->GetAttachment(GL_COLOR_ATTACHMENT0) == NULL); 569 EXPECT_TRUE(framebuffer_->GetAttachment(GL_COLOR_ATTACHMENT0) == NULL);
570 EXPECT_EQ(static_cast<GLenum>(0), framebuffer_->GetColorAttachmentFormat()); 570 EXPECT_EQ(static_cast<GLenum>(0), framebuffer_->GetColorAttachmentFormat());
571 571
572 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT), 572 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT),
573 framebuffer_->IsPossiblyComplete()); 573 framebuffer_->IsPossiblyComplete(false));
574 EXPECT_TRUE(framebuffer_->IsCleared()); 574 EXPECT_TRUE(framebuffer_->IsCleared());
575 } 575 }
576 576
577 TEST_F(FramebufferInfoTest, AttachFloatTexture) {
578 const GLuint kTextureClientId = 33;
579 const GLuint kTextureServiceId = 333;
580 const GLint kDepth = 1;
581 const GLint kBorder = 0;
582 const GLenum kType = GL_FLOAT;
583 const GLsizei kWidth = 16;
584 const GLsizei kHeight = 32;
585 const GLint kLevel = 0;
586 const GLenum kFormat = GL_RGBA;
587 const GLenum kInternalFormat = GL_RGBA32F;
588 const GLenum kBadInternalFormat = GL_RGBA;
589 const GLenum kTarget = GL_TEXTURE_2D;
590 const GLsizei kSamples = 0;
591 EXPECT_FALSE(framebuffer_->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0));
592 EXPECT_FALSE(framebuffer_->HasUnclearedAttachment(GL_DEPTH_ATTACHMENT));
593 EXPECT_FALSE(framebuffer_->HasUnclearedAttachment(GL_STENCIL_ATTACHMENT));
594
595 texture_manager_.CreateTexture(kTextureClientId, kTextureServiceId);
596 scoped_refptr<TextureRef> texture(
597 texture_manager_.GetTexture(kTextureClientId));
598 ASSERT_TRUE(texture.get() != NULL);
599
600 // check adding one attachment
601 framebuffer_->AttachTexture(
602 GL_COLOR_ATTACHMENT0, texture.get(), kTarget, kLevel, kSamples);
603 EXPECT_EQ(static_cast<GLenum>(0), framebuffer_->GetColorAttachmentFormat());
604
605 // Try unsized internalformat
606 texture_manager_.SetTarget(texture.get(), GL_TEXTURE_2D);
607 texture_manager_.SetLevelInfo(texture.get(),
608 GL_TEXTURE_2D,
609 kLevel,
610 kBadInternalFormat,
611 kWidth,
612 kHeight,
613 kDepth,
614 kBorder,
615 kFormat,
616 kType,
617 true);
618 // Texture with an unsized internalformat is not allowed as an attachment
619 // regardless of whether float color attachments are allowed in general.
620 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT),
621 framebuffer_->IsPossiblyComplete(false));
622 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT),
623 framebuffer_->IsPossiblyComplete(true));
624
625 // Try a good format.
626 texture_manager_.SetLevelInfo(texture.get(),
627 GL_TEXTURE_2D,
628 kLevel,
629 kInternalFormat,
630 kWidth,
631 kHeight,
632 kDepth,
633 kBorder,
634 kFormat,
635 kType,
636 false);
637 // Texture with a sized float internalformat is allowed as an attachment
638 // only if float color attachments allowed flag is true.
639 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT),
640 framebuffer_->IsPossiblyComplete(false));
641 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE),
642 framebuffer_->IsPossiblyComplete(true));
643
644 }
645
577 TEST_F(FramebufferInfoTest, UnbindRenderbuffer) { 646 TEST_F(FramebufferInfoTest, UnbindRenderbuffer) {
578 const GLuint kRenderbufferClient1Id = 33; 647 const GLuint kRenderbufferClient1Id = 33;
579 const GLuint kRenderbufferService1Id = 333; 648 const GLuint kRenderbufferService1Id = 333;
580 const GLuint kRenderbufferClient2Id = 34; 649 const GLuint kRenderbufferClient2Id = 34;
581 const GLuint kRenderbufferService2Id = 334; 650 const GLuint kRenderbufferService2Id = 334;
582 651
583 renderbuffer_manager_.CreateRenderbuffer( 652 renderbuffer_manager_.CreateRenderbuffer(
584 kRenderbufferClient1Id, kRenderbufferService1Id); 653 kRenderbufferClient1Id, kRenderbufferService1Id);
585 Renderbuffer* renderbuffer1 = 654 Renderbuffer* renderbuffer1 =
586 renderbuffer_manager_.GetRenderbuffer(kRenderbufferClient1Id); 655 renderbuffer_manager_.GetRenderbuffer(kRenderbufferClient1Id);
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
811 .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE)) 880 .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE))
812 .RetiresOnSaturation(); 881 .RetiresOnSaturation();
813 } 882 }
814 framebuffer_->GetStatus(&texture_manager_, GL_READ_FRAMEBUFFER); 883 framebuffer_->GetStatus(&texture_manager_, GL_READ_FRAMEBUFFER);
815 } 884 }
816 885
817 } // namespace gles2 886 } // namespace gles2
818 } // namespace gpu 887 } // namespace gpu
819 888
820 889
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698