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

Side by Side Diff: gpu/command_buffer/tests/gl_copy_texture_CHROMIUM_unittest.cc

Issue 2623863002: Support level > 0 for CopyTextureCHROMIUM extension (Closed)
Patch Set: skip dest_level > 0 on Android Created 3 years, 11 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 #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 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 uint8_t expected_color[4]; 307 uint8_t expected_color[4];
308 uint8_t mask[4]; 308 uint8_t mask[4];
309 getExpectedColor(src_format_type.internal_format, 309 getExpectedColor(src_format_type.internal_format,
310 dest_format_type.internal_format, color, expected_color, 310 dest_format_type.internal_format, color, expected_color,
311 mask); 311 mask);
312 312
313 glGenTextures(2, textures_); 313 glGenTextures(2, textures_);
314 glBindTexture(target, textures_[0]); 314 glBindTexture(target, textures_[0]);
315 glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 315 glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
316 glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 316 glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
317 #if defined(OS_MACOSX)
318 // TODO(qiankun.miao@intel.com): Remove this workaround for Mac OSX, once
319 // integer texture rendering bug is fixed on Mac OSX: crbug.com/679639.
320 glTexImage2D(target, 0, src_format_type.internal_format,
321 width_ << source_level, height_ << source_level, 0,
322 src_format_type.format, src_format_type.type, nullptr);
323 #endif
317 glTexImage2D(target, source_level, src_format_type.internal_format, width_, 324 glTexImage2D(target, source_level, src_format_type.internal_format, width_,
318 height_, 0, src_format_type.format, src_format_type.type, 325 height_, 0, src_format_type.format, src_format_type.type,
319 pixels.get()); 326 pixels.get());
320 EXPECT_TRUE(glGetError() == GL_NO_ERROR); 327 EXPECT_TRUE(glGetError() == GL_NO_ERROR);
321 glBindTexture(target, textures_[1]); 328 glBindTexture(target, textures_[1]);
322 glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 329 glTexParameterf(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
323 glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 330 glTexParameterf(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
324 glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 331 glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
332 // This hack makes dest texture complete in ES2 and ES3 context
333 // respectively. With this, sampling from the dest texture is correct.
334 if (is_es3) {
335 glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
336 glTexParameteri(target, GL_TEXTURE_BASE_LEVEL, dest_level);
337 #if defined(OS_MACOSX)
338 // TODO(qiankun.miao@intel.com): Remove this workaround for Mac OSX, once
339 // framebuffer complete bug is fixed on Mac OSX: crbug.com/678526.
340 glTexImage2D(target, 0, dest_format_type.internal_format,
341 width_ << dest_level, height_ << dest_level, 0,
342 dest_format_type.format, dest_format_type.type, nullptr);
343 #endif
344 } else {
345 glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST);
346 glTexImage2D(target, 0, dest_format_type.internal_format,
347 width_ << dest_level, height_ << dest_level, 0,
348 dest_format_type.format, dest_format_type.type, nullptr);
349 glGenerateMipmap(target);
350 }
325 EXPECT_TRUE(glGetError() == GL_NO_ERROR); 351 EXPECT_TRUE(glGetError() == GL_NO_ERROR);
326 352
327 // TODO(qiankun.miao@intel.com): Upgrade glCopyTextureCHROMIUM and
328 // glCopySubTextureCHROMIUM to support copying from level > 0 of source
329 // texture to level > 0 of dest texture.
330 if (copy_type == TexImage) { 353 if (copy_type == TexImage) {
331 glCopyTextureCHROMIUM(textures_[0], 0, textures_[1], 0, 354 glCopyTextureCHROMIUM(textures_[0], source_level, textures_[1],
332 dest_format_type.internal_format, 355 dest_level, dest_format_type.internal_format,
333 dest_format_type.type, false, false, false); 356 dest_format_type.type, false, false, false);
334 } else { 357 } else {
335 glBindTexture(target, textures_[1]); 358 glBindTexture(target, textures_[1]);
336 glTexImage2D(target, dest_level, dest_format_type.internal_format, width_, 359 glTexImage2D(target, dest_level, dest_format_type.internal_format, width_,
337 height_, 0, dest_format_type.format, dest_format_type.type, 360 height_, 0, dest_format_type.format, dest_format_type.type,
338 nullptr); 361 nullptr);
339 362
340 glCopySubTextureCHROMIUM(textures_[0], 0, textures_[1], 0, 0, 0, 0, 0, 363 glCopySubTextureCHROMIUM(textures_[0], source_level, textures_[1],
341 width_, height_, false, false, false); 364 dest_level, 0, 0, 0, 0, width_, height_, false,
365 false, false);
342 } 366 }
343 EXPECT_TRUE(glGetError() == GL_NO_ERROR); 367 EXPECT_TRUE(glGetError() == GL_NO_ERROR);
344 368
345 // Draw destination texture to a fbo with a texture attachment in RGBA 369 // Draw destination texture to a fbo with a texture attachment in RGBA
346 // format. 370 // format.
347 GLuint texture = CreateDrawingTexture(target, width_, height_); 371 GLuint texture = CreateDrawingTexture(target, width_, height_);
348 GLuint framebuffer = CreateDrawingFBO(target, texture); 372 GLuint framebuffer = CreateDrawingFBO(target, texture);
349 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE), 373 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE),
350 glCheckFramebufferStatus(GL_FRAMEBUFFER)); 374 glCheckFramebufferStatus(GL_FRAMEBUFFER));
351 glViewport(0, 0, width_, height_); 375 glViewport(0, 0, width_, height_);
352 376
353 glBindTexture(target, textures_[1]); 377 glBindTexture(target, textures_[1]);
354 std::string fragment_shader_source = 378 std::string fragment_shader_source =
355 GetFragmentShaderSource(dest_format_type.internal_format, is_es3); 379 GetFragmentShaderSource(dest_format_type.internal_format, is_es3);
356 // TODO(qiankun.miao@intel.com): Support drawing from level > 0 of a
357 // texture.
358 GLTestHelper::DrawTextureQuad( 380 GLTestHelper::DrawTextureQuad(
359 is_es3 ? kSimpleVertexShaderES3 : kSimpleVertexShaderES2, 381 is_es3 ? kSimpleVertexShaderES3 : kSimpleVertexShaderES2,
360 fragment_shader_source.c_str(), "a_position", "u_texture"); 382 fragment_shader_source.c_str(), "a_position", "u_texture");
361 EXPECT_TRUE(GL_NO_ERROR == glGetError()); 383 EXPECT_TRUE(GL_NO_ERROR == glGetError());
362 384
363 uint8_t tolerance = dest_format_type.internal_format == GL_RGBA4 ? 20 : 7; 385 uint8_t tolerance = dest_format_type.internal_format == GL_RGBA4 ? 20 : 7;
364 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, width_, height_, tolerance, 386 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, width_, height_, tolerance,
365 expected_color, mask)) 387 expected_color, mask))
366 << " src_internal_format: " 388 << " src_internal_format: "
367 << gles2::GLES2Util::GetStringEnum(src_format_type.internal_format) 389 << gles2::GLES2Util::GetStringEnum(src_format_type.internal_format)
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 } 447 }
426 448
427 bool ShouldSkipSRGBEXT() const { 449 bool ShouldSkipSRGBEXT() const {
428 DCHECK(!ShouldSkipTest()); 450 DCHECK(!ShouldSkipTest());
429 return !gl_.decoder()->GetFeatureInfo()->feature_flags().ext_srgb; 451 return !gl_.decoder()->GetFeatureInfo()->feature_flags().ext_srgb;
430 } 452 }
431 453
432 // RGB5_A1 is not color-renderable on NVIDIA Mac, see crbug.com/676209. 454 // RGB5_A1 is not color-renderable on NVIDIA Mac, see crbug.com/676209.
433 bool ShouldSkipRGB5_A1() const { 455 bool ShouldSkipRGB5_A1() const {
434 DCHECK(!ShouldSkipTest()); 456 DCHECK(!ShouldSkipTest());
457 #if defined(OS_MACOSX)
435 return true; 458 return true;
459 #else
460 return false;
461 #endif
436 } 462 }
437 }; 463 };
438 464
439 INSTANTIATE_TEST_CASE_P(CopyType, 465 INSTANTIATE_TEST_CASE_P(CopyType,
440 GLCopyTextureCHROMIUMTest, 466 GLCopyTextureCHROMIUMTest,
441 ::testing::ValuesIn(kCopyTypes)); 467 ::testing::ValuesIn(kCopyTypes));
442 468
443 INSTANTIATE_TEST_CASE_P(CopyType, 469 INSTANTIATE_TEST_CASE_P(CopyType,
444 GLCopyTextureCHROMIUMES3Test, 470 GLCopyTextureCHROMIUMES3Test,
445 ::testing::ValuesIn(kCopyTypes)); 471 ::testing::ValuesIn(kCopyTypes));
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
723 749
724 // Copy from RGB source texture to dest texture. 750 // Copy from RGB source texture to dest texture.
725 FormatType src_format_type = {GL_RGB, GL_RGB, GL_UNSIGNED_BYTE}; 751 FormatType src_format_type = {GL_RGB, GL_RGB, GL_UNSIGNED_BYTE};
726 FormatType dest_format_types[] = { 752 FormatType dest_format_types[] = {
727 {GL_RGB, GL_RGB, GL_UNSIGNED_BYTE}, 753 {GL_RGB, GL_RGB, GL_UNSIGNED_BYTE},
728 {GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE}, 754 {GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE},
729 }; 755 };
730 // Source level must be 0 in ES2 context. 756 // Source level must be 0 in ES2 context.
731 GLint source_level = 0; 757 GLint source_level = 0;
732 758
733 // TODO(qiankun.miao@intel.com): Support level > 0. 759 for (GLint dest_level = 0; dest_level < 3; dest_level++) {
734 for (GLint dest_level = 0; dest_level < 1; dest_level++) {
735 for (auto dest_format_type : dest_format_types) { 760 for (auto dest_format_type : dest_format_types) {
736 RunCopyTexture(GL_TEXTURE_2D, copy_type, src_format_type, source_level, 761 RunCopyTexture(GL_TEXTURE_2D, copy_type, src_format_type, source_level,
737 dest_format_type, dest_level, false); 762 dest_format_type, dest_level, false);
738 } 763 }
739 } 764 }
740 } 765 }
741 766
742 TEST_P(GLCopyTextureCHROMIUMES3Test, CopyTextureLevel) { 767 TEST_P(GLCopyTextureCHROMIUMES3Test, CopyTextureLevel) {
743 if (ShouldSkipTest()) 768 if (ShouldSkipTest())
744 return; 769 return;
745 CopyType copy_type = GetParam(); 770 CopyType copy_type = GetParam();
746 771
747 // Copy from RGBA source texture to dest texture. 772 // Copy from RGBA source texture to dest texture.
748 FormatType src_format_type = {GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE}; 773 FormatType src_format_type = {GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE};
749 FormatType dest_format_types[] = { 774 FormatType dest_format_types[] = {
750 {GL_RGB8UI, GL_RGB_INTEGER, GL_UNSIGNED_BYTE}, 775 {GL_RGB8UI, GL_RGB_INTEGER, GL_UNSIGNED_BYTE},
751 {GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE}, 776 {GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE},
752 {GL_RGBA8UI, GL_RGBA_INTEGER, GL_UNSIGNED_BYTE}, 777 {GL_RGBA8UI, GL_RGBA_INTEGER, GL_UNSIGNED_BYTE},
753 }; 778 };
754 779
755 // TODO(qiankun.miao@intel.com): Support level > 0. 780 for (GLint source_level = 0; source_level < 3; source_level++) {
756 for (GLint source_level = 0; source_level < 1; source_level++) { 781 for (GLint dest_level = 0; dest_level < 3; dest_level++) {
757 for (GLint dest_level = 0; dest_level < 1; dest_level++) {
758 for (auto dest_format_type : dest_format_types) { 782 for (auto dest_format_type : dest_format_types) {
783 #if defined(OS_WIN) || defined(OS_ANDROID)
784 // TODO(qiankun.miao@intel.com): source_level > 0 or dest_level > 0
785 // isn't available due to renderinig bug for non-zero base level in
786 // NVIDIA Windows: crbug.com/679639 and Android: crbug.com/680460.
Ken Russell (switch to Gerrit) 2017/01/13 05:08:37 Sorry for going back and forth on this (per my sug
787 if (dest_level > 0)
788 continue;
789 #endif
759 RunCopyTexture(GL_TEXTURE_2D, copy_type, src_format_type, source_level, 790 RunCopyTexture(GL_TEXTURE_2D, copy_type, src_format_type, source_level,
760 dest_format_type, dest_level, true); 791 dest_format_type, dest_level, true);
761 } 792 }
762 } 793 }
763 } 794 }
764 } 795 }
765 796
766 // Test to ensure that the destination texture is redefined if the properties 797 // Test to ensure that the destination texture is redefined if the properties
767 // are different. 798 // are different.
768 TEST_F(GLCopyTextureCHROMIUMTest, RedefineDestinationTexture) { 799 TEST_F(GLCopyTextureCHROMIUMTest, RedefineDestinationTexture) {
(...skipping 650 matching lines...) Expand 10 before | Expand all | Expand 10 after
1419 } 1450 }
1420 } 1451 }
1421 1452
1422 glDeleteTextures(2, textures_); 1453 glDeleteTextures(2, textures_);
1423 glDeleteFramebuffers(1, &framebuffer_id_); 1454 glDeleteFramebuffers(1, &framebuffer_id_);
1424 } 1455 }
1425 } 1456 }
1426 } 1457 }
1427 1458
1428 } // namespace gpu 1459 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698