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

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

Issue 1925093002: Handle compressed textures allocated via TexStorage2D. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed obsolete method and fixed tests. Created 4 years, 7 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 1242 matching lines...) Expand 10 before | Expand all | Expand 10 after
1253 unsigned target, 1253 unsigned target,
1254 int level, 1254 int level,
1255 unsigned format, 1255 unsigned format,
1256 unsigned type, 1256 unsigned type,
1257 int xoffset, 1257 int xoffset,
1258 int yoffset, 1258 int yoffset,
1259 int width, 1259 int width,
1260 int height) override; 1260 int height) override;
1261 1261
1262 // overridden from GLES2Decoder 1262 // overridden from GLES2Decoder
1263 bool ClearCompressedTextureLevel(Texture* texture,
1264 unsigned target,
1265 int level,
1266 unsigned format,
1267 int width,
1268 int height) override;
1269
1270 // overridden from GLES2Decoder
1263 bool ClearLevel3D(Texture* texture, 1271 bool ClearLevel3D(Texture* texture,
1264 unsigned target, 1272 unsigned target,
1265 int level, 1273 int level,
1266 unsigned format, 1274 unsigned format,
1267 unsigned type, 1275 unsigned type,
1268 int width, 1276 int width,
1269 int height, 1277 int height,
1270 int depth) override; 1278 int depth) override;
1271 1279
1272 // Restore all GL state that affects clearing. 1280 // Restore all GL state that affects clearing.
(...skipping 9136 matching lines...) Expand 10 before | Expand all | Expand 10 after
10409 zero.get()); 10417 zero.get());
10410 y += tile_height; 10418 y += tile_height;
10411 } 10419 }
10412 TextureRef* bound_texture = 10420 TextureRef* bound_texture =
10413 texture_manager()->GetTextureInfoForTarget(&state_, texture->target()); 10421 texture_manager()->GetTextureInfoForTarget(&state_, texture->target());
10414 glBindTexture(texture->target(), 10422 glBindTexture(texture->target(),
10415 bound_texture ? bound_texture->service_id() : 0); 10423 bound_texture ? bound_texture->service_id() : 0);
10416 return true; 10424 return true;
10417 } 10425 }
10418 10426
10427 bool GLES2DecoderImpl::ClearCompressedTextureLevel(Texture* texture,
10428 unsigned target,
10429 int level,
10430 unsigned format,
10431 int width,
10432 int height) {
10433 DCHECK(target != GL_TEXTURE_3D && target != GL_TEXTURE_2D_ARRAY);
10434 // This code path can only be called if the texture was originally
10435 // allocated via TexStorage2D.
Zhenyao Mo 2016/04/28 17:57:13 nit: can you also add a comment here that although
Ken Russell (switch to Gerrit) 2016/04/29 13:10:06 Done.
10436 DCHECK(feature_info_->IsES3Enabled());
10437
10438 GLsizei bytes_required = 0;
10439 if (!GetCompressedTexSizeInBytes(
10440 "ClearCompressedTextureLevel", width, height, 1, format,
10441 &bytes_required)) {
10442 return false;
10443 }
10444
10445 TRACE_EVENT1("gpu", "GLES2DecoderImpl::ClearCompressedTextureLevel",
10446 "bytes_required", bytes_required);
10447
10448 std::unique_ptr<char[]> zero(new char[bytes_required]);
10449 memset(zero.get(), 0, bytes_required);
10450 glBindTexture(texture->target(), texture->service_id());
Zhenyao Mo 2016/04/28 17:57:13 You also need to unbind the PIXEL_UNPACK_BUFFER if
Ken Russell (switch to Gerrit) 2016/04/29 13:10:06 Thanks for pointing that out. Done.
10451 glCompressedTexSubImage2D(
10452 target, level, 0, 0, width, height, format, bytes_required, zero.get());
10453 TextureRef* bound_texture =
10454 texture_manager()->GetTextureInfoForTarget(&state_, texture->target());
10455 glBindTexture(texture->target(),
10456 bound_texture ? bound_texture->service_id() : 0);
10457 return true;
10458 }
10459
10419 bool GLES2DecoderImpl::ClearLevel3D(Texture* texture, 10460 bool GLES2DecoderImpl::ClearLevel3D(Texture* texture,
10420 unsigned target, 10461 unsigned target,
10421 int level, 10462 int level,
10422 unsigned format, 10463 unsigned format,
10423 unsigned type, 10464 unsigned type,
10424 int width, 10465 int width,
10425 int height, 10466 int height,
10426 int depth) { 10467 int depth) {
10427 DCHECK(target == GL_TEXTURE_3D || target == GL_TEXTURE_2D_ARRAY); 10468 DCHECK(target == GL_TEXTURE_3D || target == GL_TEXTURE_2D_ARRAY);
10428 DCHECK(feature_info_->IsES3Enabled()); 10469 DCHECK(feature_info_->IsES3Enabled());
(...skipping 1196 matching lines...) Expand 10 before | Expand all | Expand 10 after
11625 } 11666 }
11626 11667
11627 if (!ValidateCompressedTexFuncData("glCompressedTexSubImage2D", 11668 if (!ValidateCompressedTexFuncData("glCompressedTexSubImage2D",
11628 width, height, 1, format, image_size) || 11669 width, height, 1, format, image_size) ||
11629 !ValidateCompressedTexSubDimensions("glCompressedTexSubImage2D", 11670 !ValidateCompressedTexSubDimensions("glCompressedTexSubImage2D",
11630 target, level, xoffset, yoffset, 0, 11671 target, level, xoffset, yoffset, 0,
11631 width, height, 1, format, texture)) { 11672 width, height, 1, format, texture)) {
11632 return; 11673 return;
11633 } 11674 }
11634 11675
11676 if (!texture->IsLevelCleared(target, level)) {
11677 // This can only happen if the compressed texture was allocated
11678 // using TexStorage2D.
11679 DCHECK(texture->IsImmutable());
11680 GLsizei level_width = 0, level_height = 0;
11681 bool success = texture->GetLevelSize(
11682 target, level, &level_width, &level_height, nullptr);
11683 DCHECK(success);
11684 // We can skip the clear if we're uploading the entire level.
11685 if (xoffset == 0 && yoffset == 0 &&
11686 width == level_width && height == level_height) {
11687 texture_manager()->SetLevelCleared(texture_ref, target, level, true);
11688 } else {
11689 texture_manager()->ClearTextureLevel(this, texture_ref, target, level);
11690 }
11691 DCHECK(texture->IsLevelCleared(target, level));
11692 }
11635 11693
11636 // Note: There is no need to deal with texture cleared tracking here
11637 // because the validation above means you can only get here if the level
11638 // is already a matching compressed format and in that case
11639 // CompressedTexImage2D already cleared the texture.
11640 glCompressedTexSubImage2D( 11694 glCompressedTexSubImage2D(
11641 target, level, xoffset, yoffset, width, height, format, image_size, data); 11695 target, level, xoffset, yoffset, width, height, format, image_size, data);
11642 11696
11643 // This may be a slow command. Exit command processing to allow for 11697 // This may be a slow command. Exit command processing to allow for
11644 // context preemption and GPU watchdog checks. 11698 // context preemption and GPU watchdog checks.
11645 ExitCommandProcessingEarly(); 11699 ExitCommandProcessingEarly();
11646 } 11700 }
11647 11701
11648 static void Clip( 11702 static void Clip(
11649 GLint start, GLint range, GLint sourceRange, 11703 GLint start, GLint range, GLint sourceRange,
(...skipping 2674 matching lines...) Expand 10 before | Expand all | Expand 10 after
14324 } 14378 }
14325 if (levels <= 0) { 14379 if (levels <= 0) {
14326 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, "levels <= 0"); 14380 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, "levels <= 0");
14327 return; 14381 return;
14328 } 14382 }
14329 if (!validators_->texture_internal_format_storage.IsValid(internal_format)) { 14383 if (!validators_->texture_internal_format_storage.IsValid(internal_format)) {
14330 LOCAL_SET_GL_ERROR_INVALID_ENUM( 14384 LOCAL_SET_GL_ERROR_INVALID_ENUM(
14331 function_name, internal_format, "internal_format"); 14385 function_name, internal_format, "internal_format");
14332 return; 14386 return;
14333 } 14387 }
14334 bool is_compressed_format; 14388 bool is_compressed_format = GLES2Util::IsCompressedTextureFormat(
14335 switch (internal_format) { 14389 internal_format);
14336 case GL_COMPRESSED_R11_EAC: 14390 if (is_compressed_format && target == GL_TEXTURE_3D) {
14337 case GL_COMPRESSED_SIGNED_R11_EAC: 14391 LOCAL_SET_GL_ERROR(
14338 case GL_COMPRESSED_RG11_EAC: 14392 GL_INVALID_OPERATION, function_name, "target invalid for format");
14339 case GL_COMPRESSED_SIGNED_RG11_EAC: 14393 return;
14340 case GL_COMPRESSED_RGB8_ETC2:
14341 case GL_COMPRESSED_SRGB8_ETC2:
14342 case GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2:
14343 case GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2:
14344 case GL_COMPRESSED_RGBA8_ETC2_EAC:
14345 case GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:
14346 is_compressed_format = true;
14347 if (target == GL_TEXTURE_3D) {
14348 LOCAL_SET_GL_ERROR(
14349 GL_INVALID_OPERATION, function_name, "target invalid for format");
14350 return;
14351 }
14352 break;
14353 default:
14354 is_compressed_format = false;
14355 break;
14356 } 14394 }
14395
14357 if (!texture_manager()->ValidForTarget(target, 0, width, height, depth) || 14396 if (!texture_manager()->ValidForTarget(target, 0, width, height, depth) ||
14358 TextureManager::ComputeMipMapCount( 14397 TextureManager::ComputeMipMapCount(
14359 target, width, height, depth) < levels) { 14398 target, width, height, depth) < levels) {
14360 LOCAL_SET_GL_ERROR( 14399 LOCAL_SET_GL_ERROR(
14361 GL_INVALID_VALUE, function_name, "dimensions out of range"); 14400 GL_INVALID_VALUE, function_name, "dimensions out of range");
14362 return; 14401 return;
14363 } 14402 }
14364 TextureRef* texture_ref = texture_manager()->GetTextureInfoForTarget( 14403 TextureRef* texture_ref = texture_manager()->GetTextureInfoForTarget(
14365 &state_, target); 14404 &state_, target);
14366 if (!texture_ref) { 14405 if (!texture_ref) {
(...skipping 2012 matching lines...) Expand 10 before | Expand all | Expand 10 after
16379 } 16418 }
16380 16419
16381 // Include the auto-generated part of this file. We split this because it means 16420 // Include the auto-generated part of this file. We split this because it means
16382 // we can easily edit the non-auto generated parts right here in this file 16421 // we can easily edit the non-auto generated parts right here in this file
16383 // instead of having to edit some template or the code generator. 16422 // instead of having to edit some template or the code generator.
16384 #include "base/macros.h" 16423 #include "base/macros.h"
16385 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 16424 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
16386 16425
16387 } // namespace gles2 16426 } // namespace gles2
16388 } // namespace gpu 16427 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698