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

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

Issue 2076213002: Decompress ETC texture data when there is no native support. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Decompress ETC texture data when there is no native support. Created 4 years, 5 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 #include "gpu/command_buffer/service/program_manager.h" 57 #include "gpu/command_buffer/service/program_manager.h"
58 #include "gpu/command_buffer/service/query_manager.h" 58 #include "gpu/command_buffer/service/query_manager.h"
59 #include "gpu/command_buffer/service/renderbuffer_manager.h" 59 #include "gpu/command_buffer/service/renderbuffer_manager.h"
60 #include "gpu/command_buffer/service/sampler_manager.h" 60 #include "gpu/command_buffer/service/sampler_manager.h"
61 #include "gpu/command_buffer/service/shader_manager.h" 61 #include "gpu/command_buffer/service/shader_manager.h"
62 #include "gpu/command_buffer/service/shader_translator.h" 62 #include "gpu/command_buffer/service/shader_translator.h"
63 #include "gpu/command_buffer/service/texture_manager.h" 63 #include "gpu/command_buffer/service/texture_manager.h"
64 #include "gpu/command_buffer/service/transform_feedback_manager.h" 64 #include "gpu/command_buffer/service/transform_feedback_manager.h"
65 #include "gpu/command_buffer/service/vertex_array_manager.h" 65 #include "gpu/command_buffer/service/vertex_array_manager.h"
66 #include "gpu/command_buffer/service/vertex_attrib_manager.h" 66 #include "gpu/command_buffer/service/vertex_attrib_manager.h"
67 #include "third_party/angle/src/image_util/loadimage.h"
67 #include "third_party/smhasher/src/City.h" 68 #include "third_party/smhasher/src/City.h"
68 #include "ui/gfx/buffer_types.h" 69 #include "ui/gfx/buffer_types.h"
69 #include "ui/gfx/geometry/point.h" 70 #include "ui/gfx/geometry/point.h"
70 #include "ui/gfx/geometry/rect.h" 71 #include "ui/gfx/geometry/rect.h"
71 #include "ui/gfx/geometry/rect_conversions.h" 72 #include "ui/gfx/geometry/rect_conversions.h"
72 #include "ui/gfx/geometry/size.h" 73 #include "ui/gfx/geometry/size.h"
73 #include "ui/gfx/gpu_memory_buffer.h" 74 #include "ui/gfx/gpu_memory_buffer.h"
74 #include "ui/gfx/overlay_transform.h" 75 #include "ui/gfx/overlay_transform.h"
75 #include "ui/gfx/transform.h" 76 #include "ui/gfx/transform.h"
76 #include "ui/gl/ca_renderer_layer_params.h" 77 #include "ui/gl/ca_renderer_layer_params.h"
(...skipping 11367 matching lines...) Expand 10 before | Expand all | Expand 10 after
11444 {8, 5}, 11445 {8, 5},
11445 {8, 6}, 11446 {8, 6},
11446 {8, 8}, 11447 {8, 8},
11447 {10, 5}, 11448 {10, 5},
11448 {10, 6}, 11449 {10, 6},
11449 {10, 8}, 11450 {10, 8},
11450 {10, 10}, 11451 {10, 10},
11451 {12, 10}, 11452 {12, 10},
11452 {12, 12}}; 11453 {12, 12}};
11453 11454
11455 bool CheckETCFormatSupport(const FeatureInfo& featureInfo) {
11456 const gl::GLVersionInfo& versionInfo = featureInfo.gl_version_info();
11457 return versionInfo.IsAtLeastGL(4, 3) || versionInfo.IsAtLeastGLES(3, 0) ||
11458 featureInfo.feature_flags().arb_es3_compatability;
11459 }
11460
11461 using CompressedFormatSupportCheck = bool (*)(const FeatureInfo&);
11462 using CompressedFormatDecompressionFunction = void (*)(size_t width,
11463 size_t height,
11464 size_t depth,
11465 const uint8_t* input,
11466 size_t inputRowPitch,
11467 size_t inputDepthPitch,
11468 uint8_t* output,
11469 size_t outputRowPitch,
11470 size_t outputDepthPitch);
11471
11472 struct CompressedFormatInfo {
11473 GLenum format;
11474 uint32_t blockSize;
piman 2016/07/06 21:20:59 nit: use chromium style here and below (e.g. block
Geoff Lang 2016/07/08 18:49:16 Done.
11475 uint32_t bytesPerBlock;
11476 CompressedFormatSupportCheck supportCheck;
11477 CompressedFormatDecompressionFunction decompressionFunction;
11478 GLenum decompressedInternalFormat;
11479 GLenum decompressedFormat;
11480 GLenum decompressedType;
11481 };
11482
11483 const CompressedFormatInfo kCompressedFormatInfoArray[]{
Zhenyao Mo 2016/07/06 19:45:39 nit: a space between [] and {
Geoff Lang 2016/07/08 18:49:16 Done.
11484 {
11485 GL_COMPRESSED_R11_EAC, 4, 8, CheckETCFormatSupport,
11486 angle::LoadEACR11ToR8, GL_R8, GL_RED, GL_UNSIGNED_BYTE,
11487 },
11488 {
11489 GL_COMPRESSED_SIGNED_R11_EAC, 4, 8, CheckETCFormatSupport,
11490 angle::LoadEACR11SToR8, GL_R8_SNORM, GL_RED, GL_BYTE,
11491 },
11492 {
11493 GL_COMPRESSED_RG11_EAC, 4, 16, CheckETCFormatSupport,
11494 angle::LoadEACRG11ToRG8, GL_RG8, GL_RG, GL_UNSIGNED_BYTE,
11495 },
11496 {
11497 GL_COMPRESSED_SIGNED_RG11_EAC, 4, 16, CheckETCFormatSupport,
11498 angle::LoadEACRG11SToRG8, GL_RG8_SNORM, GL_RG, GL_BYTE,
11499 },
11500 {
11501 GL_COMPRESSED_RGB8_ETC2, 4, 8, CheckETCFormatSupport,
11502 angle::LoadETC2RGB8ToRGBA8, GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE,
11503 },
11504 {
11505 GL_COMPRESSED_SRGB8_ETC2, 4, 8, CheckETCFormatSupport,
11506 angle::LoadETC2SRGB8ToRGBA8, GL_SRGB8_ALPHA8, GL_SRGB_ALPHA,
11507 GL_UNSIGNED_BYTE,
11508 },
11509 {
11510 GL_COMPRESSED_RGBA8_ETC2_EAC, 4, 16, CheckETCFormatSupport,
11511 angle::LoadETC2RGBA8ToRGBA8, GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE,
11512 },
11513 {
11514 GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2, 4, 8,
11515 CheckETCFormatSupport, angle::LoadETC2RGB8A1ToRGBA8, GL_RGBA8, GL_RGBA,
11516 GL_UNSIGNED_BYTE,
11517 },
11518 {
11519 GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC, 4, 16, CheckETCFormatSupport,
11520 angle::LoadETC2SRGBA8ToSRGBA8, GL_SRGB8_ALPHA8, GL_SRGB_ALPHA,
11521 GL_UNSIGNED_BYTE,
11522 },
11523 {
11524 GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2, 4, 8,
11525 CheckETCFormatSupport, angle::LoadETC2SRGB8A1ToRGBA8, GL_SRGB8_ALPHA8,
11526 GL_SRGB_ALPHA, GL_UNSIGNED_BYTE,
11527 },
11528 };
11529
11530 const CompressedFormatInfo* GetCompressedFormatInfo(GLenum format) {
11531 for (size_t i = 0; i < arraysize(kCompressedFormatInfoArray); i++) {
11532 if (kCompressedFormatInfoArray[i].format == format) {
11533 return &kCompressedFormatInfoArray[i];
11534 }
11535 }
11536 return nullptr;
11537 }
11538
11539 uint32_t GetCompressedFormatRowPitch(const CompressedFormatInfo& info,
11540 uint32_t width) {
11541 uint32_t num_blocks_wide = (width + info.blockSize - 1) / info.blockSize;
11542 return num_blocks_wide * info.bytesPerBlock;
11543 }
11544
11545 uint32_t GetCompressedFormatDepthPitch(const CompressedFormatInfo& info,
11546 uint32_t width,
11547 uint32_t height) {
11548 uint32_t num_blocks_high = ((height + info.blockSize - 1) / info.blockSize);
11549 return num_blocks_high * GetCompressedFormatRowPitch(info, width);
11550 }
11551
11552 std::unique_ptr<uint8_t[]> DecompressTextureData(
11553 const CompressedFormatInfo& info,
11554 uint32_t width,
11555 uint32_t height,
11556 uint32_t depth,
11557 const void* data) {
11558 uint32_t output_pixel_size = GLES2Util::ComputeImageGroupSize(
11559 info.decompressedFormat, info.decompressedType);
11560 std::unique_ptr<uint8_t[]> decompressed_data(
11561 new uint8_t[output_pixel_size * width * height]);
11562
11563 info.decompressionFunction(width, height, 1,
11564 reinterpret_cast<const uint8_t*>(data),
11565 GetCompressedFormatRowPitch(info, width),
11566 GetCompressedFormatDepthPitch(info, width, height),
11567 decompressed_data.get(), output_pixel_size * width,
11568 output_pixel_size * width * height);
11569
11570 return decompressed_data;
11571 }
11572
11573 void PushDecompressedTextureUnpackState() {
11574 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
11575 glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
11576 glPixelStorei(GL_UNPACK_SKIP_ROWS, 0);
11577 glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
11578 glPixelStorei(GL_UNPACK_IMAGE_HEIGHT, 0);
11579 glPixelStorei(GL_UNPACK_SKIP_IMAGES, 0);
Zhenyao Mo 2016/07/06 19:45:39 No need for all the SKIP params as they are always
Geoff Lang 2016/07/08 18:49:16 Ah, thanks for pointing that out. I kept the Push
11580 glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
11581 }
11582
11583 void PopDecompressedTextureUnpackState(const ContextState& state) {
11584 glPixelStorei(GL_UNPACK_ALIGNMENT, state.unpack_alignment);
11585 glPixelStorei(GL_UNPACK_ROW_LENGTH, state.unpack_row_length);
11586 glPixelStorei(GL_UNPACK_SKIP_ROWS, state.unpack_skip_rows);
11587 glPixelStorei(GL_UNPACK_SKIP_PIXELS, state.unpack_skip_images);
11588 glPixelStorei(GL_UNPACK_IMAGE_HEIGHT, state.unpack_image_height);
11589 glPixelStorei(GL_UNPACK_SKIP_IMAGES, state.unpack_skip_images);
11590 if (state.bound_pixel_unpack_buffer) {
11591 glBindBuffer(GL_PIXEL_UNPACK_BUFFER,
11592 state.bound_array_buffer->service_id());
11593 }
11594 }
11595
11454 bool IsValidDXTSize(GLint level, GLsizei size) { 11596 bool IsValidDXTSize(GLint level, GLsizei size) {
11455 // TODO(zmo): Linux NVIDIA driver does allow size of 1 and 2 on level 0. 11597 // TODO(zmo): Linux NVIDIA driver does allow size of 1 and 2 on level 0.
11456 // However, the WebGL conformance test and blink side code forbid it. 11598 // However, the WebGL conformance test and blink side code forbid it.
11457 // For now, let's be on the cautious side. If all drivers behaves the same 11599 // For now, let's be on the cautious side. If all drivers behaves the same
11458 // as Linux NVIDIA, then we can remove this limitation. 11600 // as Linux NVIDIA, then we can remove this limitation.
11459 return (level && size == 1) || 11601 return (level && size == 1) ||
11460 (level && size == 2) || 11602 (level && size == 2) ||
11461 !(size % kS3TCBlockWidth); 11603 !(size % kS3TCBlockWidth);
11462 } 11604 }
11463 11605
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after
11872 if (texture->IsAttachedToFramebuffer()) { 12014 if (texture->IsAttachedToFramebuffer()) {
11873 framebuffer_state_.clear_state_dirty = true; 12015 framebuffer_state_.clear_state_dirty = true;
11874 } 12016 }
11875 12017
11876 std::unique_ptr<int8_t[]> zero; 12018 std::unique_ptr<int8_t[]> zero;
11877 if (!data) { 12019 if (!data) {
11878 zero.reset(new int8_t[image_size]); 12020 zero.reset(new int8_t[image_size]);
11879 memset(zero.get(), 0, image_size); 12021 memset(zero.get(), 0, image_size);
11880 data = zero.get(); 12022 data = zero.get();
11881 } 12023 }
12024
11882 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCompressedTexImage2D"); 12025 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCompressedTexImage2D");
11883 glCompressedTexImage2D( 12026
11884 target, level, internal_format, width, height, border, image_size, data); 12027 const CompressedFormatInfo* format_info =
12028 GetCompressedFormatInfo(internal_format);
12029 if (format_info != nullptr && !format_info->supportCheck(*feature_info_)) {
12030 std::unique_ptr<uint8_t[]> decompressed_data =
12031 DecompressTextureData(*format_info, width, height, 1, data);
piman 2016/07/06 21:20:59 What happens if there's a PIXEL_UNPACK_BUFFER boun
Geoff Lang 2016/07/08 18:49:16 Yea, I noticed that too. PBOs aren't handled at a
12032 PushDecompressedTextureUnpackState();
12033 glTexImage2D(target, level, format_info->decompressedInternalFormat, width,
12034 height, border, format_info->decompressedFormat,
12035 format_info->decompressedType, decompressed_data.get());
12036 PopDecompressedTextureUnpackState(state_);
12037 } else {
12038 glCompressedTexImage2D(target, level, internal_format, width, height,
12039 border, image_size, data);
12040 }
11885 GLenum error = LOCAL_PEEK_GL_ERROR("glCompressedTexImage2D"); 12041 GLenum error = LOCAL_PEEK_GL_ERROR("glCompressedTexImage2D");
11886 if (error == GL_NO_ERROR) { 12042 if (error == GL_NO_ERROR) {
11887 texture_manager()->SetLevelInfo(texture_ref, target, level, internal_format, 12043 texture_manager()->SetLevelInfo(texture_ref, target, level, internal_format,
11888 width, height, 1, border, 0, 0, 12044 width, height, 1, border, 0, 0,
11889 gfx::Rect(width, height)); 12045 gfx::Rect(width, height));
11890 } 12046 }
11891 12047
11892 // This may be a slow command. Exit command processing to allow for 12048 // This may be a slow command. Exit command processing to allow for
11893 // context preemption and GPU watchdog checks. 12049 // context preemption and GPU watchdog checks.
11894 ExitCommandProcessingEarly(); 12050 ExitCommandProcessingEarly();
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
11945 framebuffer_state_.clear_state_dirty = true; 12101 framebuffer_state_.clear_state_dirty = true;
11946 } 12102 }
11947 12103
11948 std::unique_ptr<int8_t[]> zero; 12104 std::unique_ptr<int8_t[]> zero;
11949 if (!data) { 12105 if (!data) {
11950 zero.reset(new int8_t[image_size]); 12106 zero.reset(new int8_t[image_size]);
11951 memset(zero.get(), 0, image_size); 12107 memset(zero.get(), 0, image_size);
11952 data = zero.get(); 12108 data = zero.get();
11953 } 12109 }
11954 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCompressedTexImage3D"); 12110 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCompressedTexImage3D");
11955 glCompressedTexImage3D(target, level, internal_format, width, height, depth, 12111 const CompressedFormatInfo* format_info =
11956 border, image_size, data); 12112 GetCompressedFormatInfo(internal_format);
12113 if (format_info != nullptr && !format_info->supportCheck(*feature_info_)) {
12114 std::unique_ptr<uint8_t[]> decompressed_data =
12115 DecompressTextureData(*format_info, width, height, depth, data);
12116 PushDecompressedTextureUnpackState();
12117 glTexImage3D(target, level, format_info->decompressedInternalFormat, width,
12118 height, depth, border, format_info->decompressedFormat,
12119 format_info->decompressedType, decompressed_data.get());
12120 PopDecompressedTextureUnpackState(state_);
12121 } else {
12122 glCompressedTexImage3D(target, level, internal_format, width, height, depth,
12123 border, image_size, data);
12124 }
11957 GLenum error = LOCAL_PEEK_GL_ERROR("glCompressedTexImage3D"); 12125 GLenum error = LOCAL_PEEK_GL_ERROR("glCompressedTexImage3D");
11958 if (error == GL_NO_ERROR) { 12126 if (error == GL_NO_ERROR) {
11959 texture_manager()->SetLevelInfo(texture_ref, target, level, internal_format, 12127 texture_manager()->SetLevelInfo(texture_ref, target, level, internal_format,
11960 width, height, depth, border, 0, 0, 12128 width, height, depth, border, 0, 0,
11961 gfx::Rect(width, height)); 12129 gfx::Rect(width, height));
11962 } 12130 }
11963 12131
11964 // This may be a slow command. Exit command processing to allow for 12132 // This may be a slow command. Exit command processing to allow for
11965 // context preemption and GPU watchdog checks. 12133 // context preemption and GPU watchdog checks.
11966 ExitCommandProcessingEarly(); 12134 ExitCommandProcessingEarly();
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
12011 target, level, xoffset, yoffset, 12179 target, level, xoffset, yoffset,
12012 zoffset, width, height, depth, 12180 zoffset, width, height, depth,
12013 format, texture)) { 12181 format, texture)) {
12014 return; 12182 return;
12015 } 12183 }
12016 12184
12017 // Note: There is no need to deal with texture cleared tracking here 12185 // Note: There is no need to deal with texture cleared tracking here
12018 // because the validation above means you can only get here if the level 12186 // because the validation above means you can only get here if the level
12019 // is already a matching compressed format and in that case 12187 // is already a matching compressed format and in that case
12020 // CompressedTexImage3D already cleared the texture. 12188 // CompressedTexImage3D already cleared the texture.
12021 glCompressedTexSubImage3D( 12189
12022 target, level, xoffset, yoffset, zoffset, width, height, depth, format, 12190 const CompressedFormatInfo* format_info =
12023 image_size, data); 12191 GetCompressedFormatInfo(internal_format);
12192 if (format_info != nullptr && !format_info->supportCheck(*feature_info_)) {
12193 std::unique_ptr<uint8_t[]> decompressed_data =
12194 DecompressTextureData(*format_info, width, height, depth, data);
12195 PushDecompressedTextureUnpackState();
12196 glTexSubImage3D(target, level, xoffset, yoffset, zoffset, width, height,
12197 depth, format_info->decompressedFormat,
12198 format_info->decompressedType, decompressed_data.get());
12199 PopDecompressedTextureUnpackState(state_);
12200 } else {
12201 glCompressedTexSubImage3D(target, level, xoffset, yoffset, zoffset, width,
12202 height, depth, format, image_size, data);
12203 }
12024 12204
12025 // This may be a slow command. Exit command processing to allow for 12205 // This may be a slow command. Exit command processing to allow for
12026 // context preemption and GPU watchdog checks. 12206 // context preemption and GPU watchdog checks.
12027 ExitCommandProcessingEarly(); 12207 ExitCommandProcessingEarly();
12028 } 12208 }
12029 12209
12030 error::Error GLES2DecoderImpl::HandleTexImage2D(uint32_t immediate_data_size, 12210 error::Error GLES2DecoderImpl::HandleTexImage2D(uint32_t immediate_data_size,
12031 const void* cmd_data) { 12211 const void* cmd_data) {
12032 const gles2::cmds::TexImage2D& c = 12212 const gles2::cmds::TexImage2D& c =
12033 *static_cast<const gles2::cmds::TexImage2D*>(cmd_data); 12213 *static_cast<const gles2::cmds::TexImage2D*>(cmd_data);
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
12262 // We can skip the clear if we're uploading the entire level. 12442 // We can skip the clear if we're uploading the entire level.
12263 if (xoffset == 0 && yoffset == 0 && 12443 if (xoffset == 0 && yoffset == 0 &&
12264 width == level_width && height == level_height) { 12444 width == level_width && height == level_height) {
12265 texture_manager()->SetLevelCleared(texture_ref, target, level, true); 12445 texture_manager()->SetLevelCleared(texture_ref, target, level, true);
12266 } else { 12446 } else {
12267 texture_manager()->ClearTextureLevel(this, texture_ref, target, level); 12447 texture_manager()->ClearTextureLevel(this, texture_ref, target, level);
12268 } 12448 }
12269 DCHECK(texture->IsLevelCleared(target, level)); 12449 DCHECK(texture->IsLevelCleared(target, level));
12270 } 12450 }
12271 12451
12272 glCompressedTexSubImage2D( 12452 const CompressedFormatInfo* format_info =
12273 target, level, xoffset, yoffset, width, height, format, image_size, data); 12453 GetCompressedFormatInfo(internal_format);
12454 if (format_info != nullptr && !format_info->supportCheck(*feature_info_)) {
12455 std::unique_ptr<uint8_t[]> decompressed_data =
12456 DecompressTextureData(*format_info, width, height, 1, data);
12457 PushDecompressedTextureUnpackState();
12458 glTexSubImage2D(target, level, xoffset, yoffset, width, height,
12459 format_info->decompressedFormat,
12460 format_info->decompressedType, decompressed_data.get());
12461 PopDecompressedTextureUnpackState(state_);
12462 } else {
12463 glCompressedTexSubImage2D(target, level, xoffset, yoffset, width, height,
12464 format, image_size, data);
12465 }
12274 12466
12275 // This may be a slow command. Exit command processing to allow for 12467 // This may be a slow command. Exit command processing to allow for
12276 // context preemption and GPU watchdog checks. 12468 // context preemption and GPU watchdog checks.
12277 ExitCommandProcessingEarly(); 12469 ExitCommandProcessingEarly();
12278 } 12470 }
12279 12471
12280 static void Clip( 12472 static void Clip(
12281 GLint start, GLint range, GLint sourceRange, 12473 GLint start, GLint range, GLint sourceRange,
12282 GLint* out_start, GLint* out_range) { 12474 GLint* out_start, GLint* out_range) {
12283 DCHECK(out_start); 12475 DCHECK(out_start);
(...skipping 2772 matching lines...) Expand 10 before | Expand all | Expand 10 after
15056 if (target == GL_TEXTURE_3D) 15248 if (target == GL_TEXTURE_3D)
15057 level_depth = std::max(1, level_depth >> 1); 15249 level_depth = std::max(1, level_depth >> 1);
15058 } 15250 }
15059 if (!estimated_size.IsValid() || 15251 if (!estimated_size.IsValid() ||
15060 !EnsureGPUMemoryAvailable(estimated_size.ValueOrDefault(0))) { 15252 !EnsureGPUMemoryAvailable(estimated_size.ValueOrDefault(0))) {
15061 LOCAL_SET_GL_ERROR(GL_OUT_OF_MEMORY, function_name, "out of memory"); 15253 LOCAL_SET_GL_ERROR(GL_OUT_OF_MEMORY, function_name, "out of memory");
15062 return; 15254 return;
15063 } 15255 }
15064 } 15256 }
15065 15257
15258 GLenum compatability_iternal_format = internal_format;
piman 2016/07/06 21:20:59 nit: 2 typos: compatability_iternal_format -> comp
Geoff Lang 2016/07/08 18:49:16 Done.
15259 const CompressedFormatInfo* format_info =
15260 GetCompressedFormatInfo(internal_format);
15261 if (format_info != nullptr && !format_info->supportCheck(*feature_info_)) {
15262 compatability_iternal_format = format_info->decompressedInternalFormat;
15263 }
15264
15066 // TODO(zmo): We might need to emulate TexStorage using TexImage or 15265 // TODO(zmo): We might need to emulate TexStorage using TexImage or
15067 // CompressedTexImage on Mac OSX where we expose ES3 APIs when the underlying 15266 // CompressedTexImage on Mac OSX where we expose ES3 APIs when the underlying
15068 // driver is lower than 4.2 and ARB_texture_storage extension doesn't exist. 15267 // driver is lower than 4.2 and ARB_texture_storage extension doesn't exist.
15069 if (dimension == ContextState::k2D) { 15268 if (dimension == ContextState::k2D) {
15070 glTexStorage2DEXT(target, levels, internal_format, width, height); 15269 glTexStorage2DEXT(target, levels, compatability_iternal_format, width,
15270 height);
15071 } else { 15271 } else {
15072 glTexStorage3D(target, levels, internal_format, width, height, depth); 15272 glTexStorage3D(target, levels, compatability_iternal_format, width, height,
15273 depth);
15073 } 15274 }
15074 15275
15075 { 15276 {
15076 GLsizei level_width = width; 15277 GLsizei level_width = width;
15077 GLsizei level_height = height; 15278 GLsizei level_height = height;
15078 GLsizei level_depth = depth; 15279 GLsizei level_depth = depth;
15079 GLenum adjusted_format = 15280 GLenum adjusted_format =
15080 feature_info_->IsES3Enabled() ? internal_format : format; 15281 feature_info_->IsES3Enabled() ? internal_format : format;
15081 for (int ii = 0; ii < levels; ++ii) { 15282 for (int ii = 0; ii < levels; ++ii) {
15082 if (target == GL_TEXTURE_CUBE_MAP) { 15283 if (target == GL_TEXTURE_CUBE_MAP) {
(...skipping 1988 matching lines...) Expand 10 before | Expand all | Expand 10 after
17071 } 17272 }
17072 17273
17073 // Include the auto-generated part of this file. We split this because it means 17274 // Include the auto-generated part of this file. We split this because it means
17074 // we can easily edit the non-auto generated parts right here in this file 17275 // we can easily edit the non-auto generated parts right here in this file
17075 // instead of having to edit some template or the code generator. 17276 // instead of having to edit some template or the code generator.
17076 #include "base/macros.h" 17277 #include "base/macros.h"
17077 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 17278 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
17078 17279
17079 } // namespace gles2 17280 } // namespace gles2
17080 } // namespace gpu 17281 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698