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

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

Issue 1335873002: Initialize default texture for GL_TEXTURE_3D and GL_TEXTURE_2D_ARRAY (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix gpu_unittests Created 5 years, 3 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/texture_manager.h" 5 #include "gpu/command_buffer/service/texture_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 1395 matching lines...) Expand 10 before | Expand all | Expand 10 after
1406 bool TextureManager::Initialize() { 1406 bool TextureManager::Initialize() {
1407 // TODO(gman): The default textures have to be real textures, not the 0 1407 // TODO(gman): The default textures have to be real textures, not the 0
1408 // texture because we simulate non shared resources on top of shared 1408 // texture because we simulate non shared resources on top of shared
1409 // resources and all contexts that share resource share the same default 1409 // resources and all contexts that share resource share the same default
1410 // texture. 1410 // texture.
1411 default_textures_[kTexture2D] = CreateDefaultAndBlackTextures( 1411 default_textures_[kTexture2D] = CreateDefaultAndBlackTextures(
1412 GL_TEXTURE_2D, &black_texture_ids_[kTexture2D]); 1412 GL_TEXTURE_2D, &black_texture_ids_[kTexture2D]);
1413 default_textures_[kCubeMap] = CreateDefaultAndBlackTextures( 1413 default_textures_[kCubeMap] = CreateDefaultAndBlackTextures(
1414 GL_TEXTURE_CUBE_MAP, &black_texture_ids_[kCubeMap]); 1414 GL_TEXTURE_CUBE_MAP, &black_texture_ids_[kCubeMap]);
1415 1415
1416 if (feature_info_->IsES3Capable()) {
Zhenyao Mo 2015/09/14 21:12:06 IsES3Enabled(). Otherwise we are still emulating E
qiankun 2015/09/15 09:14:59 Done.
1417 default_textures_[kTexture3D] = CreateDefaultAndBlackTextures(
1418 GL_TEXTURE_3D, &black_texture_ids_[kTexture3D]);
1419 default_textures_[kTexture2DArray] = CreateDefaultAndBlackTextures(
1420 GL_TEXTURE_2D_ARRAY, &black_texture_ids_[kTexture2DArray]);
1421 }
1422
1416 if (feature_info_->feature_flags().oes_egl_image_external) { 1423 if (feature_info_->feature_flags().oes_egl_image_external) {
1417 default_textures_[kExternalOES] = CreateDefaultAndBlackTextures( 1424 default_textures_[kExternalOES] = CreateDefaultAndBlackTextures(
1418 GL_TEXTURE_EXTERNAL_OES, &black_texture_ids_[kExternalOES]); 1425 GL_TEXTURE_EXTERNAL_OES, &black_texture_ids_[kExternalOES]);
1419 } 1426 }
1420 1427
1421 if (feature_info_->feature_flags().arb_texture_rectangle) { 1428 if (feature_info_->feature_flags().arb_texture_rectangle) {
1422 default_textures_[kRectangleARB] = CreateDefaultAndBlackTextures( 1429 default_textures_[kRectangleARB] = CreateDefaultAndBlackTextures(
1423 GL_TEXTURE_RECTANGLE_ARB, &black_texture_ids_[kRectangleARB]); 1430 GL_TEXTURE_RECTANGLE_ARB, &black_texture_ids_[kRectangleARB]);
1424 } 1431 }
1425 1432
(...skipping 10 matching lines...) Expand all
1436 scoped_refptr<TextureRef> 1443 scoped_refptr<TextureRef>
1437 TextureManager::CreateDefaultAndBlackTextures( 1444 TextureManager::CreateDefaultAndBlackTextures(
1438 GLenum target, 1445 GLenum target,
1439 GLuint* black_texture) { 1446 GLuint* black_texture) {
1440 static uint8 black[] = {0, 0, 0, 255}; 1447 static uint8 black[] = {0, 0, 0, 255};
1441 1448
1442 // Sampling a texture not associated with any EGLImage sibling will return 1449 // Sampling a texture not associated with any EGLImage sibling will return
1443 // black values according to the spec. 1450 // black values according to the spec.
1444 bool needs_initialization = (target != GL_TEXTURE_EXTERNAL_OES); 1451 bool needs_initialization = (target != GL_TEXTURE_EXTERNAL_OES);
1445 bool needs_faces = (target == GL_TEXTURE_CUBE_MAP); 1452 bool needs_faces = (target == GL_TEXTURE_CUBE_MAP);
1453 bool is_3d_or_2d_array_target = (target == GL_TEXTURE_3D ||
1454 target == GL_TEXTURE_2D_ARRAY);
1446 1455
1447 // Make default textures and texture for replacing non-renderable textures. 1456 // Make default textures and texture for replacing non-renderable textures.
1448 GLuint ids[2]; 1457 GLuint ids[2];
1449 const int num_ids = use_default_textures_ ? 2 : 1; 1458 const int num_ids = use_default_textures_ ? 2 : 1;
1450 glGenTextures(num_ids, ids); 1459 glGenTextures(num_ids, ids);
1451 for (int ii = 0; ii < num_ids; ++ii) { 1460 for (int ii = 0; ii < num_ids; ++ii) {
1452 glBindTexture(target, ids[ii]); 1461 glBindTexture(target, ids[ii]);
1453 if (needs_initialization) { 1462 if (needs_initialization) {
1454 if (needs_faces) { 1463 if (needs_faces) {
1455 for (int jj = 0; jj < GLES2Util::kNumFaces; ++jj) { 1464 for (int jj = 0; jj < GLES2Util::kNumFaces; ++jj) {
1456 glTexImage2D(GLES2Util::IndexToGLFaceTarget(jj), 0, GL_RGBA, 1, 1, 0, 1465 glTexImage2D(GLES2Util::IndexToGLFaceTarget(jj), 0, GL_RGBA, 1, 1, 0,
1457 GL_RGBA, GL_UNSIGNED_BYTE, black); 1466 GL_RGBA, GL_UNSIGNED_BYTE, black);
1458 } 1467 }
1459 } else { 1468 } else {
1460 glTexImage2D(target, 0, GL_RGBA, 1, 1, 0, GL_RGBA, 1469 if (is_3d_or_2d_array_target) {
1461 GL_UNSIGNED_BYTE, black); 1470 glTexImage3D(target, 0, GL_RGBA, 1, 1, 1, 0, GL_RGBA,
1471 GL_UNSIGNED_BYTE, black);
1472 } else {
1473 glTexImage2D(target, 0, GL_RGBA, 1, 1, 0, GL_RGBA,
1474 GL_UNSIGNED_BYTE, black);
1475 }
1462 } 1476 }
1463 } 1477 }
1464 } 1478 }
1465 glBindTexture(target, 0); 1479 glBindTexture(target, 0);
1466 1480
1467 scoped_refptr<TextureRef> default_texture; 1481 scoped_refptr<TextureRef> default_texture;
1468 if (use_default_textures_) { 1482 if (use_default_textures_) {
1469 default_texture = TextureRef::Create(this, 0, ids[1]); 1483 default_texture = TextureRef::Create(this, 0, ids[1]);
1470 SetTarget(default_texture.get(), target); 1484 SetTarget(default_texture.get(), target);
1471 if (needs_faces) { 1485 if (needs_faces) {
(...skipping 723 matching lines...) Expand 10 before | Expand all | Expand 10 after
2195 pmd->AddOwnershipEdge(client_guid, service_guid, importance); 2209 pmd->AddOwnershipEdge(client_guid, service_guid, importance);
2196 2210
2197 // Dump all sub-levels held by the texture. They will appear below the main 2211 // Dump all sub-levels held by the texture. They will appear below the main
2198 // gl/textures/client_X/texture_Y dump. 2212 // gl/textures/client_X/texture_Y dump.
2199 ref->texture()->DumpLevelMemory(pmd, memory_tracker_->ClientTracingId(), 2213 ref->texture()->DumpLevelMemory(pmd, memory_tracker_->ClientTracingId(),
2200 dump_name); 2214 dump_name);
2201 } 2215 }
2202 2216
2203 } // namespace gles2 2217 } // namespace gles2
2204 } // namespace gpu 2218 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698