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

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

Issue 2208733002: Command buffer: clear rect for a specific layer/level of the uncleared texture for CopyTexSubImage3D (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Do not assign a default value 0 to layer, UpdateMipCleared for all layers for 3D texture Created 4 years, 4 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 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 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 17 matching lines...) Expand all
28 #include "ui/gl/gl_implementation.h" 28 #include "ui/gl/gl_implementation.h"
29 #include "ui/gl/gl_mock.h" 29 #include "ui/gl/gl_mock.h"
30 #include "ui/gl/gl_surface_stub.h" 30 #include "ui/gl/gl_surface_stub.h"
31 31
32 #if !defined(GL_DEPTH24_STENCIL8) 32 #if !defined(GL_DEPTH24_STENCIL8)
33 #define GL_DEPTH24_STENCIL8 0x88F0 33 #define GL_DEPTH24_STENCIL8 0x88F0
34 #endif 34 #endif
35 35
36 using ::gl::MockGLInterface; 36 using ::gl::MockGLInterface;
37 using ::testing::_; 37 using ::testing::_;
38 using ::testing::AnyNumber;
38 using ::testing::DoAll; 39 using ::testing::DoAll;
39 using ::testing::InSequence; 40 using ::testing::InSequence;
40 using ::testing::Invoke; 41 using ::testing::Invoke;
41 using ::testing::MatcherCast; 42 using ::testing::MatcherCast;
42 using ::testing::Mock; 43 using ::testing::Mock;
43 using ::testing::Pointee; 44 using ::testing::Pointee;
44 using ::testing::Return; 45 using ::testing::Return;
45 using ::testing::SaveArg; 46 using ::testing::SaveArg;
46 using ::testing::SetArrayArgument; 47 using ::testing::SetArrayArgument;
47 using ::testing::SetArgumentPointee; 48 using ::testing::SetArgumentPointee;
(...skipping 1312 matching lines...) Expand 10 before | Expand all | Expand 10 after
1360 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 1361 EXPECT_EQ(GL_NO_ERROR, GetGLError());
1361 1362
1362 EXPECT_CALL(*gl_, CheckFramebufferStatusEXT(_)) 1363 EXPECT_CALL(*gl_, CheckFramebufferStatusEXT(_))
1363 .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE)) 1364 .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE))
1364 .RetiresOnSaturation(); 1365 .RetiresOnSaturation();
1365 cmd.Init(kTarget, kLevel, kXoffset, kYoffset, kZoffset, 1366 cmd.Init(kTarget, kLevel, kXoffset, kYoffset, kZoffset,
1366 kX, kY, kWidth, kHeight); 1367 kX, kY, kWidth, kHeight);
1367 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 1368 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
1368 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); 1369 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
1369 } 1370 }
1371 /*
1372 TEST_P(GLES3DecoderTest, CopyTexSubImage3DMarksTextureAsCleared) {
1373 DoBindTexture(GL_TEXTURE_3D, client_texture_id_, kServiceTextureId);
1374 DoTexImage3D(
1375 GL_TEXTURE_3D, 0, GL_RGB8, 2, 2, 2, 0, GL_RGB, GL_UNSIGNED_BYTE, 0, 0);
1370 1376
1377 TextureManager* manager = group().texture_manager();
1378 TextureRef* texture_ref = manager->GetTexture(client_texture_id_);
1379 ASSERT_TRUE(texture_ref != NULL);
1380 Texture* texture = texture_ref->texture();
1381
1382 CopyTexSubImage3D cmd;
1383
1384 // clear the left part of layer 0
1385 EXPECT_CALL(*gl_, GetError())
1386 .WillOnce(Return(GL_NO_ERROR))
1387 .RetiresOnSaturation();
1388 EXPECT_CALL(*gl_, GenBuffersARB(_, _))
1389 .Times(AnyNumber());
1390 EXPECT_CALL(*gl_, DeleteBuffersARB(_, _))
1391 .Times(AnyNumber());
1392 EXPECT_CALL(*gl_, CopyTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 0,
1393 0, 0, 1, 2))
1394 .Times(1)
1395 .RetiresOnSaturation();
1396 EXPECT_CALL(*gl_, GetError())
1397 .WillOnce(Return(GL_NO_ERROR))
1398 .RetiresOnSaturation();
1399 cmd.Init(GL_TEXTURE_3D, 0, 0, 0, 0,
1400 0, 0, 1, 2);
1401 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
1402
1403 EXPECT_FALSE(texture->SafeToRenderFrom());
1404
1405 // clear the right part of layer 0
1406 EXPECT_CALL(*gl_, GetError())
1407 .WillOnce(Return(GL_NO_ERROR))
1408 .RetiresOnSaturation();
1409 EXPECT_CALL(*gl_, GenBuffersARB(_, _))
1410 .Times(AnyNumber());
1411 EXPECT_CALL(*gl_, DeleteBuffersARB(_, _))
1412 .Times(AnyNumber());
1413 EXPECT_CALL(*gl_, CopyTexSubImage3D(GL_TEXTURE_3D, 0, 1, 0, 0,
1414 0, 0, 1, 2))
1415 .Times(1)
1416 .RetiresOnSaturation();
1417 EXPECT_CALL(*gl_, GetError())
1418 .WillOnce(Return(GL_NO_ERROR))
1419 .RetiresOnSaturation();
1420 cmd.Init(GL_TEXTURE_3D, 0, 1, 0, 0,
1421 0, 0, 1, 2);
1422 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
1423
1424 EXPECT_FALSE(texture->SafeToRenderFrom());
1425
1426 // clear layer 1
1427 EXPECT_CALL(*gl_, GetError())
1428 .WillOnce(Return(GL_NO_ERROR))
1429 .RetiresOnSaturation();
1430 EXPECT_CALL(*gl_, GenBuffersARB(_, _))
1431 .Times(AnyNumber());
1432 EXPECT_CALL(*gl_, DeleteBuffersARB(_, _))
1433 .Times(AnyNumber());
1434 EXPECT_CALL(*gl_, CopyTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 0,
1435 0, 0, 2, 2))
1436 .Times(1)
1437 .RetiresOnSaturation();
1438 EXPECT_CALL(*gl_, GetError())
1439 .WillOnce(Return(GL_NO_ERROR))
1440 .RetiresOnSaturation();
1441 cmd.Init(GL_TEXTURE_3D, 0, 0, 0, 0,
1442 0, 0, 2, 2);
1443 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
1444
1445 EXPECT_TRUE(texture->SafeToRenderFrom());
1446 }
1447 */
1371 TEST_P(GLES3DecoderTest, CompressedTexImage3DFailsWithBadImageSize) { 1448 TEST_P(GLES3DecoderTest, CompressedTexImage3DFailsWithBadImageSize) {
1372 const uint32_t kBucketId = 123; 1449 const uint32_t kBucketId = 123;
1373 const GLenum kTarget = GL_TEXTURE_2D_ARRAY; 1450 const GLenum kTarget = GL_TEXTURE_2D_ARRAY;
1374 const GLint kLevel = 0; 1451 const GLint kLevel = 0;
1375 const GLenum kInternalFormat = GL_COMPRESSED_RGBA8_ETC2_EAC; 1452 const GLenum kInternalFormat = GL_COMPRESSED_RGBA8_ETC2_EAC;
1376 const GLsizei kWidth = 4; 1453 const GLsizei kWidth = 4;
1377 const GLsizei kHeight = 8; 1454 const GLsizei kHeight = 8;
1378 const GLsizei kDepth = 4; 1455 const GLsizei kDepth = 4;
1379 CommonDecoder::Bucket* bucket = decoder_->CreateBucket(kBucketId); 1456 CommonDecoder::Bucket* bucket = decoder_->CreateBucket(kBucketId);
1380 ASSERT_TRUE(bucket != NULL); 1457 ASSERT_TRUE(bucket != NULL);
(...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after
1900 EXPECT_EQ(error::kNoError, ExecuteCmd(texsub_cmd)); 1977 EXPECT_EQ(error::kNoError, ExecuteCmd(texsub_cmd));
1901 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); 1978 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
1902 1979
1903 // Test CopyTexSubImage not allowed for ETC1 compressed texture 1980 // Test CopyTexSubImage not allowed for ETC1 compressed texture
1904 CopyTexSubImage2D copy_cmd; 1981 CopyTexSubImage2D copy_cmd;
1905 copy_cmd.Init(GL_TEXTURE_2D, 0, 0, 0, 0, 0, 4, 4); 1982 copy_cmd.Init(GL_TEXTURE_2D, 0, 0, 0, 0, 0, 4, 4);
1906 EXPECT_EQ(error::kNoError, ExecuteCmd(copy_cmd)); 1983 EXPECT_EQ(error::kNoError, ExecuteCmd(copy_cmd));
1907 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); 1984 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
1908 } 1985 }
1909 1986
1910
1911
1912 TEST_P(GLES2DecoderManualInitTest, EGLImageExternalBindTexture) { 1987 TEST_P(GLES2DecoderManualInitTest, EGLImageExternalBindTexture) {
1913 InitState init; 1988 InitState init;
1914 init.extensions = "GL_OES_EGL_image_external"; 1989 init.extensions = "GL_OES_EGL_image_external";
1915 init.gl_version = "opengl es 2.0"; 1990 init.gl_version = "opengl es 2.0";
1916 init.bind_generates_resource = true; 1991 init.bind_generates_resource = true;
1917 InitDecoder(init); 1992 InitDecoder(init);
1918 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_EXTERNAL_OES, kNewServiceId)); 1993 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_EXTERNAL_OES, kNewServiceId));
1919 EXPECT_CALL(*gl_, GenTextures(1, _)) 1994 EXPECT_CALL(*gl_, GenTextures(1, _))
1920 .WillOnce(SetArgumentPointee<1>(kNewServiceId)); 1995 .WillOnce(SetArgumentPointee<1>(kNewServiceId));
1921 BindTexture cmd; 1996 BindTexture cmd;
(...skipping 1367 matching lines...) Expand 10 before | Expand all | Expand 10 after
3289 GLenum type; 3364 GLenum type;
3290 GLenum internal_format; 3365 GLenum internal_format;
3291 3366
3292 EXPECT_TRUE( 3367 EXPECT_TRUE(
3293 texture->GetLevelSize(GL_TEXTURE_2D, 0, &width, &height, nullptr)); 3368 texture->GetLevelSize(GL_TEXTURE_2D, 0, &width, &height, nullptr));
3294 EXPECT_EQ(3, width); 3369 EXPECT_EQ(3, width);
3295 EXPECT_EQ(1, height); 3370 EXPECT_EQ(1, height);
3296 EXPECT_TRUE(texture->GetLevelType(GL_TEXTURE_2D, 0, &type, &internal_format)); 3371 EXPECT_TRUE(texture->GetLevelType(GL_TEXTURE_2D, 0, &type, &internal_format));
3297 EXPECT_EQ(static_cast<GLenum>(GL_RGBA), internal_format); 3372 EXPECT_EQ(static_cast<GLenum>(GL_RGBA), internal_format);
3298 EXPECT_EQ(static_cast<GLenum>(GL_UNSIGNED_BYTE), type); 3373 EXPECT_EQ(static_cast<GLenum>(GL_UNSIGNED_BYTE), type);
3299 EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 0) == NULL); 3374 EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 0, 0) == NULL);
3300 3375
3301 // Bind image to texture. 3376 // Bind image to texture.
3302 // ScopedGLErrorSuppressor calls GetError on its constructor and destructor. 3377 // ScopedGLErrorSuppressor calls GetError on its constructor and destructor.
3303 DoBindTexImage2DCHROMIUM(GL_TEXTURE_2D, 1); 3378 DoBindTexImage2DCHROMIUM(GL_TEXTURE_2D, 1);
3304 EXPECT_TRUE( 3379 EXPECT_TRUE(
3305 texture->GetLevelSize(GL_TEXTURE_2D, 0, &width, &height, nullptr)); 3380 texture->GetLevelSize(GL_TEXTURE_2D, 0, &width, &height, nullptr));
3306 // Image should now be set. 3381 // Image should now be set.
3307 EXPECT_FALSE(texture->GetLevelImage(GL_TEXTURE_2D, 0) == NULL); 3382 EXPECT_FALSE(texture->GetLevelImage(GL_TEXTURE_2D, 0, 0) == NULL);
3308 3383
3309 // Define new texture image. 3384 // Define new texture image.
3310 DoTexImage2D( 3385 DoTexImage2D(
3311 GL_TEXTURE_2D, 0, GL_RGBA, 3, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0); 3386 GL_TEXTURE_2D, 0, GL_RGBA, 3, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0);
3312 EXPECT_TRUE( 3387 EXPECT_TRUE(
3313 texture->GetLevelSize(GL_TEXTURE_2D, 0, &width, &height, nullptr)); 3388 texture->GetLevelSize(GL_TEXTURE_2D, 0, &width, &height, nullptr));
3314 // Image should no longer be set. 3389 // Image should no longer be set.
3315 EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 0) == NULL); 3390 EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 0, 0) == NULL);
3316 } 3391 }
3317 3392
3318 TEST_P(GLES2DecoderTest, BindTexImage2DCHROMIUMCubeMapNotAllowed) { 3393 TEST_P(GLES2DecoderTest, BindTexImage2DCHROMIUMCubeMapNotAllowed) {
3319 scoped_refptr<gl::GLImage> image(new gl::GLImageStub); 3394 scoped_refptr<gl::GLImage> image(new gl::GLImageStub);
3320 GetImageManager()->AddImage(image.get(), 1); 3395 GetImageManager()->AddImage(image.get(), 1);
3321 DoBindTexture(GL_TEXTURE_CUBE_MAP, client_texture_id_, kServiceTextureId); 3396 DoBindTexture(GL_TEXTURE_CUBE_MAP, client_texture_id_, kServiceTextureId);
3322 3397
3323 BindTexImage2DCHROMIUM bind_tex_image_2d_cmd; 3398 BindTexImage2DCHROMIUM bind_tex_image_2d_cmd;
3324 bind_tex_image_2d_cmd.Init(GL_TEXTURE_CUBE_MAP, 1); 3399 bind_tex_image_2d_cmd.Init(GL_TEXTURE_CUBE_MAP, 1);
3325 EXPECT_EQ(error::kNoError, ExecuteCmd(bind_tex_image_2d_cmd)); 3400 EXPECT_EQ(error::kNoError, ExecuteCmd(bind_tex_image_2d_cmd));
3326 EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); 3401 EXPECT_EQ(GL_INVALID_ENUM, GetGLError());
3327 } 3402 }
3328 3403
3329 TEST_P(GLES2DecoderTest, OrphanGLImageWithTexImage2D) { 3404 TEST_P(GLES2DecoderTest, OrphanGLImageWithTexImage2D) {
3330 scoped_refptr<gl::GLImage> image(new gl::GLImageStub); 3405 scoped_refptr<gl::GLImage> image(new gl::GLImageStub);
3331 GetImageManager()->AddImage(image.get(), 1); 3406 GetImageManager()->AddImage(image.get(), 1);
3332 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); 3407 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId);
3333 3408
3334 DoBindTexImage2DCHROMIUM(GL_TEXTURE_2D, 1); 3409 DoBindTexImage2DCHROMIUM(GL_TEXTURE_2D, 1);
3335 3410
3336 TextureRef* texture_ref = 3411 TextureRef* texture_ref =
3337 group().texture_manager()->GetTexture(client_texture_id_); 3412 group().texture_manager()->GetTexture(client_texture_id_);
3338 ASSERT_TRUE(texture_ref != NULL); 3413 ASSERT_TRUE(texture_ref != NULL);
3339 Texture* texture = texture_ref->texture(); 3414 Texture* texture = texture_ref->texture();
3340 3415
3341 EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 0) == image.get()); 3416 EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 0, 0) == image.get());
3342 DoTexImage2D( 3417 DoTexImage2D(
3343 GL_TEXTURE_2D, 0, GL_RGBA, 3, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0); 3418 GL_TEXTURE_2D, 0, GL_RGBA, 3, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0);
3344 EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 0) == NULL); 3419 EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 0, 0) == NULL);
3345 } 3420 }
3346 3421
3347 TEST_P(GLES2DecoderTest, GLImageAttachedAfterSubTexImage2D) { 3422 TEST_P(GLES2DecoderTest, GLImageAttachedAfterSubTexImage2D) {
3348 // Specifically tests that TexSubImage2D is not optimized to TexImage2D 3423 // Specifically tests that TexSubImage2D is not optimized to TexImage2D
3349 // in the presence of image attachments. 3424 // in the presence of image attachments.
3350 ASSERT_FALSE( 3425 ASSERT_FALSE(
3351 feature_info()->workarounds().texsubimage_faster_than_teximage); 3426 feature_info()->workarounds().texsubimage_faster_than_teximage);
3352 3427
3353 scoped_refptr<gl::GLImage> image(new gl::GLImageStub); 3428 scoped_refptr<gl::GLImage> image(new gl::GLImageStub);
3354 GetImageManager()->AddImage(image.get(), 1); 3429 GetImageManager()->AddImage(image.get(), 1);
(...skipping 17 matching lines...) Expand all
3372 pixels_shm_id, pixels_shm_offset); 3447 pixels_shm_id, pixels_shm_offset);
3373 3448
3374 // Bind texture to GLImage. 3449 // Bind texture to GLImage.
3375 DoBindTexImage2DCHROMIUM(GL_TEXTURE_2D, 1); 3450 DoBindTexImage2DCHROMIUM(GL_TEXTURE_2D, 1);
3376 3451
3377 // Check binding. 3452 // Check binding.
3378 TextureRef* texture_ref = 3453 TextureRef* texture_ref =
3379 group().texture_manager()->GetTexture(client_texture_id_); 3454 group().texture_manager()->GetTexture(client_texture_id_);
3380 ASSERT_TRUE(texture_ref != NULL); 3455 ASSERT_TRUE(texture_ref != NULL);
3381 Texture* texture = texture_ref->texture(); 3456 Texture* texture = texture_ref->texture();
3382 EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 0) == image.get()); 3457 EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 0, 0) == image.get());
3383 3458
3384 // TexSubImage2D should not unbind GLImage. 3459 // TexSubImage2D should not unbind GLImage.
3385 EXPECT_CALL(*gl_, TexSubImage2D(target, level, xoffset, yoffset, width, 3460 EXPECT_CALL(*gl_, TexSubImage2D(target, level, xoffset, yoffset, width,
3386 height, format, type, _)) 3461 height, format, type, _))
3387 .Times(1) 3462 .Times(1)
3388 .RetiresOnSaturation(); 3463 .RetiresOnSaturation();
3389 TexSubImage2D tex_sub_image_2d_cmd; 3464 TexSubImage2D tex_sub_image_2d_cmd;
3390 tex_sub_image_2d_cmd.Init(target, level, xoffset, yoffset, width, height, 3465 tex_sub_image_2d_cmd.Init(target, level, xoffset, yoffset, width, height,
3391 format, type, pixels_shm_id, pixels_shm_offset, 3466 format, type, pixels_shm_id, pixels_shm_offset,
3392 internal); 3467 internal);
3393 EXPECT_EQ(error::kNoError, ExecuteCmd(tex_sub_image_2d_cmd)); 3468 EXPECT_EQ(error::kNoError, ExecuteCmd(tex_sub_image_2d_cmd));
3394 EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 0) == image.get()); 3469 EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 0, 0) == image.get());
3395 } 3470 }
3396 3471
3397 TEST_P(GLES2DecoderTest, GLImageAttachedAfterClearLevel) { 3472 TEST_P(GLES2DecoderTest, GLImageAttachedAfterClearLevel) {
3398 scoped_refptr<gl::GLImage> image(new gl::GLImageStub); 3473 scoped_refptr<gl::GLImage> image(new gl::GLImageStub);
3399 GetImageManager()->AddImage(image.get(), 1); 3474 GetImageManager()->AddImage(image.get(), 1);
3400 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); 3475 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId);
3401 3476
3402 GLenum target = GL_TEXTURE_2D; 3477 GLenum target = GL_TEXTURE_2D;
3403 GLint level = 0; 3478 GLint level = 0;
3404 GLint xoffset = 0; 3479 GLint xoffset = 0;
(...skipping 11 matching lines...) Expand all
3416 pixels_shm_id, pixels_shm_offset); 3491 pixels_shm_id, pixels_shm_offset);
3417 3492
3418 // Bind texture to GLImage. 3493 // Bind texture to GLImage.
3419 DoBindTexImage2DCHROMIUM(GL_TEXTURE_2D, 1); 3494 DoBindTexImage2DCHROMIUM(GL_TEXTURE_2D, 1);
3420 3495
3421 // Check binding. 3496 // Check binding.
3422 TextureRef* texture_ref = 3497 TextureRef* texture_ref =
3423 group().texture_manager()->GetTexture(client_texture_id_); 3498 group().texture_manager()->GetTexture(client_texture_id_);
3424 ASSERT_TRUE(texture_ref != NULL); 3499 ASSERT_TRUE(texture_ref != NULL);
3425 Texture* texture = texture_ref->texture(); 3500 Texture* texture = texture_ref->texture();
3426 EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 0) == image.get()); 3501 EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 0, 0) == image.get());
3427 3502
3428 // ClearLevel should use glTexSubImage2D to avoid unbinding GLImage. 3503 // ClearLevel should use glTexSubImage2D to avoid unbinding GLImage.
3429 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_2D, kServiceTextureId)) 3504 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_2D, kServiceTextureId))
3430 .Times(2) 3505 .Times(2)
3431 .RetiresOnSaturation(); 3506 .RetiresOnSaturation();
3432 EXPECT_CALL(*gl_, TexSubImage2D(target, level, xoffset, yoffset, width, 3507 EXPECT_CALL(*gl_, TexSubImage2D(target, level, xoffset, yoffset, width,
3433 height, format, type, _)) 3508 height, format, type, _))
3434 .Times(1) 3509 .Times(1)
3435 .RetiresOnSaturation(); 3510 .RetiresOnSaturation();
3436 GetDecoder()->ClearLevel(texture, target, level, format, type, 0, 0, width, 3511 GetDecoder()->ClearLevel(texture, target, level, format, type, 0, 0, width,
3437 height); 3512 height);
3438 EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 0) == image.get()); 3513 EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 0, 0) == image.get());
3439 } 3514 }
3440 3515
3441 TEST_P(GLES2DecoderTest, ReleaseTexImage2DCHROMIUM) { 3516 TEST_P(GLES2DecoderTest, ReleaseTexImage2DCHROMIUM) {
3442 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); 3517 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId);
3443 DoTexImage2D( 3518 DoTexImage2D(
3444 GL_TEXTURE_2D, 0, GL_RGBA, 3, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0); 3519 GL_TEXTURE_2D, 0, GL_RGBA, 3, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0);
3445 TextureRef* texture_ref = 3520 TextureRef* texture_ref =
3446 group().texture_manager()->GetTexture(client_texture_id_); 3521 group().texture_manager()->GetTexture(client_texture_id_);
3447 ASSERT_TRUE(texture_ref != NULL); 3522 ASSERT_TRUE(texture_ref != NULL);
3448 Texture* texture = texture_ref->texture(); 3523 Texture* texture = texture_ref->texture();
3449 EXPECT_EQ(kServiceTextureId, texture->service_id()); 3524 EXPECT_EQ(kServiceTextureId, texture->service_id());
3450 3525
3451 scoped_refptr<gl::GLImage> image(new gl::GLImageStub); 3526 scoped_refptr<gl::GLImage> image(new gl::GLImageStub);
3452 GetImageManager()->AddImage(image.get(), 1); 3527 GetImageManager()->AddImage(image.get(), 1);
3453 EXPECT_FALSE(GetImageManager()->LookupImage(1) == NULL); 3528 EXPECT_FALSE(GetImageManager()->LookupImage(1) == NULL);
3454 3529
3455 GLsizei width; 3530 GLsizei width;
3456 GLsizei height; 3531 GLsizei height;
3457 GLenum type; 3532 GLenum type;
3458 GLenum internal_format; 3533 GLenum internal_format;
3459 3534
3460 EXPECT_TRUE( 3535 EXPECT_TRUE(
3461 texture->GetLevelSize(GL_TEXTURE_2D, 0, &width, &height, nullptr)); 3536 texture->GetLevelSize(GL_TEXTURE_2D, 0, &width, &height, nullptr));
3462 EXPECT_EQ(3, width); 3537 EXPECT_EQ(3, width);
3463 EXPECT_EQ(1, height); 3538 EXPECT_EQ(1, height);
3464 EXPECT_TRUE(texture->GetLevelType(GL_TEXTURE_2D, 0, &type, &internal_format)); 3539 EXPECT_TRUE(texture->GetLevelType(GL_TEXTURE_2D, 0, &type, &internal_format));
3465 EXPECT_EQ(static_cast<GLenum>(GL_RGBA), internal_format); 3540 EXPECT_EQ(static_cast<GLenum>(GL_RGBA), internal_format);
3466 EXPECT_EQ(static_cast<GLenum>(GL_UNSIGNED_BYTE), type); 3541 EXPECT_EQ(static_cast<GLenum>(GL_UNSIGNED_BYTE), type);
3467 EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 0) == NULL); 3542 EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 0, 0) == NULL);
3468 3543
3469 // Bind image to texture. 3544 // Bind image to texture.
3470 // ScopedGLErrorSuppressor calls GetError on its constructor and destructor. 3545 // ScopedGLErrorSuppressor calls GetError on its constructor and destructor.
3471 DoBindTexImage2DCHROMIUM(GL_TEXTURE_2D, 1); 3546 DoBindTexImage2DCHROMIUM(GL_TEXTURE_2D, 1);
3472 EXPECT_TRUE( 3547 EXPECT_TRUE(
3473 texture->GetLevelSize(GL_TEXTURE_2D, 0, &width, &height, nullptr)); 3548 texture->GetLevelSize(GL_TEXTURE_2D, 0, &width, &height, nullptr));
3474 // Image should now be set. 3549 // Image should now be set.
3475 EXPECT_FALSE(texture->GetLevelImage(GL_TEXTURE_2D, 0) == NULL); 3550 EXPECT_FALSE(texture->GetLevelImage(GL_TEXTURE_2D, 0, 0) == NULL);
3476 3551
3477 // Release image from texture. 3552 // Release image from texture.
3478 // ScopedGLErrorSuppressor calls GetError on its constructor and destructor. 3553 // ScopedGLErrorSuppressor calls GetError on its constructor and destructor.
3479 EXPECT_CALL(*gl_, GetError()) 3554 EXPECT_CALL(*gl_, GetError())
3480 .WillOnce(Return(GL_NO_ERROR)) 3555 .WillOnce(Return(GL_NO_ERROR))
3481 .WillOnce(Return(GL_NO_ERROR)) 3556 .WillOnce(Return(GL_NO_ERROR))
3482 .RetiresOnSaturation(); 3557 .RetiresOnSaturation();
3483 ReleaseTexImage2DCHROMIUM release_tex_image_2d_cmd; 3558 ReleaseTexImage2DCHROMIUM release_tex_image_2d_cmd;
3484 release_tex_image_2d_cmd.Init(GL_TEXTURE_2D, 1); 3559 release_tex_image_2d_cmd.Init(GL_TEXTURE_2D, 1);
3485 EXPECT_EQ(error::kNoError, ExecuteCmd(release_tex_image_2d_cmd)); 3560 EXPECT_EQ(error::kNoError, ExecuteCmd(release_tex_image_2d_cmd));
3486 EXPECT_TRUE( 3561 EXPECT_TRUE(
3487 texture->GetLevelSize(GL_TEXTURE_2D, 0, &width, &height, nullptr)); 3562 texture->GetLevelSize(GL_TEXTURE_2D, 0, &width, &height, nullptr));
3488 // Image should no longer be set. 3563 // Image should no longer be set.
3489 EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 0) == NULL); 3564 EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 0, 0) == NULL);
3490 } 3565 }
3491 3566
3492 class MockGLImage : public gl::GLImage { 3567 class MockGLImage : public gl::GLImage {
3493 public: 3568 public:
3494 MockGLImage() {} 3569 MockGLImage() {}
3495 3570
3496 // Overridden from gl::GLImage: 3571 // Overridden from gl::GLImage:
3497 MOCK_METHOD0(GetSize, gfx::Size()); 3572 MOCK_METHOD0(GetSize, gfx::Size());
3498 MOCK_METHOD0(GetInternalFormat, unsigned()); 3573 MOCK_METHOD0(GetInternalFormat, unsigned());
3499 MOCK_METHOD1(Destroy, void(bool)); 3574 MOCK_METHOD1(Destroy, void(bool));
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
3647 init.bind_generates_resource = true; 3722 init.bind_generates_resource = true;
3648 InitDecoder(init); 3723 InitDecoder(init);
3649 3724
3650 TextureRef* texture_ref = GetTexture(client_texture_id_); 3725 TextureRef* texture_ref = GetTexture(client_texture_id_);
3651 scoped_refptr<MockGLImage> image(new MockGLImage); 3726 scoped_refptr<MockGLImage> image(new MockGLImage);
3652 group().texture_manager()->SetTarget(texture_ref, GL_TEXTURE_EXTERNAL_OES); 3727 group().texture_manager()->SetTarget(texture_ref, GL_TEXTURE_EXTERNAL_OES);
3653 group().texture_manager()->SetLevelInfo(texture_ref, GL_TEXTURE_EXTERNAL_OES, 3728 group().texture_manager()->SetLevelInfo(texture_ref, GL_TEXTURE_EXTERNAL_OES,
3654 0, GL_RGBA, 0, 0, 1, 0, GL_RGBA, 3729 0, GL_RGBA, 0, 0, 1, 0, GL_RGBA,
3655 GL_UNSIGNED_BYTE, gfx::Rect()); 3730 GL_UNSIGNED_BYTE, gfx::Rect());
3656 group().texture_manager()->SetLevelImage(texture_ref, GL_TEXTURE_EXTERNAL_OES, 3731 group().texture_manager()->SetLevelImage(texture_ref, GL_TEXTURE_EXTERNAL_OES,
3657 0, image.get(), Texture::BOUND); 3732 0, 0, image.get(), Texture::BOUND);
3658 3733
3659 DoBindTexture(GL_TEXTURE_EXTERNAL_OES, client_texture_id_, kServiceTextureId); 3734 DoBindTexture(GL_TEXTURE_EXTERNAL_OES, client_texture_id_, kServiceTextureId);
3660 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 3735 EXPECT_EQ(GL_NO_ERROR, GetGLError());
3661 3736
3662 SetupSamplerExternalProgram(); 3737 SetupSamplerExternalProgram();
3663 SetupIndexBuffer(); 3738 SetupIndexBuffer();
3664 AddExpectationsForSimulatedAttrib0(kMaxValidIndex + 1, 0); 3739 AddExpectationsForSimulatedAttrib0(kMaxValidIndex + 1, 0);
3665 SetupExpectationsForApplyingDefaultDirtyState(); 3740 SetupExpectationsForApplyingDefaultDirtyState();
3666 EXPECT_TRUE(group().texture_manager()->CanRender(texture_ref)); 3741 EXPECT_TRUE(group().texture_manager()->CanRender(texture_ref));
3667 3742
(...skipping 706 matching lines...) Expand 10 before | Expand all | Expand 10 after
4374 // TODO(gman): CompressedTexSubImage2DImmediate 4449 // TODO(gman): CompressedTexSubImage2DImmediate
4375 4450
4376 // TODO(gman): TexImage2D 4451 // TODO(gman): TexImage2D
4377 4452
4378 // TODO(gman): TexImage2DImmediate 4453 // TODO(gman): TexImage2DImmediate
4379 4454
4380 // TODO(gman): TexSubImage2DImmediate 4455 // TODO(gman): TexSubImage2DImmediate
4381 4456
4382 } // namespace gles2 4457 } // namespace gles2
4383 } // namespace gpu 4458 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/gles2_cmd_decoder.cc ('k') | gpu/command_buffer/service/mailbox_manager_sync.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698