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

Side by Side Diff: gpu/command_buffer/service/mailbox_manager_unittest.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "base/macros.h" 5 #include "base/macros.h"
6 #include "gpu/command_buffer/common/sync_token.h" 6 #include "gpu/command_buffer/common/sync_token.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/gpu_service_test.h" 8 #include "gpu/command_buffer/service/gpu_service_test.h"
9 #include "gpu/command_buffer/service/mailbox_manager_impl.h" 9 #include "gpu/command_buffer/service/mailbox_manager_impl.h"
10 #include "gpu/command_buffer/service/mailbox_manager_sync.h" 10 #include "gpu/command_buffer/service/mailbox_manager_sync.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 manager_ = new MailboxManagerSync(); 43 manager_ = new MailboxManagerSync();
44 DCHECK(manager_->UsesSync()); 44 DCHECK(manager_->UsesSync());
45 } 45 }
46 46
47 void TearDown() override { GpuServiceTest::TearDown(); } 47 void TearDown() override { GpuServiceTest::TearDown(); }
48 48
49 Texture* CreateTexture() { 49 Texture* CreateTexture() {
50 return new Texture(1); 50 return new Texture(1);
51 } 51 }
52 52
53 void SetTarget(Texture* texture, GLenum target, GLuint max_level) { 53 void SetTarget(Texture* texture,
54 texture->SetTarget(target, max_level); 54 GLenum target,
55 GLuint max_level,
56 GLuint layers) {
57 texture->SetTarget(target, max_level, layers);
55 } 58 }
56 59
57 void SetLevelInfo(Texture* texture, 60 void SetLevelInfo(Texture* texture,
58 GLenum target, 61 GLenum target,
59 GLint level, 62 GLint level,
60 GLenum internal_format, 63 GLenum internal_format,
61 GLsizei width, 64 GLsizei width,
62 GLsizei height, 65 GLsizei height,
63 GLsizei depth, 66 GLsizei depth,
64 GLint border, 67 GLint border,
65 GLenum format, 68 GLenum format,
66 GLenum type, 69 GLenum type,
67 const gfx::Rect& cleared_rect) { 70 const gfx::Rect& cleared_rect) {
68 texture->SetLevelInfo(target, level, internal_format, width, height, depth, 71 texture->SetLevelInfo(target, level, internal_format, width, height, depth,
69 border, format, type, cleared_rect); 72 border, format, type, cleared_rect);
70 } 73 }
71 74
72 void SetLevelCleared(Texture* texture, 75 void SetLevelCleared(Texture* texture,
73 GLenum target, 76 GLenum target,
74 GLint level, 77 GLint level,
75 bool cleared) { 78 bool cleared) {
76 texture->SetLevelCleared(target, level, cleared); 79 texture->SetLevelCleared(target, level, 0, cleared);
77 } 80 }
78 81
79 GLenum SetParameter(Texture* texture, GLenum pname, GLint param) { 82 GLenum SetParameter(Texture* texture, GLenum pname, GLint param) {
80 return texture->SetParameteri(feature_info_.get(), pname, param); 83 return texture->SetParameteri(feature_info_.get(), pname, param);
81 } 84 }
82 85
83 void DestroyTexture(Texture* texture) { 86 void DestroyTexture(Texture* texture) {
84 delete texture; 87 delete texture;
85 } 88 }
86 89
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 manager2_ = new MailboxManagerSync(); 203 manager2_ = new MailboxManagerSync();
201 context_ = new gl::GLContextStub(); 204 context_ = new gl::GLContextStub();
202 surface_ = new gl::GLSurfaceStub(); 205 surface_ = new gl::GLSurfaceStub();
203 context_->MakeCurrent(surface_.get()); 206 context_->MakeCurrent(surface_.get());
204 } 207 }
205 208
206 Texture* DefineTexture() { 209 Texture* DefineTexture() {
207 Texture* texture = CreateTexture(); 210 Texture* texture = CreateTexture();
208 const GLsizei levels_needed = TextureManager::ComputeMipMapCount( 211 const GLsizei levels_needed = TextureManager::ComputeMipMapCount(
209 GL_TEXTURE_2D, kMaxTextureWidth, kMaxTextureHeight, kMaxTextureDepth); 212 GL_TEXTURE_2D, kMaxTextureWidth, kMaxTextureHeight, kMaxTextureDepth);
210 SetTarget(texture, GL_TEXTURE_2D, levels_needed); 213 SetTarget(texture, GL_TEXTURE_2D, levels_needed, kMaxTextureDepth);
211 SetLevelInfo(texture, GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 1, 0, GL_RGBA, 214 SetLevelInfo(texture, GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 1, 0, GL_RGBA,
212 GL_UNSIGNED_BYTE, gfx::Rect(1, 1)); 215 GL_UNSIGNED_BYTE, gfx::Rect(1, 1));
213 SetParameter(texture, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 216 SetParameter(texture, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
214 SetParameter(texture, GL_TEXTURE_MAG_FILTER, GL_LINEAR); 217 SetParameter(texture, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
215 return texture; 218 return texture;
216 } 219 }
217 220
218 void SetupUpdateTexParamExpectations(GLuint texture_id, 221 void SetupUpdateTexParamExpectations(GLuint texture_id,
219 GLenum min, 222 GLenum min,
220 GLenum mag, 223 GLenum mag,
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 kNewTextureId, GL_LINEAR, GL_LINEAR, GL_REPEAT, GL_REPEAT); 336 kNewTextureId, GL_LINEAR, GL_LINEAR, GL_REPEAT, GL_REPEAT);
334 Texture* new_texture = manager2_->ConsumeTexture(name); 337 Texture* new_texture = manager2_->ConsumeTexture(name);
335 EXPECT_FALSE(new_texture == NULL); 338 EXPECT_FALSE(new_texture == NULL);
336 EXPECT_NE(texture, new_texture); 339 EXPECT_NE(texture, new_texture);
337 EXPECT_EQ(kNewTextureId, new_texture->service_id()); 340 EXPECT_EQ(kNewTextureId, new_texture->service_id());
338 341
339 // Resize original texture 342 // Resize original texture
340 SetLevelInfo(texture, GL_TEXTURE_2D, 0, GL_RGBA, 16, 32, 1, 0, GL_RGBA, 343 SetLevelInfo(texture, GL_TEXTURE_2D, 0, GL_RGBA, 16, 32, 1, 0, GL_RGBA,
341 GL_UNSIGNED_BYTE, gfx::Rect(16, 32)); 344 GL_UNSIGNED_BYTE, gfx::Rect(16, 32));
342 // Should have been orphaned 345 // Should have been orphaned
343 EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 0) == NULL); 346 EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 0, 0) == NULL);
344 347
345 // Synchronize again 348 // Synchronize again
346 manager_->PushTextureUpdates(g_sync_token); 349 manager_->PushTextureUpdates(g_sync_token);
347 SetupUpdateTexParamExpectations( 350 SetupUpdateTexParamExpectations(
348 kNewTextureId, GL_LINEAR, GL_LINEAR, GL_REPEAT, GL_REPEAT); 351 kNewTextureId, GL_LINEAR, GL_LINEAR, GL_REPEAT, GL_REPEAT);
349 manager2_->PullTextureUpdates(g_sync_token); 352 manager2_->PullTextureUpdates(g_sync_token);
350 GLsizei width, height; 353 GLsizei width, height;
351 new_texture->GetLevelSize(GL_TEXTURE_2D, 0, &width, &height, nullptr); 354 new_texture->GetLevelSize(GL_TEXTURE_2D, 0, &width, &height, nullptr);
352 EXPECT_EQ(16, width); 355 EXPECT_EQ(16, width);
353 EXPECT_EQ(32, height); 356 EXPECT_EQ(32, height);
354 357
355 // Should have gotten a new attachment 358 // Should have gotten a new attachment
356 EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 0) != NULL); 359 EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 0, 0) != NULL);
357 // Resize original texture again.... 360 // Resize original texture again....
358 SetLevelInfo(texture, GL_TEXTURE_2D, 0, GL_RGBA, 64, 64, 1, 0, GL_RGBA, 361 SetLevelInfo(texture, GL_TEXTURE_2D, 0, GL_RGBA, 64, 64, 1, 0, GL_RGBA,
359 GL_UNSIGNED_BYTE, gfx::Rect(64, 64)); 362 GL_UNSIGNED_BYTE, gfx::Rect(64, 64));
360 // ...and immediately delete the texture which should save the changes. 363 // ...and immediately delete the texture which should save the changes.
361 SetupUpdateTexParamExpectations( 364 SetupUpdateTexParamExpectations(
362 kNewTextureId, GL_LINEAR, GL_LINEAR, GL_REPEAT, GL_REPEAT); 365 kNewTextureId, GL_LINEAR, GL_LINEAR, GL_REPEAT, GL_REPEAT);
363 DestroyTexture(texture); 366 DestroyTexture(texture);
364 367
365 // Should be still around since there is a ref from manager2 368 // Should be still around since there is a ref from manager2
366 EXPECT_EQ(new_texture, manager2_->ConsumeTexture(name)); 369 EXPECT_EQ(new_texture, manager2_->ConsumeTexture(name));
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
560 563
561 EXPECT_EQ(NULL, manager_->ConsumeTexture(name)); 564 EXPECT_EQ(NULL, manager_->ConsumeTexture(name));
562 EXPECT_EQ(NULL, manager2_->ConsumeTexture(name)); 565 EXPECT_EQ(NULL, manager2_->ConsumeTexture(name));
563 } 566 }
564 567
565 TEST_F(MailboxManagerSyncTest, SyncIncompleteTexture) { 568 TEST_F(MailboxManagerSyncTest, SyncIncompleteTexture) {
566 const GLuint kNewTextureId = 1234; 569 const GLuint kNewTextureId = 1234;
567 570
568 // Create but not define texture. 571 // Create but not define texture.
569 Texture* texture = CreateTexture(); 572 Texture* texture = CreateTexture();
570 SetTarget(texture, GL_TEXTURE_2D, 1); 573 SetTarget(texture, GL_TEXTURE_2D, 1, kMaxTextureDepth);
571 EXPECT_FALSE(texture->IsDefined()); 574 EXPECT_FALSE(texture->IsDefined());
572 575
573 Mailbox name = Mailbox::Generate(); 576 Mailbox name = Mailbox::Generate();
574 manager_->ProduceTexture(name, texture); 577 manager_->ProduceTexture(name, texture);
575 EXPECT_EQ(texture, manager_->ConsumeTexture(name)); 578 EXPECT_EQ(texture, manager_->ConsumeTexture(name));
576 579
577 // Synchronize 580 // Synchronize
578 manager_->PushTextureUpdates(g_sync_token); 581 manager_->PushTextureUpdates(g_sync_token);
579 manager2_->PullTextureUpdates(g_sync_token); 582 manager2_->PullTextureUpdates(g_sync_token);
580 583
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
688 DestroyTexture(texture2); 691 DestroyTexture(texture2);
689 DestroyTexture(new_texture); 692 DestroyTexture(new_texture);
690 } 693 }
691 694
692 // TODO: Texture::level_infos_[][].size() 695 // TODO: Texture::level_infos_[][].size()
693 696
694 // TODO: unsupported targets and formats 697 // TODO: unsupported targets and formats
695 698
696 } // namespace gles2 699 } // namespace gles2
697 } // namespace gpu 700 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/mailbox_manager_sync.cc ('k') | gpu/command_buffer/service/texture_definition.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698