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

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

Issue 1872663002: Enable TexStorage on Desktop GL lower than 4.2 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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/gles2_cmd_decoder.h" 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h"
6 6
7 #include <limits.h> 7 #include <limits.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 #include <stdio.h> 10 #include <stdio.h>
(...skipping 965 matching lines...) Expand 10 before | Expand all | Expand 10 after
976 GLint x, 976 GLint x,
977 GLint y, 977 GLint y,
978 GLsizei width, 978 GLsizei width,
979 GLsizei height, 979 GLsizei height,
980 GLboolean unpack_flip_y, 980 GLboolean unpack_flip_y,
981 GLboolean unpack_premultiply_alpha, 981 GLboolean unpack_premultiply_alpha,
982 GLboolean unpack_unmultiply_alpha); 982 GLboolean unpack_unmultiply_alpha);
983 983
984 void DoCompressedCopyTextureCHROMIUM(GLuint source_id, GLuint dest_id); 984 void DoCompressedCopyTextureCHROMIUM(GLuint source_id, GLuint dest_id);
985 985
986 // Helper for DoTexStorage2DEXT and DoTexStorage3D.
987 void TexStorageImpl(
988 GLenum target, GLint levels, GLenum internal_format,
989 GLsizei width, GLsizei height, GLsizei depth,
990 ContextState::Dimension dimension, const char* function_name);
991
986 // Wrapper for TexStorage2DEXT. 992 // Wrapper for TexStorage2DEXT.
987 void DoTexStorage2DEXT( 993 void DoTexStorage2DEXT(
988 GLenum target, 994 GLenum target,
989 GLint levels, 995 GLint levels,
990 GLenum internal_format, 996 GLenum internal_format,
991 GLsizei width, 997 GLsizei width,
992 GLsizei height); 998 GLsizei height);
993 999
994 // Wrapper for TexStorage3D. 1000 // Wrapper for TexStorage3D.
995 void DoTexStorage3D( 1001 void DoTexStorage3D(
(...skipping 7820 matching lines...) Expand 10 before | Expand all | Expand 10 after
8816 LOCAL_SET_GL_ERROR( 8822 LOCAL_SET_GL_ERROR(
8817 GL_INVALID_OPERATION, "glGetSamplerParamteriv", "unknown sampler"); 8823 GL_INVALID_OPERATION, "glGetSamplerParamteriv", "unknown sampler");
8818 return; 8824 return;
8819 } 8825 }
8820 glGetSamplerParameteriv(sampler->service_id(), pname, params); 8826 glGetSamplerParameteriv(sampler->service_id(), pname, params);
8821 } 8827 }
8822 8828
8823 void GLES2DecoderImpl::DoGetTexParameterfv( 8829 void GLES2DecoderImpl::DoGetTexParameterfv(
8824 GLenum target, GLenum pname, GLfloat* params) { 8830 GLenum target, GLenum pname, GLfloat* params) {
8825 InitTextureMaxAnisotropyIfNeeded(target, pname); 8831 InitTextureMaxAnisotropyIfNeeded(target, pname);
8832 if (pname == GL_TEXTURE_IMMUTABLE_FORMAT &&
8833 feature_info_->gl_version_info().IsLowerThanGL(4, 2) &&
8834 !features().ext_texture_storage) {
piman 2016/04/11 22:59:31 I'm not sure when that condition would be true. GL
Zhenyao Mo 2016/04/11 23:17:19 This will be removed for option 2.
8835 // We emulate TexStorage calls in such situations.
8836 TextureRef* texture_ref = texture_manager()->GetTextureInfoForTarget(
8837 &state_, target);
8838 if (texture_ref) {
8839 Texture* texture = texture_ref->texture();
8840 *params = static_cast<GLfloat>(texture->IsImmutable());
8841 return;
8842 }
8843 }
8826 glGetTexParameterfv(target, pname, params); 8844 glGetTexParameterfv(target, pname, params);
8827 } 8845 }
8828 8846
8829 void GLES2DecoderImpl::DoGetTexParameteriv( 8847 void GLES2DecoderImpl::DoGetTexParameteriv(
8830 GLenum target, GLenum pname, GLint* params) { 8848 GLenum target, GLenum pname, GLint* params) {
8831 InitTextureMaxAnisotropyIfNeeded(target, pname); 8849 InitTextureMaxAnisotropyIfNeeded(target, pname);
8850 if (pname == GL_TEXTURE_IMMUTABLE_FORMAT &&
8851 feature_info_->gl_version_info().IsLowerThanGL(4, 2) &&
8852 !features().ext_texture_storage) {
8853 // We emulate TexStorage calls in such situations.
8854 TextureRef* texture_ref = texture_manager()->GetTextureInfoForTarget(
8855 &state_, target);
8856 if (texture_ref) {
8857 Texture* texture = texture_ref->texture();
8858 *params = static_cast<GLint>(texture->IsImmutable());
8859 return;
8860 }
8861 }
8832 glGetTexParameteriv(target, pname, params); 8862 glGetTexParameteriv(target, pname, params);
8833 } 8863 }
8834 8864
8835 void GLES2DecoderImpl::InitTextureMaxAnisotropyIfNeeded( 8865 void GLES2DecoderImpl::InitTextureMaxAnisotropyIfNeeded(
8836 GLenum target, GLenum pname) { 8866 GLenum target, GLenum pname) {
8837 if (!workarounds().init_texture_max_anisotropy) 8867 if (!workarounds().init_texture_max_anisotropy)
8838 return; 8868 return;
8839 if (pname != GL_TEXTURE_MAX_ANISOTROPY_EXT || 8869 if (pname != GL_TEXTURE_MAX_ANISOTROPY_EXT ||
8840 !validators_->texture_parameter.IsValid(pname)) { 8870 !validators_->texture_parameter.IsValid(pname)) {
8841 return; 8871 return;
(...skipping 5449 matching lines...) Expand 10 before | Expand all | Expand 10 after
14291 source_height, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 14321 source_height, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE,
14292 gfx::Rect(source_width, source_height)); 14322 gfx::Rect(source_width, source_height));
14293 14323
14294 copy_texture_CHROMIUM_->DoCopyTexture( 14324 copy_texture_CHROMIUM_->DoCopyTexture(
14295 this, source_texture->target(), source_texture->service_id(), 14325 this, source_texture->target(), source_texture->service_id(),
14296 source_internal_format, dest_texture->target(), 14326 source_internal_format, dest_texture->target(),
14297 dest_texture->service_id(), GL_RGBA, source_width, source_height, false, 14327 dest_texture->service_id(), GL_RGBA, source_width, source_height, false,
14298 false, false); 14328 false, false);
14299 } 14329 }
14300 14330
14301 void GLES2DecoderImpl::DoTexStorage2DEXT( 14331 void GLES2DecoderImpl::TexStorageImpl(
14302 GLenum target, 14332 GLenum target, GLint levels, GLenum internal_format,
14303 GLint levels, 14333 GLsizei width, GLsizei height, GLsizei depth,
14304 GLenum internal_format, 14334 ContextState::Dimension dimension, const char* function_name) {
14305 GLsizei width, 14335 if (dimension == ContextState::k2D) {
14306 GLsizei height) { 14336 if (!validators_->texture_bind_target.IsValid(target)) {
14307 TRACE_EVENT2("gpu", "GLES2DecoderImpl::DoTexStorage2DEXT", 14337 LOCAL_SET_GL_ERROR_INVALID_ENUM(function_name, target, "target");
14308 "width", width, "height", height); 14338 return;
14309 if (!texture_manager()->ValidForTarget(target, 0, width, height, 1) || 14339 }
14310 TextureManager::ComputeMipMapCount(target, width, height, 1) < levels) { 14340 } else {
14341 if (!validators_->texture_3_d_target.IsValid(target)) {
14342 LOCAL_SET_GL_ERROR_INVALID_ENUM(function_name, target, "target");
14343 return;
14344 }
14345 }
14346 if (levels <= 0) {
14347 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, "levels <= 0");
14348 return;
14349 }
14350 if (!validators_->texture_internal_format_storage.IsValid(internal_format)) {
14351 LOCAL_SET_GL_ERROR_INVALID_ENUM(
14352 function_name, internal_format, "internal_format");
14353 return;
14354 }
14355 bool is_compressed_format;
14356 switch (internal_format) {
14357 case GL_COMPRESSED_R11_EAC:
14358 case GL_COMPRESSED_SIGNED_R11_EAC:
14359 case GL_COMPRESSED_RG11_EAC:
14360 case GL_COMPRESSED_SIGNED_RG11_EAC:
14361 case GL_COMPRESSED_RGB8_ETC2:
14362 case GL_COMPRESSED_SRGB8_ETC2:
14363 case GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2:
14364 case GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2:
14365 case GL_COMPRESSED_RGBA8_ETC2_EAC:
14366 case GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:
14367 is_compressed_format = true;
14368 if (target == GL_TEXTURE_3D) {
14369 LOCAL_SET_GL_ERROR(
14370 GL_INVALID_OPERATION, function_name, "target invalid for format");
14371 return;
14372 }
14373 break;
14374 default:
14375 is_compressed_format = false;
14376 break;
14377 }
14378 if (!texture_manager()->ValidForTarget(target, 0, width, height, depth) ||
14379 TextureManager::ComputeMipMapCount(
14380 target, width, height, depth) < levels) {
14311 LOCAL_SET_GL_ERROR( 14381 LOCAL_SET_GL_ERROR(
14312 GL_INVALID_VALUE, "glTexStorage2DEXT", "dimensions out of range"); 14382 GL_INVALID_VALUE, function_name, "dimensions out of range");
14313 return; 14383 return;
14314 } 14384 }
14315 TextureRef* texture_ref = texture_manager()->GetTextureInfoForTarget( 14385 TextureRef* texture_ref = texture_manager()->GetTextureInfoForTarget(
14316 &state_, target); 14386 &state_, target);
14317 if (!texture_ref) { 14387 if (!texture_ref) {
14318 LOCAL_SET_GL_ERROR( 14388 LOCAL_SET_GL_ERROR(
14319 GL_INVALID_OPERATION, 14389 GL_INVALID_OPERATION, function_name, "unknown texture for target");
14320 "glTexStorage2DEXT", "unknown texture for target");
14321 return; 14390 return;
14322 } 14391 }
14323 Texture* texture = texture_ref->texture(); 14392 Texture* texture = texture_ref->texture();
14324 if (texture->IsAttachedToFramebuffer()) {
14325 framebuffer_state_.clear_state_dirty = true;
14326 }
14327 if (texture->IsImmutable()) {
14328 LOCAL_SET_GL_ERROR(
14329 GL_INVALID_OPERATION,
14330 "glTexStorage2DEXT", "texture is immutable");
14331 return;
14332 }
14333
14334 GLenum format = TextureManager::ExtractFormatFromStorageFormat(
14335 internal_format);
14336 GLenum type = TextureManager::ExtractTypeFromStorageFormat(internal_format);
14337
14338 {
14339 GLsizei level_width = width;
14340 GLsizei level_height = height;
14341 uint32_t estimated_size = 0;
14342 for (int ii = 0; ii < levels; ++ii) {
14343 uint32_t level_size = 0;
14344 if (!GLES2Util::ComputeImageDataSizes(
14345 level_width, level_height, 1, format, type, state_.unpack_alignment,
14346 &estimated_size, NULL, NULL) ||
14347 !SafeAddUint32(estimated_size, level_size, &estimated_size)) {
14348 LOCAL_SET_GL_ERROR(
14349 GL_OUT_OF_MEMORY, "glTexStorage2DEXT", "dimensions too large");
14350 return;
14351 }
14352 level_width = std::max(1, level_width >> 1);
14353 level_height = std::max(1, level_height >> 1);
14354 }
14355 if (!EnsureGPUMemoryAvailable(estimated_size)) {
14356 LOCAL_SET_GL_ERROR(
14357 GL_OUT_OF_MEMORY, "glTexStorage2DEXT", "out of memory");
14358 return;
14359 }
14360 }
14361
14362 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glTexStorage2DEXT");
14363 glTexStorage2DEXT(target, levels, internal_format, width, height);
14364 GLenum error = LOCAL_PEEK_GL_ERROR("glTexStorage2DEXT");
14365 if (error == GL_NO_ERROR) {
14366 GLsizei level_width = width;
14367 GLsizei level_height = height;
14368
14369 GLenum cur_format = feature_info_->IsES3Enabled() ?
14370 internal_format : format;
14371 for (int ii = 0; ii < levels; ++ii) {
14372 if (target == GL_TEXTURE_CUBE_MAP) {
14373 for (int jj = 0; jj < 6; ++jj) {
14374 GLenum face = GL_TEXTURE_CUBE_MAP_POSITIVE_X + jj;
14375 texture_manager()->SetLevelInfo(texture_ref, face, ii, cur_format,
14376 level_width, level_height, 1, 0,
14377 format, type, gfx::Rect());
14378 }
14379 } else {
14380 texture_manager()->SetLevelInfo(texture_ref, target, ii, cur_format,
14381 level_width, level_height, 1, 0,
14382 format, type, gfx::Rect());
14383 }
14384 level_width = std::max(1, level_width >> 1);
14385 level_height = std::max(1, level_height >> 1);
14386 }
14387 texture->SetImmutable(true);
14388 }
14389 }
14390
14391 void GLES2DecoderImpl::DoTexStorage3D(
14392 GLenum target,
14393 GLint levels,
14394 GLenum internal_format,
14395 GLsizei width,
14396 GLsizei height,
14397 GLsizei depth) {
14398 TRACE_EVENT2("gpu", "GLES2DecoderImpl::DoTexStorage3D",
14399 "widthXheight", width * height, "depth", depth);
14400 if (!validators_->texture_3_d_target.IsValid(target)) {
14401 LOCAL_SET_GL_ERROR_INVALID_ENUM("glTexStorage3D", target, "target");
14402 return;
14403 }
14404 if (levels <= 0) {
14405 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glTexStorage3D", "levels <= 0");
14406 return;
14407 }
14408 if (!validators_->texture_internal_format_storage.IsValid(internal_format)) {
14409 LOCAL_SET_GL_ERROR_INVALID_ENUM("glTexStorage3D", internal_format,
14410 "internal_format");
14411 return;
14412 }
14413 if (width <= 0) {
14414 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glTexStorage3D", "width <= 0");
14415 return;
14416 }
14417 if (height <= 0) {
14418 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glTexStorage3D", "height <= 0");
14419 return;
14420 }
14421 if (depth <= 0) {
14422 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glTexStorage3D", "depth <= 0");
14423 return;
14424 }
14425 if (!texture_manager()->ValidForTarget(target, 0, width, height, depth) ||
14426 TextureManager::ComputeMipMapCount(
14427 target, width, height, depth) < levels) {
14428 LOCAL_SET_GL_ERROR(
14429 GL_INVALID_VALUE, "glTexStorage3D", "dimensions out of range");
14430 return;
14431 }
14432 TextureRef* texture_ref = texture_manager()->GetTextureInfoForTarget(
14433 &state_, target);
14434 if (!texture_ref) {
14435 LOCAL_SET_GL_ERROR(
14436 GL_INVALID_OPERATION,
14437 "glTexStorage3D", "unknown texture for target");
14438 return;
14439 }
14440 Texture* texture = texture_ref->texture();
14441 if (texture->IsAttachedToFramebuffer()) { 14393 if (texture->IsAttachedToFramebuffer()) {
14442 framebuffer_state_.clear_state_dirty = true; 14394 framebuffer_state_.clear_state_dirty = true;
14443 } 14395 }
14444 if (texture->IsImmutable()) { 14396 if (texture->IsImmutable()) {
14445 LOCAL_SET_GL_ERROR( 14397 LOCAL_SET_GL_ERROR(
14446 GL_INVALID_OPERATION, "glTexStorage3D", "texture is immutable"); 14398 GL_INVALID_OPERATION, function_name, "texture is immutable");
14447 return; 14399 return;
14448 } 14400 }
14449 14401
14450 GLenum format = TextureManager::ExtractFormatFromStorageFormat( 14402 GLenum format = TextureManager::ExtractFormatFromStorageFormat(
14451 internal_format); 14403 internal_format);
14452 GLenum type = TextureManager::ExtractTypeFromStorageFormat(internal_format); 14404 GLenum type = TextureManager::ExtractTypeFromStorageFormat(internal_format);
14453 14405
14406 std::vector<int32_t> level_size(levels);
14407 {
14408 GLsizei level_width = width;
14409 GLsizei level_height = height;
14410 GLsizei level_depth = depth;
14411 base::CheckedNumeric<uint32_t> estimated_size(0);
14412 PixelStoreParams params;
14413 params.alignment = 1;
14414 for (int ii = 0; ii < levels; ++ii) {
14415 uint32_t size;
14416 if (is_compressed_format) {
14417 if (!GetCompressedTexSizeInBytes(function_name,
14418 level_width, level_height, level_depth,
14419 internal_format, &level_size[ii])) {
14420 // GetCompressedTexSizeInBytes() already generates a GL error.
14421 return;
14422 }
14423 size = static_cast<uint32_t>(level_size[ii]);
14424 } else {
14425 if (!GLES2Util::ComputeImageDataSizesES3(level_width,
14426 level_height,
14427 level_depth,
14428 format, type,
14429 params,
14430 &size,
14431 nullptr, nullptr,
14432 nullptr, nullptr)) {
14433 LOCAL_SET_GL_ERROR(
14434 GL_OUT_OF_MEMORY, function_name, "dimensions too large");
14435 return;
14436 }
14437 }
14438 estimated_size += size;
14439 level_width = std::max(1, level_width >> 1);
14440 level_height = std::max(1, level_height >> 1);
14441 if (target == GL_TEXTURE_3D)
14442 level_depth = std::max(1, level_depth >> 1);
14443 }
14444 if (!estimated_size.IsValid() ||
14445 !EnsureGPUMemoryAvailable(estimated_size.ValueOrDefault(0))) {
14446 LOCAL_SET_GL_ERROR(GL_OUT_OF_MEMORY, function_name, "out of memory");
14447 return;
14448 }
14449 }
14450
14451 if (feature_info_->gl_version_info().IsLowerThanGL(4, 2) &&
14452 !features().ext_texture_storage) {
14453 // Emulate TexStorage with TexImage or CompressedTexImage.
14454 Buffer* bound_buffer = buffer_manager()->GetBufferInfoForTarget(
14455 &state_, GL_PIXEL_UNPACK_BUFFER);
14456 if (bound_buffer) {
14457 glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
14458 }
14459
14460 scoped_ptr<char[]> zero_data;
14461 if (is_compressed_format) {
14462 zero_data.reset(new char[level_size[0]]);
14463 memset(zero_data.get(), 0, level_size[0]);
14464 }
14465
14466 GLsizei level_width = width;
14467 GLsizei level_height = height;
14468 GLsizei level_depth = depth;
14469 for (int ii = 0; ii < levels; ++ii) {
14470 if (dimension == ContextState::k2D) {
14471 if (target == GL_TEXTURE_CUBE_MAP) {
14472 for (int jj = 0; jj < 6; ++jj) {
14473 GLenum face = GL_TEXTURE_CUBE_MAP_POSITIVE_X + jj;
14474 if (is_compressed_format) {
14475 glCompressedTexImage2D(face, ii, internal_format,
14476 level_width, level_height, 0,
14477 level_size[ii], zero_data.get());
14478 } else {
14479 glTexImage2D(face, ii, internal_format, level_width, level_height,
14480 0, format, type, nullptr);
14481 }
14482 }
14483 } else {
14484 if (is_compressed_format) {
14485 glCompressedTexImage2D(target, ii, internal_format,
14486 level_width, level_height, 0,
14487 level_size[ii], zero_data.get());
14488 } else {
14489 glTexImage2D(target, ii, internal_format, level_width, level_height,
14490 0, format, type, nullptr);
14491 }
14492 }
14493 } else { // dimension == ContextState::k3D
14494 if (is_compressed_format) {
14495 DCHECK(target != GL_TEXTURE_3D);
14496 glCompressedTexImage3D(target, ii, internal_format,
14497 level_width, level_height, level_depth, 0,
14498 level_size[ii], zero_data.get());
14499 } else {
14500 glTexImage3D(target, ii, internal_format, width, height, depth,
14501 0, format, type, nullptr);
14502 }
14503 }
14504 level_width = std::max(1, level_width >> 1);
14505 level_height = std::max(1, level_height >> 1);
14506 if (target == GL_TEXTURE_3D)
14507 level_depth = std::max(1, level_depth >> 1);
14508 } // end of for-loop
14509 if (bound_buffer) {
14510 glBindBuffer(GL_PIXEL_UNPACK_BUFFER, bound_buffer->service_id());
14511 }
14512 } else {
14513 if (dimension == ContextState::k2D)
14514 glTexStorage2DEXT(target, levels, internal_format, width, height);
14515 else
14516 glTexStorage3D(target, levels, internal_format, width, height, depth);
14517 }
14518
14454 { 14519 {
14455 GLsizei level_width = width; 14520 GLsizei level_width = width;
14456 GLsizei level_height = height; 14521 GLsizei level_height = height;
14457 GLsizei level_depth = depth; 14522 GLsizei level_depth = depth;
14458 uint32_t estimated_size = 0; 14523 GLenum adjusted_format =
14524 feature_info_->IsES3Enabled() ? internal_format : format;
14459 for (int ii = 0; ii < levels; ++ii) { 14525 for (int ii = 0; ii < levels; ++ii) {
14460 uint32_t level_size = 0; 14526 if (target == GL_TEXTURE_CUBE_MAP) {
14461 if (!GLES2Util::ComputeImageDataSizes( 14527 for (int jj = 0; jj < 6; ++jj) {
14462 level_width, level_height, level_depth, format, type, 14528 GLenum face = GL_TEXTURE_CUBE_MAP_POSITIVE_X + jj;
14463 state_.unpack_alignment, 14529 texture_manager()->SetLevelInfo(texture_ref, face, ii,
14464 &estimated_size, NULL, NULL) || 14530 adjusted_format,
14465 !SafeAddUint32(estimated_size, level_size, &estimated_size)) { 14531 level_width, level_height, 1,
14466 LOCAL_SET_GL_ERROR( 14532 0, format, type, gfx::Rect());
14467 GL_OUT_OF_MEMORY, "glTexStorage3D", "dimensions too large"); 14533 }
14468 return; 14534 } else {
14535 texture_manager()->SetLevelInfo(texture_ref, target, ii,
14536 adjusted_format,
14537 level_width, level_height, level_depth,
14538 0, format, type, gfx::Rect());
14469 } 14539 }
14470 level_width = std::max(1, level_width >> 1); 14540 level_width = std::max(1, level_width >> 1);
14471 level_height = std::max(1, level_height >> 1); 14541 level_height = std::max(1, level_height >> 1);
14472 if (target == GL_TEXTURE_3D) 14542 if (target == GL_TEXTURE_3D)
14473 level_depth = std::max(1, level_depth >> 1);
14474 }
14475 if (!EnsureGPUMemoryAvailable(estimated_size)) {
14476 LOCAL_SET_GL_ERROR(
14477 GL_OUT_OF_MEMORY, "glTexStorage3D", "out of memory");
14478 return;
14479 }
14480 }
14481
14482 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glTexStorage3D");
14483 glTexStorage3D(target, levels, internal_format, width, height, depth);
14484 GLenum error = LOCAL_PEEK_GL_ERROR("glTexStorage3D");
14485 if (error == GL_NO_ERROR) {
14486 GLsizei level_width = width;
14487 GLsizei level_height = height;
14488 GLsizei level_depth = depth;
14489
14490 GLenum cur_format = feature_info_->IsES3Enabled() ?
14491 internal_format : format;
14492 for (int ii = 0; ii < levels; ++ii) {
14493 texture_manager()->SetLevelInfo(texture_ref, target, ii, cur_format,
14494 level_width, level_height, level_depth, 0,
14495 format, type, gfx::Rect());
14496 level_width = std::max(1, level_width >> 1);
14497 level_height = std::max(1, level_height >> 1);
14498 if (target == GL_TEXTURE_3D)
14499 level_depth = std::max(1, level_depth >> 1); 14543 level_depth = std::max(1, level_depth >> 1);
14500 } 14544 }
14501 texture->SetImmutable(true); 14545 texture->SetImmutable(true);
14502 } 14546 }
14503 } 14547 }
14504 14548
14549 void GLES2DecoderImpl::DoTexStorage2DEXT(
14550 GLenum target,
14551 GLint levels,
14552 GLenum internal_format,
14553 GLsizei width,
14554 GLsizei height) {
14555 TRACE_EVENT2("gpu", "GLES2DecoderImpl::DoTexStorage2D",
14556 "width", width, "height", height);
14557 TexStorageImpl(target, levels, internal_format, width, height, 1,
14558 ContextState::k2D, "glTexStorage2D");
14559 }
14560
14561 void GLES2DecoderImpl::DoTexStorage3D(
14562 GLenum target,
14563 GLint levels,
14564 GLenum internal_format,
14565 GLsizei width,
14566 GLsizei height,
14567 GLsizei depth) {
14568 TRACE_EVENT2("gpu", "GLES2DecoderImpl::DoTexStorage3D",
14569 "widthXheight", width * height, "depth", depth);
14570 TexStorageImpl(target, levels, internal_format, width, height, depth,
14571 ContextState::k3D, "glTexStorage3D");
14572 }
14573
14505 error::Error GLES2DecoderImpl::HandleGenMailboxCHROMIUM( 14574 error::Error GLES2DecoderImpl::HandleGenMailboxCHROMIUM(
14506 uint32_t immediate_data_size, 14575 uint32_t immediate_data_size,
14507 const void* cmd_data) { 14576 const void* cmd_data) {
14508 return error::kUnknownCommand; 14577 return error::kUnknownCommand;
14509 } 14578 }
14510 14579
14511 void GLES2DecoderImpl::DoProduceTextureCHROMIUM(GLenum target, 14580 void GLES2DecoderImpl::DoProduceTextureCHROMIUM(GLenum target,
14512 const GLbyte* data) { 14581 const GLbyte* data) {
14513 TRACE_EVENT2("gpu", "GLES2DecoderImpl::DoProduceTextureCHROMIUM", 14582 TRACE_EVENT2("gpu", "GLES2DecoderImpl::DoProduceTextureCHROMIUM",
14514 "context", logger_.GetLogPrefix(), 14583 "context", logger_.GetLogPrefix(),
(...skipping 1862 matching lines...) Expand 10 before | Expand all | Expand 10 after
16377 } 16446 }
16378 16447
16379 // Include the auto-generated part of this file. We split this because it means 16448 // Include the auto-generated part of this file. We split this because it means
16380 // we can easily edit the non-auto generated parts right here in this file 16449 // we can easily edit the non-auto generated parts right here in this file
16381 // instead of having to edit some template or the code generator. 16450 // instead of having to edit some template or the code generator.
16382 #include "base/macros.h" 16451 #include "base/macros.h"
16383 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 16452 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
16384 16453
16385 } // namespace gles2 16454 } // namespace gles2
16386 } // namespace gpu 16455 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698