Chromium Code Reviews| Index: gpu/command_buffer/service/gles2_cmd_decoder.cc |
| diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc |
| index fba0b90ed602633fe7e2a6d5b1fb67304fa51fa9..a49bed834e7c18e5e215e671db73cb9b9929f817 100644 |
| --- a/gpu/command_buffer/service/gles2_cmd_decoder.cc |
| +++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc |
| @@ -3121,6 +3121,8 @@ Capabilities GLES2DecoderImpl::GetCapabilities() { |
| caps.egl_image_external = |
| feature_info_->feature_flags().oes_egl_image_external; |
| + caps.texture_format_astc = |
| + feature_info_->feature_flags().ext_texture_format_astc; |
| caps.texture_format_atc = |
| feature_info_->feature_flags().ext_texture_format_atc; |
| caps.texture_format_bgra8888 = |
| @@ -6869,7 +6871,6 @@ bool GLES2DecoderImpl::PrepareTexturesForRender() { |
| !texture_manager()->HaveImages()) { |
| return true; |
| } |
| - |
| bool textures_set = false; |
| const Program::SamplerIndices& sampler_indices = |
| state_.current_program->sampler_indices(); |
| @@ -9086,6 +9087,30 @@ const int kS3TCDXT1BlockSize = 8; |
| const int kS3TCDXT3AndDXT5BlockSize = 16; |
| const int kEACAndETC2BlockSize = 4; |
| +typedef struct { |
| + int blockWidth; |
| + int blockHeight; |
| +} ASTCBlockSize; |
| + |
| +static const ASTCBlockSize kASTCBlockSize[] = |
|
piman
2015/08/17 23:00:20
nit: you're in an anonymous namespace, so you don'
|
| + { |
| + 4, 4, /* GL_COMPRESSED_RGBA_ASTC_4x4_KHR */ |
| + 5, 4, /* and GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR */ |
| + 5, 5, |
| + 6, 5, |
| + 6, 6, |
| + 8, 5, |
| + 8, 6, |
| + 8, 8, |
| + 10, 5, |
| + 10, 6, |
| + 10, 8, |
| + 10, 10, |
| + 12, 10, |
| + 12, 12, |
| + }; |
| + |
| + |
| bool IsValidDXTSize(GLint level, GLsizei size) { |
| return (size == 1) || |
| (size == 2) || !(size % kS3TCBlockWidth); |
| @@ -9113,6 +9138,49 @@ bool GLES2DecoderImpl::GetCompressedTexSizeInBytes( |
| (height + kS3TCBlockHeight - 1) / kS3TCBlockHeight; |
| bytes_required *= kS3TCDXT1BlockSize; |
| break; |
| + case GL_COMPRESSED_RGBA_ASTC_4x4_KHR: |
| + case GL_COMPRESSED_RGBA_ASTC_5x4_KHR: |
| + case GL_COMPRESSED_RGBA_ASTC_5x5_KHR: |
| + case GL_COMPRESSED_RGBA_ASTC_6x5_KHR: |
| + case GL_COMPRESSED_RGBA_ASTC_6x6_KHR: |
| + case GL_COMPRESSED_RGBA_ASTC_8x5_KHR: |
| + case GL_COMPRESSED_RGBA_ASTC_8x6_KHR: |
| + case GL_COMPRESSED_RGBA_ASTC_8x8_KHR: |
| + case GL_COMPRESSED_RGBA_ASTC_10x5_KHR: |
| + case GL_COMPRESSED_RGBA_ASTC_10x6_KHR: |
| + case GL_COMPRESSED_RGBA_ASTC_10x8_KHR: |
| + case GL_COMPRESSED_RGBA_ASTC_10x10_KHR: |
| + case GL_COMPRESSED_RGBA_ASTC_12x10_KHR: |
| + case GL_COMPRESSED_RGBA_ASTC_12x12_KHR: |
| + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR: |
| + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR: |
| + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR: |
| + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR: |
| + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR: |
| + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR: |
| + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR: |
| + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR: |
| + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR: |
| + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR: |
| + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR: |
| + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR: |
| + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR: |
| + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR: { |
| + const int index = (format < GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR) ? |
| + (int)format - GL_COMPRESSED_RGBA_ASTC_4x4_KHR : |
|
piman
2015/08/17 23:00:20
nit: no c-style cast.
|
| + (int)format - GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR; |
|
piman
2015/08/17 23:00:21
nit: no c-style cast.
|
| + |
| + const int kBlockWidth = kASTCBlockSize[index].blockWidth; |
| + const int kBlockHeight = kASTCBlockSize[index].blockHeight; |
| + |
| + int kBlockX = |
| + (std::max(width, kBlockWidth) + kBlockWidth - 1) / kBlockWidth; |
| + int kBlockY = |
| + (std::max(height, kBlockHeight) + kBlockHeight - 1) / kBlockHeight; |
| + |
| + bytes_required = (kBlockX * kBlockY) << 4; |
|
piman
2015/08/17 23:00:20
nit: rather than << 4, can you write * kASTCBlockB
|
| + break; |
| + } |
| case GL_ATC_RGBA_EXPLICIT_ALPHA_AMD: |
| case GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD: |
| case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: |
| @@ -9213,6 +9281,34 @@ bool GLES2DecoderImpl::ValidateCompressedTexDimensions( |
| return false; |
| } |
| return true; |
| + case GL_COMPRESSED_RGBA_ASTC_4x4_KHR: |
| + case GL_COMPRESSED_RGBA_ASTC_5x4_KHR: |
| + case GL_COMPRESSED_RGBA_ASTC_5x5_KHR: |
| + case GL_COMPRESSED_RGBA_ASTC_6x5_KHR: |
| + case GL_COMPRESSED_RGBA_ASTC_6x6_KHR: |
| + case GL_COMPRESSED_RGBA_ASTC_8x5_KHR: |
| + case GL_COMPRESSED_RGBA_ASTC_8x6_KHR: |
| + case GL_COMPRESSED_RGBA_ASTC_8x8_KHR: |
| + case GL_COMPRESSED_RGBA_ASTC_10x5_KHR: |
| + case GL_COMPRESSED_RGBA_ASTC_10x6_KHR: |
| + case GL_COMPRESSED_RGBA_ASTC_10x8_KHR: |
| + case GL_COMPRESSED_RGBA_ASTC_10x10_KHR: |
| + case GL_COMPRESSED_RGBA_ASTC_12x10_KHR: |
| + case GL_COMPRESSED_RGBA_ASTC_12x12_KHR: |
| + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR: |
| + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR: |
| + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR: |
| + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR: |
| + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR: |
| + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR: |
| + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR: |
| + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR: |
| + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR: |
| + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR: |
| + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR: |
| + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR: |
| + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR: |
| + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR: |
| case GL_ATC_RGB_AMD: |
| case GL_ATC_RGBA_EXPLICIT_ALPHA_AMD: |
| case GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD: |
| @@ -9418,7 +9514,6 @@ error::Error GLES2DecoderImpl::DoCompressedTexImage2D( |
| "glCompressedTexImage2D", "texture is immutable"); |
| return error::kNoError; |
| } |
| - |
| if (!ValidateCompressedTexDimensions("glCompressedTexImage2D", target, level, |
| width, height, 1, internal_format) || |
| !ValidateCompressedTexFuncData("glCompressedTexImage2D", width, height, |