OLD | NEW |
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 <stdio.h> | 7 #include <stdio.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <list> | 10 #include <list> |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 return gfx::OVERLAY_TRANSFORM_ROTATE_90; | 160 return gfx::OVERLAY_TRANSFORM_ROTATE_90; |
161 case GL_OVERLAY_TRANSFORM_ROTATE_180_CHROMIUM: | 161 case GL_OVERLAY_TRANSFORM_ROTATE_180_CHROMIUM: |
162 return gfx::OVERLAY_TRANSFORM_ROTATE_180; | 162 return gfx::OVERLAY_TRANSFORM_ROTATE_180; |
163 case GL_OVERLAY_TRANSFORM_ROTATE_270_CHROMIUM: | 163 case GL_OVERLAY_TRANSFORM_ROTATE_270_CHROMIUM: |
164 return gfx::OVERLAY_TRANSFORM_ROTATE_270; | 164 return gfx::OVERLAY_TRANSFORM_ROTATE_270; |
165 default: | 165 default: |
166 return gfx::OVERLAY_TRANSFORM_INVALID; | 166 return gfx::OVERLAY_TRANSFORM_INVALID; |
167 } | 167 } |
168 } | 168 } |
169 | 169 |
| 170 static size_t BitsPerPixel(GLenum format) { |
| 171 switch (format) { |
| 172 case GL_RGB: |
| 173 return 24; |
| 174 case GL_RGBA: |
| 175 return 32; |
| 176 case GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD: |
| 177 case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: |
| 178 return 8; |
| 179 case GL_ATC_RGB_AMD: |
| 180 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: |
| 181 case GL_ETC1_RGB8_OES: |
| 182 return 4; |
| 183 } |
| 184 |
| 185 NOTREACHED(); |
| 186 return 0; |
| 187 } |
| 188 |
170 } // namespace | 189 } // namespace |
171 | 190 |
172 class GLES2DecoderImpl; | 191 class GLES2DecoderImpl; |
173 | 192 |
174 // Local versions of the SET_GL_ERROR macros | 193 // Local versions of the SET_GL_ERROR macros |
175 #define LOCAL_SET_GL_ERROR(error, function_name, msg) \ | 194 #define LOCAL_SET_GL_ERROR(error, function_name, msg) \ |
176 ERRORSTATE_SET_GL_ERROR(state_.GetErrorState(), error, function_name, msg) | 195 ERRORSTATE_SET_GL_ERROR(state_.GetErrorState(), error, function_name, msg) |
177 #define LOCAL_SET_GL_ERROR_INVALID_ENUM(function_name, value, label) \ | 196 #define LOCAL_SET_GL_ERROR_INVALID_ENUM(function_name, value, label) \ |
178 ERRORSTATE_SET_GL_ERROR_INVALID_ENUM(state_.GetErrorState(), \ | 197 ERRORSTATE_SET_GL_ERROR_INVALID_ENUM(state_.GetErrorState(), \ |
179 function_name, value, label) | 198 function_name, value, label) |
(...skipping 757 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
937 GLuint plane); | 956 GLuint plane); |
938 | 957 |
939 void DoCopyTextureCHROMIUM( | 958 void DoCopyTextureCHROMIUM( |
940 GLenum target, | 959 GLenum target, |
941 GLuint source_id, | 960 GLuint source_id, |
942 GLuint target_id, | 961 GLuint target_id, |
943 GLint level, | 962 GLint level, |
944 GLenum internal_format, | 963 GLenum internal_format, |
945 GLenum dest_type); | 964 GLenum dest_type); |
946 | 965 |
| 966 void DoCopyCompressedTextureCHROMIUM(GLenum target, |
| 967 GLuint source_id, |
| 968 GLuint target_id, |
| 969 GLenum internal_format, |
| 970 GLenum dest_type); |
| 971 |
947 // Wrapper for TexStorage2DEXT. | 972 // Wrapper for TexStorage2DEXT. |
948 void DoTexStorage2DEXT( | 973 void DoTexStorage2DEXT( |
949 GLenum target, | 974 GLenum target, |
950 GLint levels, | 975 GLint levels, |
951 GLenum internal_format, | 976 GLenum internal_format, |
952 GLsizei width, | 977 GLsizei width, |
953 GLsizei height); | 978 GLsizei height); |
954 | 979 |
955 void DoProduceTextureCHROMIUM(GLenum target, const GLbyte* key); | 980 void DoProduceTextureCHROMIUM(GLenum target, const GLbyte* key); |
956 void DoProduceTextureDirectCHROMIUM(GLuint texture, GLenum target, | 981 void DoProduceTextureDirectCHROMIUM(GLuint texture, GLenum target, |
(...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1645 GLint level, GLsizei width, GLsizei height, GLenum format); | 1670 GLint level, GLsizei width, GLsizei height, GLenum format); |
1646 bool ValidateCompressedTexFuncData( | 1671 bool ValidateCompressedTexFuncData( |
1647 const char* function_name, | 1672 const char* function_name, |
1648 GLsizei width, GLsizei height, GLenum format, size_t size); | 1673 GLsizei width, GLsizei height, GLenum format, size_t size); |
1649 bool ValidateCompressedTexSubDimensions( | 1674 bool ValidateCompressedTexSubDimensions( |
1650 const char* function_name, | 1675 const char* function_name, |
1651 GLenum target, GLint level, GLint xoffset, GLint yoffset, | 1676 GLenum target, GLint level, GLint xoffset, GLint yoffset, |
1652 GLsizei width, GLsizei height, GLenum format, | 1677 GLsizei width, GLsizei height, GLenum format, |
1653 Texture* texture); | 1678 Texture* texture); |
1654 | 1679 |
| 1680 bool ValidateCompressedTexSubImage2D(error::Error* error, |
| 1681 const char* function_name, |
| 1682 GLenum target, |
| 1683 GLint level, |
| 1684 GLint xoffset, |
| 1685 GLint yoffset, |
| 1686 GLsizei width, |
| 1687 GLsizei height, |
| 1688 GLenum format, |
| 1689 GLsizei image_size, |
| 1690 const void* data); |
| 1691 |
1655 void RenderWarning(const char* filename, int line, const std::string& msg); | 1692 void RenderWarning(const char* filename, int line, const std::string& msg); |
1656 void PerformanceWarning( | 1693 void PerformanceWarning( |
1657 const char* filename, int line, const std::string& msg); | 1694 const char* filename, int line, const std::string& msg); |
1658 | 1695 |
1659 const FeatureInfo::FeatureFlags& features() const { | 1696 const FeatureInfo::FeatureFlags& features() const { |
1660 return feature_info_->feature_flags(); | 1697 return feature_info_->feature_flags(); |
1661 } | 1698 } |
1662 | 1699 |
1663 const FeatureInfo::Workarounds& workarounds() const { | 1700 const FeatureInfo::Workarounds& workarounds() const { |
1664 return feature_info_->workarounds(); | 1701 return feature_info_->workarounds(); |
(...skipping 1167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2832 DoGetIntegerv(GL_MAX_VERTEX_UNIFORM_VECTORS, | 2869 DoGetIntegerv(GL_MAX_VERTEX_UNIFORM_VECTORS, |
2833 &caps.max_vertex_uniform_vectors); | 2870 &caps.max_vertex_uniform_vectors); |
2834 DoGetIntegerv(GL_NUM_COMPRESSED_TEXTURE_FORMATS, | 2871 DoGetIntegerv(GL_NUM_COMPRESSED_TEXTURE_FORMATS, |
2835 &caps.num_compressed_texture_formats); | 2872 &caps.num_compressed_texture_formats); |
2836 DoGetIntegerv(GL_NUM_SHADER_BINARY_FORMATS, &caps.num_shader_binary_formats); | 2873 DoGetIntegerv(GL_NUM_SHADER_BINARY_FORMATS, &caps.num_shader_binary_formats); |
2837 DoGetIntegerv(GL_BIND_GENERATES_RESOURCE_CHROMIUM, | 2874 DoGetIntegerv(GL_BIND_GENERATES_RESOURCE_CHROMIUM, |
2838 &caps.bind_generates_resource_chromium); | 2875 &caps.bind_generates_resource_chromium); |
2839 | 2876 |
2840 caps.egl_image_external = | 2877 caps.egl_image_external = |
2841 feature_info_->feature_flags().oes_egl_image_external; | 2878 feature_info_->feature_flags().oes_egl_image_external; |
| 2879 caps.texture_format_atc = |
| 2880 feature_info_->feature_flags().ext_texture_format_atc; |
2842 caps.texture_format_bgra8888 = | 2881 caps.texture_format_bgra8888 = |
2843 feature_info_->feature_flags().ext_texture_format_bgra8888; | 2882 feature_info_->feature_flags().ext_texture_format_bgra8888; |
| 2883 caps.texture_format_dxt = |
| 2884 feature_info_->feature_flags().ext_texture_format_dxt; |
2844 caps.texture_format_etc1 = | 2885 caps.texture_format_etc1 = |
2845 feature_info_->feature_flags().oes_compressed_etc1_rgb8_texture; | 2886 feature_info_->feature_flags().oes_compressed_etc1_rgb8_texture; |
2846 caps.texture_format_etc1_npot = | 2887 caps.texture_format_etc1_npot = |
2847 caps.texture_format_etc1 && !workarounds().etc1_power_of_two_only; | 2888 caps.texture_format_etc1 && !workarounds().etc1_power_of_two_only; |
2848 caps.texture_rectangle = feature_info_->feature_flags().arb_texture_rectangle; | 2889 caps.texture_rectangle = feature_info_->feature_flags().arb_texture_rectangle; |
2849 caps.texture_usage = feature_info_->feature_flags().angle_texture_usage; | 2890 caps.texture_usage = feature_info_->feature_flags().angle_texture_usage; |
2850 caps.texture_storage = feature_info_->feature_flags().ext_texture_storage; | 2891 caps.texture_storage = feature_info_->feature_flags().ext_texture_storage; |
2851 caps.discard_framebuffer = | 2892 caps.discard_framebuffer = |
2852 feature_info_->feature_flags().ext_discard_framebuffer; | 2893 feature_info_->feature_flags().ext_discard_framebuffer; |
2853 caps.sync_query = feature_info_->feature_flags().chromium_sync_query; | 2894 caps.sync_query = feature_info_->feature_flags().chromium_sync_query; |
(...skipping 5482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8336 zero.get()); | 8377 zero.get()); |
8337 } | 8378 } |
8338 y += tile_height; | 8379 y += tile_height; |
8339 } | 8380 } |
8340 TextureRef* texture = texture_manager()->GetTextureInfoForTarget( | 8381 TextureRef* texture = texture_manager()->GetTextureInfoForTarget( |
8341 &state_, bind_target); | 8382 &state_, bind_target); |
8342 glBindTexture(bind_target, texture ? texture->service_id() : 0); | 8383 glBindTexture(bind_target, texture ? texture->service_id() : 0); |
8343 return true; | 8384 return true; |
8344 } | 8385 } |
8345 | 8386 |
8346 namespace { | |
8347 | |
8348 const int kS3TCBlockWidth = 4; | |
8349 const int kS3TCBlockHeight = 4; | |
8350 const int kS3TCDXT1BlockSize = 8; | |
8351 const int kS3TCDXT3AndDXT5BlockSize = 16; | |
8352 | |
8353 bool IsValidDXTSize(GLint level, GLsizei size) { | |
8354 return (size == 1) || | |
8355 (size == 2) || !(size % kS3TCBlockWidth); | |
8356 } | |
8357 | |
8358 bool IsValidPVRTCSize(GLint level, GLsizei size) { | |
8359 return GLES2Util::IsPOT(size); | |
8360 } | |
8361 | |
8362 } // anonymous namespace. | |
8363 | |
8364 bool GLES2DecoderImpl::ValidateCompressedTexFuncData( | 8387 bool GLES2DecoderImpl::ValidateCompressedTexFuncData( |
8365 const char* function_name, | 8388 const char* function_name, |
8366 GLsizei width, GLsizei height, GLenum format, size_t size) { | 8389 GLsizei width, GLsizei height, GLenum format, size_t size) { |
8367 unsigned int bytes_required = 0; | 8390 int bytes_required = 0; |
8368 | 8391 |
8369 switch (format) { | 8392 if (!GLES2Util::ComputeCompressedImageSize(width, height, format, |
8370 case GL_ATC_RGB_AMD: | 8393 &bytes_required)) { |
8371 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: | 8394 LOCAL_SET_GL_ERROR_INVALID_ENUM(function_name, format, "format"); |
8372 case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: | 8395 return false; |
8373 case GL_ETC1_RGB8_OES: { | |
8374 int num_blocks_across = | |
8375 (width + kS3TCBlockWidth - 1) / kS3TCBlockWidth; | |
8376 int num_blocks_down = | |
8377 (height + kS3TCBlockHeight - 1) / kS3TCBlockHeight; | |
8378 int num_blocks = num_blocks_across * num_blocks_down; | |
8379 bytes_required = num_blocks * kS3TCDXT1BlockSize; | |
8380 break; | |
8381 } | |
8382 case GL_ATC_RGBA_EXPLICIT_ALPHA_AMD: | |
8383 case GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD: | |
8384 case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: | |
8385 case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: { | |
8386 int num_blocks_across = | |
8387 (width + kS3TCBlockWidth - 1) / kS3TCBlockWidth; | |
8388 int num_blocks_down = | |
8389 (height + kS3TCBlockHeight - 1) / kS3TCBlockHeight; | |
8390 int num_blocks = num_blocks_across * num_blocks_down; | |
8391 bytes_required = num_blocks * kS3TCDXT3AndDXT5BlockSize; | |
8392 break; | |
8393 } | |
8394 case GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG: | |
8395 case GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG: { | |
8396 bytes_required = (std::max(width, 8) * std::max(height, 8) * 4 + 7)/8; | |
8397 break; | |
8398 } | |
8399 case GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG: | |
8400 case GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG: { | |
8401 bytes_required = (std::max(width, 16) * std::max(height, 8) * 2 + 7)/8; | |
8402 break; | |
8403 } | |
8404 default: | |
8405 LOCAL_SET_GL_ERROR_INVALID_ENUM(function_name, format, "format"); | |
8406 return false; | |
8407 } | 8396 } |
8408 | 8397 |
8409 if (size != bytes_required) { | 8398 if (size != static_cast<size_t>(bytes_required)) { |
8410 LOCAL_SET_GL_ERROR( | 8399 LOCAL_SET_GL_ERROR( |
8411 GL_INVALID_VALUE, function_name, "size is not correct for dimensions"); | 8400 GL_INVALID_VALUE, function_name, "size is not correct for dimensions"); |
8412 return false; | 8401 return false; |
8413 } | 8402 } |
8414 | 8403 |
8415 return true; | 8404 return true; |
8416 } | 8405 } |
8417 | 8406 |
8418 bool GLES2DecoderImpl::ValidateCompressedTexDimensions( | 8407 bool GLES2DecoderImpl::ValidateCompressedTexDimensions( |
8419 const char* function_name, | 8408 const char* function_name, |
8420 GLint level, GLsizei width, GLsizei height, GLenum format) { | 8409 GLint level, GLsizei width, GLsizei height, GLenum format) { |
8421 switch (format) { | 8410 if (!GLES2Util::IsValidCompressedImageSize(level, width, height, format)) { |
8422 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: | 8411 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name, |
8423 case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: | 8412 "width or height invalid for level"); |
8424 case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: | 8413 return false; |
8425 case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: { | |
8426 if (!IsValidDXTSize(level, width) || !IsValidDXTSize(level, height)) { | |
8427 LOCAL_SET_GL_ERROR( | |
8428 GL_INVALID_OPERATION, function_name, | |
8429 "width or height invalid for level"); | |
8430 return false; | |
8431 } | |
8432 return true; | |
8433 } | |
8434 case GL_ATC_RGB_AMD: | |
8435 case GL_ATC_RGBA_EXPLICIT_ALPHA_AMD: | |
8436 case GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD: | |
8437 case GL_ETC1_RGB8_OES: { | |
8438 if (width <= 0 || height <= 0) { | |
8439 LOCAL_SET_GL_ERROR( | |
8440 GL_INVALID_OPERATION, function_name, | |
8441 "width or height invalid for level"); | |
8442 return false; | |
8443 } | |
8444 return true; | |
8445 } | |
8446 case GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG: | |
8447 case GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG: | |
8448 case GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG: | |
8449 case GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG: { | |
8450 if (!IsValidPVRTCSize(level, width) || | |
8451 !IsValidPVRTCSize(level, height)) { | |
8452 LOCAL_SET_GL_ERROR( | |
8453 GL_INVALID_OPERATION, function_name, | |
8454 "width or height invalid for level"); | |
8455 return false; | |
8456 } | |
8457 return true; | |
8458 } | |
8459 default: | |
8460 return false; | |
8461 } | 8414 } |
| 8415 |
| 8416 return true; |
8462 } | 8417 } |
8463 | 8418 |
8464 bool GLES2DecoderImpl::ValidateCompressedTexSubDimensions( | 8419 bool GLES2DecoderImpl::ValidateCompressedTexSubDimensions( |
8465 const char* function_name, | 8420 const char* function_name, |
8466 GLenum target, GLint level, GLint xoffset, GLint yoffset, | 8421 GLenum target, GLint level, GLint xoffset, GLint yoffset, |
8467 GLsizei width, GLsizei height, GLenum format, | 8422 GLsizei width, GLsizei height, GLenum format, |
8468 Texture* texture) { | 8423 Texture* texture) { |
8469 if (xoffset < 0 || yoffset < 0) { | 8424 if (xoffset < 0 || yoffset < 0) { |
8470 LOCAL_SET_GL_ERROR( | 8425 LOCAL_SET_GL_ERROR( |
8471 GL_INVALID_VALUE, function_name, "xoffset or yoffset < 0"); | 8426 GL_INVALID_VALUE, function_name, "xoffset or yoffset < 0"); |
8472 return false; | 8427 return false; |
8473 } | 8428 } |
8474 | 8429 |
8475 switch (format) { | 8430 switch (format) { |
| 8431 case GL_ATC_RGB_AMD: |
| 8432 case GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD: |
8476 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: | 8433 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: |
8477 case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: | 8434 case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: |
8478 case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: | 8435 case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: |
8479 case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: { | 8436 case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: |
| 8437 case GL_ETC1_RGB8_OES: { |
8480 const int kBlockWidth = 4; | 8438 const int kBlockWidth = 4; |
8481 const int kBlockHeight = 4; | 8439 const int kBlockHeight = 4; |
8482 if ((xoffset % kBlockWidth) || (yoffset % kBlockHeight)) { | 8440 if ((xoffset % kBlockWidth) || (yoffset % kBlockHeight)) { |
8483 LOCAL_SET_GL_ERROR( | 8441 LOCAL_SET_GL_ERROR( |
8484 GL_INVALID_OPERATION, function_name, | 8442 GL_INVALID_OPERATION, function_name, |
8485 "xoffset or yoffset not multiple of 4"); | 8443 "xoffset or yoffset not multiple of 4"); |
8486 return false; | 8444 return false; |
8487 } | 8445 } |
8488 GLsizei tex_width = 0; | 8446 GLsizei tex_width = 0; |
8489 GLsizei tex_height = 0; | 8447 GLsizei tex_height = 0; |
8490 if (!texture->GetLevelSize(target, level, &tex_width, &tex_height) || | 8448 if (!texture->GetLevelSize(target, level, &tex_width, &tex_height) || |
8491 width - xoffset > tex_width || | 8449 width - xoffset > tex_width || |
8492 height - yoffset > tex_height) { | 8450 height - yoffset > tex_height) { |
8493 LOCAL_SET_GL_ERROR( | 8451 LOCAL_SET_GL_ERROR( |
8494 GL_INVALID_OPERATION, function_name, "dimensions out of range"); | 8452 GL_INVALID_OPERATION, function_name, "dimensions out of range"); |
8495 return false; | 8453 return false; |
8496 } | 8454 } |
8497 return ValidateCompressedTexDimensions( | 8455 return ValidateCompressedTexDimensions( |
8498 function_name, level, width, height, format); | 8456 function_name, level, width, height, format); |
8499 } | 8457 } |
8500 case GL_ATC_RGB_AMD: | 8458 case GL_ATC_RGBA_EXPLICIT_ALPHA_AMD: { |
8501 case GL_ATC_RGBA_EXPLICIT_ALPHA_AMD: | |
8502 case GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD: { | |
8503 LOCAL_SET_GL_ERROR( | 8459 LOCAL_SET_GL_ERROR( |
8504 GL_INVALID_OPERATION, function_name, | 8460 GL_INVALID_OPERATION, function_name, |
8505 "not supported for ATC textures"); | 8461 "not supported for ATC textures"); |
8506 return false; | 8462 return false; |
8507 } | 8463 } |
8508 case GL_ETC1_RGB8_OES: { | |
8509 LOCAL_SET_GL_ERROR( | |
8510 GL_INVALID_OPERATION, function_name, | |
8511 "not supported for ECT1_RGB8_OES textures"); | |
8512 return false; | |
8513 } | |
8514 case GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG: | 8464 case GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG: |
8515 case GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG: | 8465 case GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG: |
8516 case GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG: | 8466 case GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG: |
8517 case GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG: { | 8467 case GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG: { |
8518 if ((xoffset != 0) || (yoffset != 0)) { | 8468 if ((xoffset != 0) || (yoffset != 0)) { |
8519 LOCAL_SET_GL_ERROR( | 8469 LOCAL_SET_GL_ERROR( |
8520 GL_INVALID_OPERATION, function_name, | 8470 GL_INVALID_OPERATION, function_name, |
8521 "xoffset and yoffset must be zero"); | 8471 "xoffset and yoffset must be zero"); |
8522 return false; | 8472 return false; |
8523 } | 8473 } |
8524 GLsizei tex_width = 0; | 8474 GLsizei tex_width = 0; |
8525 GLsizei tex_height = 0; | 8475 GLsizei tex_height = 0; |
8526 if (!texture->GetLevelSize(target, level, &tex_width, &tex_height) || | 8476 if (!texture->GetLevelSize(target, level, &tex_width, &tex_height) || |
8527 width != tex_width || | 8477 width != tex_width || |
8528 height != tex_height) { | 8478 height != tex_height) { |
8529 LOCAL_SET_GL_ERROR( | 8479 LOCAL_SET_GL_ERROR( |
8530 GL_INVALID_OPERATION, function_name, | 8480 GL_INVALID_OPERATION, function_name, |
8531 "dimensions must match existing texture level dimensions"); | 8481 "dimensions must match existing texture level dimensions"); |
8532 return false; | 8482 return false; |
8533 } | 8483 } |
8534 return ValidateCompressedTexDimensions( | 8484 return ValidateCompressedTexDimensions( |
8535 function_name, level, width, height, format); | 8485 function_name, level, width, height, format); |
8536 } | 8486 } |
8537 default: | 8487 default: |
8538 return false; | 8488 return false; |
8539 } | 8489 } |
8540 } | 8490 } |
8541 | 8491 |
| 8492 bool GLES2DecoderImpl::ValidateCompressedTexSubImage2D( |
| 8493 error::Error* error, |
| 8494 const char* function_name, |
| 8495 GLenum target, |
| 8496 GLint level, |
| 8497 GLint xoffset, |
| 8498 GLint yoffset, |
| 8499 GLsizei width, |
| 8500 GLsizei height, |
| 8501 GLenum format, |
| 8502 GLsizei image_size, |
| 8503 const void* data) { |
| 8504 (*error) = error::kNoError; |
| 8505 if (!validators_->texture_target.IsValid(target)) { |
| 8506 LOCAL_SET_GL_ERROR_INVALID_ENUM(function_name, target, "target"); |
| 8507 return false; |
| 8508 } |
| 8509 if (width < 0) { |
| 8510 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, "width < 0"); |
| 8511 return false; |
| 8512 } |
| 8513 if (height < 0) { |
| 8514 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, "height < 0"); |
| 8515 return false; |
| 8516 } |
| 8517 TextureRef* texture_ref = |
| 8518 texture_manager()->GetTextureInfoForTarget(&state_, target); |
| 8519 if (!texture_ref) { |
| 8520 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name, |
| 8521 "unknown texture for target"); |
| 8522 return false; |
| 8523 } |
| 8524 Texture* texture = texture_ref->texture(); |
| 8525 GLenum current_type = 0; |
| 8526 GLenum internal_format = 0; |
| 8527 if (!texture->GetLevelType(target, level, ¤t_type, &internal_format)) { |
| 8528 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name, |
| 8529 "level does not exist."); |
| 8530 return false; |
| 8531 } |
| 8532 if (async_pixel_transfer_manager_->AsyncTransferIsInProgress(texture_ref)) { |
| 8533 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name, |
| 8534 "async upload pending for texture"); |
| 8535 return false; |
| 8536 } |
| 8537 if (!ValidateCompressedTexFuncData(function_name, width, height, format, |
| 8538 image_size)) { |
| 8539 return false; |
| 8540 } |
| 8541 if (!ValidateCompressedTexSubDimensions(function_name, target, level, xoffset, |
| 8542 yoffset, width, height, format, |
| 8543 texture)) { |
| 8544 return false; |
| 8545 } |
| 8546 if (!texture->ValidForTexture(target, level, xoffset, yoffset, width, height, |
| 8547 GL_UNSIGNED_BYTE)) { |
| 8548 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, "bad dimensions."); |
| 8549 return false; |
| 8550 } |
| 8551 if (data == NULL) { |
| 8552 (*error) = error::kOutOfBounds; |
| 8553 return false; |
| 8554 } |
| 8555 return true; |
| 8556 } |
| 8557 |
8542 error::Error GLES2DecoderImpl::DoCompressedTexImage2D( | 8558 error::Error GLES2DecoderImpl::DoCompressedTexImage2D( |
8543 GLenum target, | 8559 GLenum target, |
8544 GLint level, | 8560 GLint level, |
8545 GLenum internal_format, | 8561 GLenum internal_format, |
8546 GLsizei width, | 8562 GLsizei width, |
8547 GLsizei height, | 8563 GLsizei height, |
8548 GLint border, | 8564 GLint border, |
8549 GLsizei image_size, | 8565 GLsizei image_size, |
8550 const void* data) { | 8566 const void* data) { |
8551 // TODO(gman): Validate image_size is correct for width, height and format. | 8567 // TODO(gman): Validate image_size is correct for width, height and format. |
(...skipping 2028 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10580 source_width, | 10596 source_width, |
10581 source_height, | 10597 source_height, |
10582 unpack_flip_y_, | 10598 unpack_flip_y_, |
10583 unpack_premultiply_alpha_, | 10599 unpack_premultiply_alpha_, |
10584 unpack_unpremultiply_alpha_); | 10600 unpack_unpremultiply_alpha_); |
10585 } | 10601 } |
10586 | 10602 |
10587 DoDidUseTexImageIfNeeded(source_texture, source_texture->target()); | 10603 DoDidUseTexImageIfNeeded(source_texture, source_texture->target()); |
10588 } | 10604 } |
10589 | 10605 |
| 10606 void GLES2DecoderImpl::DoCopyCompressedTextureCHROMIUM(GLenum target, |
| 10607 GLuint source_id, |
| 10608 GLuint dest_id, |
| 10609 GLenum internal_format, |
| 10610 GLenum dest_type) { |
| 10611 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoCopyCompressedTextureCHROMIUM"); |
| 10612 |
| 10613 TextureRef* dest_texture_ref = GetTexture(dest_id); |
| 10614 TextureRef* source_texture_ref = GetTexture(source_id); |
| 10615 |
| 10616 if (!source_texture_ref || !dest_texture_ref) { |
| 10617 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopyCompressedTextureCHROMIUM", |
| 10618 "unknown texture id"); |
| 10619 return; |
| 10620 } |
| 10621 |
| 10622 if (GL_TEXTURE_2D != target) { |
| 10623 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopyCompressedTextureCHROMIUM", |
| 10624 "invalid texture target"); |
| 10625 return; |
| 10626 } |
| 10627 |
| 10628 Texture* source_texture = source_texture_ref->texture(); |
| 10629 Texture* dest_texture = dest_texture_ref->texture(); |
| 10630 if (dest_texture->target() != GL_TEXTURE_2D || |
| 10631 (source_texture->target() != GL_TEXTURE_2D && |
| 10632 source_texture->target() != GL_TEXTURE_RECTANGLE_ARB && |
| 10633 source_texture->target() != GL_TEXTURE_EXTERNAL_OES)) { |
| 10634 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopyCompressedTextureCHROMIUM", |
| 10635 "invalid texture target binding"); |
| 10636 return; |
| 10637 } |
| 10638 |
| 10639 gfx::GLImage* image = |
| 10640 source_texture->GetLevelImage(source_texture->target(), 0); |
| 10641 if (!image) { |
| 10642 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopyCompressedTextureCHROMIUM", |
| 10643 "source texture has no level 0"); |
| 10644 return; |
| 10645 } |
| 10646 |
| 10647 gfx::Size size = image->GetSize(); |
| 10648 int source_width = size.width(); |
| 10649 int source_height = size.height(); |
| 10650 if (source_width <= 0 || source_height <= 0) { |
| 10651 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopyCompressedTextureCHROMIUM", |
| 10652 "invalid image size"); |
| 10653 return; |
| 10654 } |
| 10655 |
| 10656 // Clear the source texture if necessary. |
| 10657 if (!texture_manager()->ClearTextureLevel(this, source_texture_ref, |
| 10658 source_texture->target(), 0)) { |
| 10659 LOCAL_SET_GL_ERROR(GL_OUT_OF_MEMORY, "glCopyCompressedTextureCHROMIUM", |
| 10660 "dimensions too big"); |
| 10661 return; |
| 10662 } |
| 10663 |
| 10664 GLenum source_type = 0; |
| 10665 GLenum source_internal_format = 0; |
| 10666 source_texture->GetLevelType(source_texture->target(), 0, &source_type, |
| 10667 &source_internal_format); |
| 10668 |
| 10669 // The destination format should be one of the supported compressed formats. |
| 10670 bool valid_dest_format = |
| 10671 internal_format == GL_ATC_RGB_AMD || |
| 10672 internal_format == GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD || |
| 10673 internal_format == GL_COMPRESSED_RGB_S3TC_DXT1_EXT || |
| 10674 internal_format == GL_COMPRESSED_RGBA_S3TC_DXT5_EXT || |
| 10675 internal_format == GL_ETC1_RGB8_OES; |
| 10676 bool valid_source_format = source_internal_format == GL_ALPHA || |
| 10677 source_internal_format == GL_RGB || |
| 10678 source_internal_format == GL_RGBA || |
| 10679 source_internal_format == GL_LUMINANCE || |
| 10680 source_internal_format == GL_LUMINANCE_ALPHA || |
| 10681 source_internal_format == GL_BGRA_EXT; |
| 10682 if (!valid_source_format || !valid_dest_format) { |
| 10683 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glCopyCompressedTextureCHROMIUM", |
| 10684 "invalid internal format"); |
| 10685 return; |
| 10686 } |
| 10687 |
| 10688 // Defer initializing the CopyTextureCHROMIUMResourceManager until it is |
| 10689 // needed because it takes 10s of milliseconds to initialize. |
| 10690 if (!copy_texture_CHROMIUM_.get()) { |
| 10691 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCopyCompressedTextureCHROMIUM"); |
| 10692 copy_texture_CHROMIUM_.reset(new CopyTextureCHROMIUMResourceManager()); |
| 10693 copy_texture_CHROMIUM_->Initialize(this); |
| 10694 RestoreCurrentFramebufferBindings(); |
| 10695 if (LOCAL_PEEK_GL_ERROR("glCopyCompressedTextureCHROMIUM") != GL_NO_ERROR) |
| 10696 return; |
| 10697 } |
| 10698 |
| 10699 GLenum dest_type_previous = dest_type; |
| 10700 GLenum dest_internal_format = internal_format; |
| 10701 int dest_width = 0, dest_height = 0; |
| 10702 bool dest_level_defined = |
| 10703 dest_texture->GetLevelSize(GL_TEXTURE_2D, 0, &dest_width, &dest_height); |
| 10704 |
| 10705 if (dest_level_defined) { |
| 10706 dest_texture->GetLevelType(GL_TEXTURE_2D, 0, &dest_type_previous, |
| 10707 &dest_internal_format); |
| 10708 } |
| 10709 |
| 10710 // Resize the destination texture to the dimensions of the source texture. |
| 10711 if (!dest_level_defined || dest_width != source_width || |
| 10712 dest_height != source_height || dest_internal_format != internal_format || |
| 10713 dest_type_previous != dest_type) { |
| 10714 // Compute image byte size. |
| 10715 GLsizei image_size = |
| 10716 source_width * source_height * BitsPerPixel(internal_format) / 8; |
| 10717 |
| 10718 // Ensure that the glCompressedTexImage2D succeeds. |
| 10719 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCopyCompressedTextureCHROMIUM"); |
| 10720 glBindTexture(GL_TEXTURE_2D, dest_texture->service_id()); |
| 10721 glCompressedTexImage2D(GL_TEXTURE_2D, 0, internal_format, source_width, |
| 10722 source_height, 0, image_size, NULL); |
| 10723 |
| 10724 GLenum error = LOCAL_PEEK_GL_ERROR("glCopyCompressedTextureCHROMIUM"); |
| 10725 if (error != GL_NO_ERROR) { |
| 10726 RestoreCurrentTextureBindings(&state_, GL_TEXTURE_2D); |
| 10727 return; |
| 10728 } |
| 10729 |
| 10730 texture_manager()->SetLevelInfo( |
| 10731 dest_texture_ref, GL_TEXTURE_2D, 0, internal_format, source_width, |
| 10732 source_height, 1, 0, internal_format, dest_type, true); |
| 10733 } else { |
| 10734 texture_manager()->SetLevelCleared(dest_texture_ref, GL_TEXTURE_2D, 0, |
| 10735 true); |
| 10736 } |
| 10737 |
| 10738 ScopedModifyPixels modify(dest_texture_ref); |
| 10739 |
| 10740 DCHECK(!unpack_flip_y_); |
| 10741 DCHECK(!(unpack_premultiply_alpha_ ^ unpack_unpremultiply_alpha_)); |
| 10742 |
| 10743 // Copying compressed textures is only supported using GLImage::CopyTexImage. |
| 10744 glBindTexture(GL_TEXTURE_2D, dest_texture->service_id()); |
| 10745 bool copy_result = image->CopyTexImage(GL_TEXTURE_2D); |
| 10746 DCHECK(copy_result); |
| 10747 } |
| 10748 |
10590 static GLenum ExtractTypeFromStorageFormat(GLenum internalformat) { | 10749 static GLenum ExtractTypeFromStorageFormat(GLenum internalformat) { |
10591 switch (internalformat) { | 10750 switch (internalformat) { |
10592 case GL_RGB565: | 10751 case GL_RGB565: |
10593 return GL_UNSIGNED_SHORT_5_6_5; | 10752 return GL_UNSIGNED_SHORT_5_6_5; |
10594 case GL_RGBA4: | 10753 case GL_RGBA4: |
10595 return GL_UNSIGNED_SHORT_4_4_4_4; | 10754 return GL_UNSIGNED_SHORT_4_4_4_4; |
10596 case GL_RGB5_A1: | 10755 case GL_RGB5_A1: |
10597 return GL_UNSIGNED_SHORT_5_5_5_1; | 10756 return GL_UNSIGNED_SHORT_5_5_5_1; |
10598 case GL_RGB8_OES: | 10757 case GL_RGB8_OES: |
10599 return GL_UNSIGNED_BYTE; | 10758 return GL_UNSIGNED_BYTE; |
(...skipping 865 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11465 // immutable so the async state stays valid. | 11624 // immutable so the async state stays valid. |
11466 delegate = async_pixel_transfer_manager_->CreatePixelTransferDelegate( | 11625 delegate = async_pixel_transfer_manager_->CreatePixelTransferDelegate( |
11467 texture_ref, define_params); | 11626 texture_ref, define_params); |
11468 texture->SetImmutable(true); | 11627 texture->SetImmutable(true); |
11469 } | 11628 } |
11470 | 11629 |
11471 delegate->AsyncTexSubImage2D(tex_params, mem_params); | 11630 delegate->AsyncTexSubImage2D(tex_params, mem_params); |
11472 return error::kNoError; | 11631 return error::kNoError; |
11473 } | 11632 } |
11474 | 11633 |
| 11634 error::Error GLES2DecoderImpl::HandleAsyncCompressedTexImage2DCHROMIUM( |
| 11635 uint32 immediate_data_size, |
| 11636 const void* cmd_data) { |
| 11637 const gles2::cmds::AsyncCompressedTexImage2DCHROMIUM& c = |
| 11638 *static_cast<const gles2::cmds::AsyncCompressedTexImage2DCHROMIUM*>( |
| 11639 cmd_data); |
| 11640 GLenum target = static_cast<GLenum>(c.target); |
| 11641 GLint level = static_cast<GLint>(c.level); |
| 11642 // TODO(kloveless): Change HandleAsyncTexImage2DCHROMIUM command to use |
| 11643 // unsigned integer for internalformat. |
| 11644 GLenum internal_format = static_cast<GLenum>(c.internalformat); |
| 11645 GLsizei width = static_cast<GLsizei>(c.width); |
| 11646 GLsizei height = static_cast<GLsizei>(c.height); |
| 11647 GLint border = static_cast<GLint>(c.border); |
| 11648 GLsizei image_size = static_cast<GLenum>(c.imagesize); |
| 11649 uint32 pixels_shm_id = static_cast<uint32>(c.pixels_shm_id); |
| 11650 uint32 pixels_shm_offset = static_cast<uint32>(c.pixels_shm_offset); |
| 11651 uint32 async_upload_token = static_cast<uint32>(c.async_upload_token); |
| 11652 uint32 sync_data_shm_id = static_cast<uint32>(c.sync_data_shm_id); |
| 11653 uint32 sync_data_shm_offset = static_cast<uint32>(c.sync_data_shm_offset); |
| 11654 |
| 11655 base::ScopedClosureRunner scoped_completion_callback; |
| 11656 if (async_upload_token) { |
| 11657 base::Closure completion_closure = AsyncUploadTokenCompletionClosure( |
| 11658 async_upload_token, sync_data_shm_id, sync_data_shm_offset); |
| 11659 if (completion_closure.is_null()) |
| 11660 return error::kInvalidArguments; |
| 11661 |
| 11662 scoped_completion_callback.Reset(completion_closure); |
| 11663 } |
| 11664 |
| 11665 const void* pixels = NULL; |
| 11666 if (pixels_shm_id != 0 || pixels_shm_offset != 0) { |
| 11667 pixels = GetSharedMemoryAs<const void*>(pixels_shm_id, pixels_shm_offset, |
| 11668 image_size); |
| 11669 if (!pixels) { |
| 11670 return error::kOutOfBounds; |
| 11671 } |
| 11672 } |
| 11673 |
| 11674 TextureManager::DoCompressedTexImage2DArguments args = {target, |
| 11675 level, |
| 11676 internal_format, |
| 11677 width, |
| 11678 height, |
| 11679 border, |
| 11680 image_size, |
| 11681 pixels}; |
| 11682 TextureRef* texture_ref; |
| 11683 // All the normal glCompressedTexImage2D validation. |
| 11684 if (!texture_manager()->ValidateCompressedTexImage2D( |
| 11685 &state_, "glAsyncCompressedTexImage2DCHROMIUM", args, &texture_ref)) { |
| 11686 return error::kNoError; |
| 11687 } |
| 11688 |
| 11689 // Extra async validation. |
| 11690 Texture* texture = texture_ref->texture(); |
| 11691 if (!ValidateAsyncTransfer("glAsyncCompressedTexImage2DCHROMIUM", texture_ref, |
| 11692 target, level, pixels)) |
| 11693 return error::kNoError; |
| 11694 |
| 11695 // Don't allow async redefinition of a textures. |
| 11696 if (texture->IsDefined()) { |
| 11697 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, |
| 11698 "glAsyncCompressedTexImage2DCHROMIUM", |
| 11699 "already defined"); |
| 11700 return error::kNoError; |
| 11701 } |
| 11702 |
| 11703 if (!EnsureGPUMemoryAvailable(image_size)) { |
| 11704 LOCAL_SET_GL_ERROR(GL_OUT_OF_MEMORY, "glAsyncCompressedTexImage2DCHROMIUM", |
| 11705 "out of memory"); |
| 11706 return error::kNoError; |
| 11707 } |
| 11708 |
| 11709 // Setup the parameters. |
| 11710 AsyncCompressedTexImage2DParams tex_params = { |
| 11711 target, |
| 11712 level, |
| 11713 static_cast<GLenum>(internal_format), |
| 11714 width, |
| 11715 height, |
| 11716 border, |
| 11717 image_size}; |
| 11718 AsyncMemoryParams mem_params(GetSharedMemoryBuffer(c.pixels_shm_id), |
| 11719 c.pixels_shm_offset, image_size); |
| 11720 |
| 11721 // Set up the async state if needed, and make the texture |
| 11722 // immutable so the async state stays valid. The level info |
| 11723 // is set up lazily when the transfer completes. |
| 11724 AsyncPixelTransferDelegate* delegate = |
| 11725 async_pixel_transfer_manager_->CreatePixelTransferDelegate(texture_ref, |
| 11726 tex_params); |
| 11727 texture->SetImmutable(true); |
| 11728 |
| 11729 delegate->AsyncCompressedTexImage2D( |
| 11730 tex_params, mem_params, |
| 11731 base::Bind(&TextureManager::SetCompressedLevelInfoFromParams, |
| 11732 // The callback is only invoked if the transfer delegate still |
| 11733 // exists, which implies through manager->texture_ref->state |
| 11734 // ownership that both of these pointers are valid. |
| 11735 base::Unretained(texture_manager()), |
| 11736 base::Unretained(texture_ref), tex_params)); |
| 11737 return error::kNoError; |
| 11738 } |
| 11739 |
| 11740 error::Error GLES2DecoderImpl::HandleAsyncCompressedTexSubImage2DCHROMIUM( |
| 11741 uint32 immediate_data_size, |
| 11742 const void* cmd_data) { |
| 11743 const gles2::cmds::AsyncCompressedTexSubImage2DCHROMIUM& c = |
| 11744 *static_cast<const gles2::cmds::AsyncCompressedTexSubImage2DCHROMIUM*>( |
| 11745 cmd_data); |
| 11746 TRACE_EVENT0("gpu", |
| 11747 "GLES2DecoderImpl::HandleAsyncCompressedTexSubImage2DCHROMIUM"); |
| 11748 GLenum target = static_cast<GLenum>(c.target); |
| 11749 GLint level = static_cast<GLint>(c.level); |
| 11750 GLint xoffset = static_cast<GLint>(c.xoffset); |
| 11751 GLint yoffset = static_cast<GLint>(c.yoffset); |
| 11752 GLsizei width = static_cast<GLsizei>(c.width); |
| 11753 GLsizei height = static_cast<GLsizei>(c.height); |
| 11754 GLenum format = static_cast<GLenum>(c.format); |
| 11755 GLsizei image_size = static_cast<GLsizei>(c.imagesize); |
| 11756 uint32 async_upload_token = static_cast<uint32>(c.async_upload_token); |
| 11757 uint32 sync_data_shm_id = static_cast<uint32>(c.sync_data_shm_id); |
| 11758 uint32 sync_data_shm_offset = static_cast<uint32>(c.sync_data_shm_offset); |
| 11759 |
| 11760 base::ScopedClosureRunner scoped_completion_callback; |
| 11761 if (async_upload_token) { |
| 11762 base::Closure completion_closure = AsyncUploadTokenCompletionClosure( |
| 11763 async_upload_token, sync_data_shm_id, sync_data_shm_offset); |
| 11764 if (completion_closure.is_null()) |
| 11765 return error::kInvalidArguments; |
| 11766 |
| 11767 scoped_completion_callback.Reset(completion_closure); |
| 11768 } |
| 11769 |
| 11770 const void* pixels = GetSharedMemoryAs<const void*>( |
| 11771 c.data_shm_id, c.data_shm_offset, image_size); |
| 11772 |
| 11773 // All the normal glCompressedTexSubImage2D validation. |
| 11774 error::Error error = error::kNoError; |
| 11775 if (!ValidateCompressedTexSubImage2D( |
| 11776 &error, "glAsyncCompressedTexSubImage2DCHROMIUM", target, level, |
| 11777 xoffset, yoffset, width, height, format, image_size, pixels)) { |
| 11778 return error; |
| 11779 } |
| 11780 |
| 11781 // Extra async validation. |
| 11782 TextureRef* texture_ref = |
| 11783 texture_manager()->GetTextureInfoForTarget(&state_, target); |
| 11784 Texture* texture = texture_ref->texture(); |
| 11785 if (!ValidateAsyncTransfer("glAsyncCompressedTexSubImage2DCHROMIUM", |
| 11786 texture_ref, target, level, pixels)) |
| 11787 return error::kNoError; |
| 11788 |
| 11789 // Guarantee async textures are always 'cleared' as follows: |
| 11790 // - AsyncCompressedTexImage2D can not redefine an existing texture |
| 11791 // - AsyncCompressedTexImage2D must initialize the entire image via non-null |
| 11792 // buffer. |
| 11793 // - AsyncCompressedTexSubImage2D clears synchronously if not already cleared. |
| 11794 // - Textures become immutable after an async call. |
| 11795 // This way we know in all cases that an async texture is always clear. |
| 11796 if (!texture->SafeToRenderFrom()) { |
| 11797 if (!texture_manager()->ClearTextureLevel(this, texture_ref, target, |
| 11798 level)) { |
| 11799 LOCAL_SET_GL_ERROR(GL_OUT_OF_MEMORY, |
| 11800 "glAsyncCompressedTexSubImage2DCHROMIUM", |
| 11801 "dimensions too big"); |
| 11802 return error::kNoError; |
| 11803 } |
| 11804 } |
| 11805 |
| 11806 // Setup the parameters. |
| 11807 AsyncCompressedTexSubImage2DParams tex_params = {target, |
| 11808 level, |
| 11809 xoffset, |
| 11810 yoffset, |
| 11811 width, |
| 11812 height, |
| 11813 static_cast<GLenum>(format), |
| 11814 image_size}; |
| 11815 AsyncMemoryParams mem_params(GetSharedMemoryBuffer(c.data_shm_id), |
| 11816 c.data_shm_offset, image_size); |
| 11817 AsyncPixelTransferDelegate* delegate = |
| 11818 async_pixel_transfer_manager_->GetPixelTransferDelegate(texture_ref); |
| 11819 if (!delegate) { |
| 11820 // TODO(epenner): We may want to enforce exclusive use |
| 11821 // of async APIs in which case this should become an error, |
| 11822 // (the texture should have been async defined). |
| 11823 AsyncCompressedTexImage2DParams define_params = { |
| 11824 target, level, 0, 0, 0, 0, 0}; |
| 11825 texture->GetLevelSize(target, level, &define_params.width, |
| 11826 &define_params.height); |
| 11827 GLenum dummy_type; |
| 11828 texture->GetLevelType(target, level, &dummy_type, |
| 11829 &define_params.internal_format); |
| 11830 |
| 11831 // Set up the async state if needed, and make the texture |
| 11832 // immutable so the async state stays valid. |
| 11833 delegate = async_pixel_transfer_manager_->CreatePixelTransferDelegate( |
| 11834 texture_ref, define_params); |
| 11835 texture->SetImmutable(true); |
| 11836 } |
| 11837 |
| 11838 delegate->AsyncCompressedTexSubImage2D(tex_params, mem_params); |
| 11839 return error::kNoError; |
| 11840 } |
| 11841 |
11475 error::Error GLES2DecoderImpl::HandleWaitAsyncTexImage2DCHROMIUM( | 11842 error::Error GLES2DecoderImpl::HandleWaitAsyncTexImage2DCHROMIUM( |
11476 uint32 immediate_data_size, | 11843 uint32 immediate_data_size, |
11477 const void* cmd_data) { | 11844 const void* cmd_data) { |
11478 const gles2::cmds::WaitAsyncTexImage2DCHROMIUM& c = | 11845 const gles2::cmds::WaitAsyncTexImage2DCHROMIUM& c = |
11479 *static_cast<const gles2::cmds::WaitAsyncTexImage2DCHROMIUM*>(cmd_data); | 11846 *static_cast<const gles2::cmds::WaitAsyncTexImage2DCHROMIUM*>(cmd_data); |
11480 TRACE_EVENT0("gpu", "GLES2DecoderImpl::HandleWaitAsyncTexImage2DCHROMIUM"); | 11847 TRACE_EVENT0("gpu", "GLES2DecoderImpl::HandleWaitAsyncTexImage2DCHROMIUM"); |
11481 GLenum target = static_cast<GLenum>(c.target); | 11848 GLenum target = static_cast<GLenum>(c.target); |
11482 | 11849 |
11483 if (GL_TEXTURE_2D != target) { | 11850 if (GL_TEXTURE_2D != target) { |
11484 LOCAL_SET_GL_ERROR( | 11851 LOCAL_SET_GL_ERROR( |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11532 } | 11899 } |
11533 } | 11900 } |
11534 | 11901 |
11535 // Include the auto-generated part of this file. We split this because it means | 11902 // Include the auto-generated part of this file. We split this because it means |
11536 // we can easily edit the non-auto generated parts right here in this file | 11903 // we can easily edit the non-auto generated parts right here in this file |
11537 // instead of having to edit some template or the code generator. | 11904 // instead of having to edit some template or the code generator. |
11538 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 11905 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
11539 | 11906 |
11540 } // namespace gles2 | 11907 } // namespace gles2 |
11541 } // namespace gpu | 11908 } // namespace gpu |
OLD | NEW |