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 <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 2010 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2021 GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, | 2021 GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, |
2022 GLsizei width, GLsizei height, GLsizei depth, GLenum format, | 2022 GLsizei width, GLsizei height, GLsizei depth, GLenum format, |
2023 Texture* texture); | 2023 Texture* texture); |
2024 bool ValidateCopyTextureCHROMIUMTextures(const char* function_name, | 2024 bool ValidateCopyTextureCHROMIUMTextures(const char* function_name, |
2025 GLenum dest_target, | 2025 GLenum dest_target, |
2026 TextureRef* source_texture_ref, | 2026 TextureRef* source_texture_ref, |
2027 TextureRef* dest_texture_ref); | 2027 TextureRef* dest_texture_ref); |
2028 bool CanUseCopyTextureCHROMIUMInternalFormat(GLenum dest_internal_format); | 2028 bool CanUseCopyTextureCHROMIUMInternalFormat(GLenum dest_internal_format); |
2029 CopyTextureMethod ValidateCopyTextureCHROMIUMInternalFormats( | 2029 CopyTextureMethod ValidateCopyTextureCHROMIUMInternalFormats( |
2030 const char* function_name, | 2030 const char* function_name, |
2031 TextureRef* source_texture_ref, | |
2032 GLint source_level, | 2031 GLint source_level, |
| 2032 GLenum source_internal_format, |
| 2033 GLenum source_type, |
| 2034 GLenum dest_target, |
| 2035 GLint dest_level, |
2033 GLenum dest_internal_format); | 2036 GLenum dest_internal_format); |
2034 bool ValidateCompressedCopyTextureCHROMIUM(const char* function_name, | 2037 bool ValidateCompressedCopyTextureCHROMIUM(const char* function_name, |
2035 TextureRef* source_texture_ref, | 2038 TextureRef* source_texture_ref, |
2036 TextureRef* dest_texture_ref); | 2039 TextureRef* dest_texture_ref); |
2037 | 2040 |
2038 void RenderWarning(const char* filename, int line, const std::string& msg); | 2041 void RenderWarning(const char* filename, int line, const std::string& msg); |
2039 void PerformanceWarning( | 2042 void PerformanceWarning( |
2040 const char* filename, int line, const std::string& msg); | 2043 const char* filename, int line, const std::string& msg); |
2041 | 2044 |
2042 const FeatureInfo::FeatureFlags& features() const { | 2045 const FeatureInfo::FeatureFlags& features() const { |
(...skipping 14220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16263 case GL_RGBA32F: | 16266 case GL_RGBA32F: |
16264 case GL_R11F_G11F_B10F: | 16267 case GL_R11F_G11F_B10F: |
16265 return true; | 16268 return true; |
16266 default: | 16269 default: |
16267 return false; | 16270 return false; |
16268 } | 16271 } |
16269 } | 16272 } |
16270 | 16273 |
16271 CopyTextureMethod GLES2DecoderImpl::ValidateCopyTextureCHROMIUMInternalFormats( | 16274 CopyTextureMethod GLES2DecoderImpl::ValidateCopyTextureCHROMIUMInternalFormats( |
16272 const char* function_name, | 16275 const char* function_name, |
16273 TextureRef* source_texture_ref, | |
16274 GLint source_level, | 16276 GLint source_level, |
| 16277 GLenum source_internal_format, |
| 16278 GLenum source_type, |
| 16279 GLenum dest_target, |
| 16280 GLint dest_level, |
16275 GLenum dest_internal_format) { | 16281 GLenum dest_internal_format) { |
16276 GLenum source_type = 0; | |
16277 GLenum source_internal_format = 0; | |
16278 Texture* source_texture = source_texture_ref->texture(); | |
16279 source_texture->GetLevelType(source_texture->target(), source_level, | |
16280 &source_type, &source_internal_format); | |
16281 | |
16282 bool valid_dest_format = false; | 16282 bool valid_dest_format = false; |
16283 // TODO(qiankun.miao@intel.com): ALPHA, LUMINANCE and LUMINANCE_ALPHA formats | 16283 // TODO(qiankun.miao@intel.com): ALPHA, LUMINANCE and LUMINANCE_ALPHA formats |
16284 // are not supported on GL core profile. See crbug.com/577144. Enable the | 16284 // are not supported on GL core profile. See crbug.com/577144. Enable the |
16285 // workaround for glCopyTexImage and glCopyTexSubImage in | 16285 // workaround for glCopyTexImage and glCopyTexSubImage in |
16286 // gles2_cmd_copy_tex_image.cc for glCopyTextureCHROMIUM implementation. | 16286 // gles2_cmd_copy_tex_image.cc for glCopyTextureCHROMIUM implementation. |
16287 switch (dest_internal_format) { | 16287 switch (dest_internal_format) { |
16288 case GL_RGB: | 16288 case GL_RGB: |
16289 case GL_RGBA: | 16289 case GL_RGBA: |
16290 case GL_RGB8: | 16290 case GL_RGB8: |
16291 case GL_RGBA8: | 16291 case GL_RGBA8: |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16365 | 16365 |
16366 // CopyTexImage* should not allow internalformat of GL_BGRA_EXT and | 16366 // CopyTexImage* should not allow internalformat of GL_BGRA_EXT and |
16367 // GL_BGRA8_EXT. crbug.com/663086. | 16367 // GL_BGRA8_EXT. crbug.com/663086. |
16368 bool copy_tex_image_format_valid = | 16368 bool copy_tex_image_format_valid = |
16369 source_internal_format != GL_BGRA_EXT && | 16369 source_internal_format != GL_BGRA_EXT && |
16370 dest_internal_format != GL_BGRA_EXT && | 16370 dest_internal_format != GL_BGRA_EXT && |
16371 source_internal_format != GL_BGRA8_EXT && | 16371 source_internal_format != GL_BGRA8_EXT && |
16372 dest_internal_format != GL_BGRA8_EXT && | 16372 dest_internal_format != GL_BGRA8_EXT && |
16373 ValidateCopyTexFormatHelper(dest_internal_format, source_internal_format, | 16373 ValidateCopyTexFormatHelper(dest_internal_format, source_internal_format, |
16374 source_type, &output_error_msg); | 16374 source_type, &output_error_msg); |
16375 if (source_format_color_renderable && copy_tex_image_format_valid) | 16375 |
| 16376 // TODO(qiankun.miao@intel.com): for WebGL 2.0 or OpenGL ES 3.0, both |
| 16377 // DIRECT_DRAW path for dest_level > 0 and DIRECT_COPY path for source_level > |
| 16378 // 0 are not available due to a framebuffer completeness bug: |
| 16379 // crbug.com/678526. Once the bug is fixed, the limitation for WebGL 2.0 and |
| 16380 // OpenGL ES 3.0 can be lifted. |
| 16381 // For WebGL 1.0 or OpenGL ES 2.0, DIRECT_DRAW path isn't available for |
| 16382 // dest_level > 0 due to level > 0 isn't supported by glFramebufferTexture2D |
| 16383 // in ES2 context. DIRECT_DRAW path isn't available for cube map dest texture |
| 16384 // either due to it may be cube map incomplete. Go to DRAW_AND_COPY path in |
| 16385 // these cases. |
| 16386 if (source_format_color_renderable && copy_tex_image_format_valid && |
| 16387 source_level == 0) |
16376 return DIRECT_COPY; | 16388 return DIRECT_COPY; |
16377 | 16389 if (dest_format_color_renderable && dest_level == 0 && |
16378 if (dest_format_color_renderable) | 16390 dest_target != GL_TEXTURE_CUBE_MAP) |
16379 return DIRECT_DRAW; | 16391 return DIRECT_DRAW; |
16380 | 16392 |
| 16393 // Draw to a fbo attaching level 0 of an intermediate texture, |
| 16394 // then copy from the fbo to dest texture level with glCopyTexImage2D. |
16381 return DRAW_AND_COPY; | 16395 return DRAW_AND_COPY; |
16382 } | 16396 } |
16383 | 16397 |
16384 bool GLES2DecoderImpl::ValidateCompressedCopyTextureCHROMIUM( | 16398 bool GLES2DecoderImpl::ValidateCompressedCopyTextureCHROMIUM( |
16385 const char* function_name, | 16399 const char* function_name, |
16386 TextureRef* source_texture_ref, | 16400 TextureRef* source_texture_ref, |
16387 TextureRef* dest_texture_ref) { | 16401 TextureRef* dest_texture_ref) { |
16388 if (!source_texture_ref || !dest_texture_ref) { | 16402 if (!source_texture_ref || !dest_texture_ref) { |
16389 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, "unknown texture id"); | 16403 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, "unknown texture id"); |
16390 return false; | 16404 return false; |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16468 &source_internal_format); | 16482 &source_internal_format); |
16469 GLenum format = | 16483 GLenum format = |
16470 TextureManager::ExtractFormatFromStorageFormat(internal_format); | 16484 TextureManager::ExtractFormatFromStorageFormat(internal_format); |
16471 if (!texture_manager()->ValidateTextureParameters( | 16485 if (!texture_manager()->ValidateTextureParameters( |
16472 GetErrorState(), kFunctionName, true, format, dest_type, | 16486 GetErrorState(), kFunctionName, true, format, dest_type, |
16473 internal_format, dest_level)) { | 16487 internal_format, dest_level)) { |
16474 return; | 16488 return; |
16475 } | 16489 } |
16476 | 16490 |
16477 CopyTextureMethod method = ValidateCopyTextureCHROMIUMInternalFormats( | 16491 CopyTextureMethod method = ValidateCopyTextureCHROMIUMInternalFormats( |
16478 kFunctionName, source_texture_ref, source_level, internal_format); | 16492 kFunctionName, source_level, source_internal_format, source_type, |
| 16493 dest_binding_target, dest_level, internal_format); |
16479 // INVALID_OPERATION is already generated by | 16494 // INVALID_OPERATION is already generated by |
16480 // ValidateCopyTextureCHROMIUMInternalFormats. | 16495 // ValidateCopyTextureCHROMIUMInternalFormats. |
16481 if (method == NOT_COPYABLE) { | 16496 if (method == NOT_COPYABLE) { |
16482 return; | 16497 return; |
16483 } | 16498 } |
16484 | 16499 |
16485 // Draw to a fbo attaching level 0 of an intermediate texture, | |
16486 // then copy from the fbo to dest texture level with glCopyTexImage2D. | |
16487 // For WebGL 1.0 or OpenGL ES 2.0, DIRECT_DRAW path isn't available for | |
16488 // dest_level > 0 due to level > 0 isn't supported by glFramebufferTexture2D | |
16489 // in ES2 context. DIRECT_DRAW path isn't available for cube map dest texture | |
16490 // either due to it may be cube map incomplete. Go to DRAW_AND_COPY path in | |
16491 // these cases. | |
16492 // TODO(qiankun.miao@intel.com): for WebGL 2.0 or OpenGL ES 3.0, both | |
16493 // DIRECT_DRAW path for dest_level > 0 and DIRECT_COPY path for source_level > | |
16494 // 0 are not available due to a framebuffer completeness bug: | |
16495 // crbug.com/678526. Once the bug is fixed, the limitation for WebGL 2.0 and | |
16496 // OpenGL ES 3.0 can be lifted. | |
16497 if (((dest_level > 0 || dest_binding_target == GL_TEXTURE_CUBE_MAP) && | |
16498 method == DIRECT_DRAW) || | |
16499 (source_level > 0 && method == DIRECT_COPY)) { | |
16500 method = DRAW_AND_COPY; | |
16501 } | |
16502 | |
16503 if (feature_info_->feature_flags().desktop_srgb_support) { | 16500 if (feature_info_->feature_flags().desktop_srgb_support) { |
16504 bool enable_framebuffer_srgb = | 16501 bool enable_framebuffer_srgb = |
16505 GLES2Util::GetColorEncodingFromInternalFormat(source_internal_format) == | 16502 GLES2Util::GetColorEncodingFromInternalFormat(source_internal_format) == |
16506 GL_SRGB || | 16503 GL_SRGB || |
16507 GLES2Util::GetColorEncodingFromInternalFormat(internal_format) == | 16504 GLES2Util::GetColorEncodingFromInternalFormat(internal_format) == |
16508 GL_SRGB; | 16505 GL_SRGB; |
16509 state_.EnableDisableFramebufferSRGB(enable_framebuffer_srgb); | 16506 state_.EnableDisableFramebufferSRGB(enable_framebuffer_srgb); |
16510 } | 16507 } |
16511 | 16508 |
16512 int source_width = 0; | 16509 int source_width = 0; |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16737 return; | 16734 return; |
16738 } | 16735 } |
16739 if (!dest_texture->ValidForTexture(dest_target, dest_level, xoffset, yoffset, | 16736 if (!dest_texture->ValidForTexture(dest_target, dest_level, xoffset, yoffset, |
16740 0, width, height, 1)) { | 16737 0, width, height, 1)) { |
16741 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, kFunctionName, | 16738 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, kFunctionName, |
16742 "destination texture bad dimensions."); | 16739 "destination texture bad dimensions."); |
16743 return; | 16740 return; |
16744 } | 16741 } |
16745 | 16742 |
16746 CopyTextureMethod method = ValidateCopyTextureCHROMIUMInternalFormats( | 16743 CopyTextureMethod method = ValidateCopyTextureCHROMIUMInternalFormats( |
16747 kFunctionName, source_texture_ref, source_level, dest_internal_format); | 16744 kFunctionName, source_level, source_internal_format, source_type, |
| 16745 dest_binding_target, dest_level, dest_internal_format); |
16748 // INVALID_OPERATION is already generated by | 16746 // INVALID_OPERATION is already generated by |
16749 // ValidateCopyTextureCHROMIUMInternalFormats. | 16747 // ValidateCopyTextureCHROMIUMInternalFormats. |
16750 if (method == NOT_COPYABLE) { | 16748 if (method == NOT_COPYABLE) { |
16751 return; | 16749 return; |
16752 } | 16750 } |
16753 | 16751 |
16754 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) | 16752 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) |
16755 // glDrawArrays is faster than glCopyTexSubImage2D on IA Mesa driver, | 16753 // glDrawArrays is faster than glCopyTexSubImage2D on IA Mesa driver, |
16756 // although opposite in Android. | 16754 // although opposite in Android. |
16757 // TODO(dshwang): After Mesa fixes this issue, remove this hack. | 16755 // TODO(dshwang): After Mesa fixes this issue, remove this hack. |
16758 // https://bugs.freedesktop.org/show_bug.cgi?id=98478, crbug.com/535198. | 16756 // https://bugs.freedesktop.org/show_bug.cgi?id=98478, crbug.com/535198. |
16759 if (Texture::ColorRenderable(GetFeatureInfo(), dest_internal_format, | 16757 if (Texture::ColorRenderable(GetFeatureInfo(), dest_internal_format, |
16760 dest_texture->IsImmutable()) && | 16758 dest_texture->IsImmutable()) && |
16761 method == DIRECT_COPY) { | 16759 method == DIRECT_COPY) { |
16762 method = DIRECT_DRAW; | 16760 method = DIRECT_DRAW; |
16763 } | 16761 } |
16764 #endif | 16762 #endif |
16765 | 16763 |
16766 // Draw to a fbo attaching level 0 of an intermediate texture, | |
16767 // then copy from the fbo to dest texture level with glCopyTexImage2D. | |
16768 // For WebGL 1.0 or OpenGL ES 2.0, DIRECT_DRAW path isn't available for | |
16769 // dest_level > 0 due to level > 0 isn't supported by glFramebufferTexture2D | |
16770 // in ES2 context. DIRECT_DRAW path isn't available for cube map dest texture | |
16771 // either due to it may be cube map incomplete. Go to DRAW_AND_COPY path in | |
16772 // these cases. | |
16773 // TODO(qiankun.miao@intel.com): for WebGL 2.0 or OpenGL ES 3.0, both | |
16774 // DIRECT_DRAW path for dest_level > 0 and DIRECT_COPY path for source_level > | |
16775 // 0 are not available due to a framebuffer completeness bug: | |
16776 // crbug.com/678526. Once the bug is fixed, the limitation for WebGL 2.0 and | |
16777 // OpenGL ES 3.0 can be lifted. | |
16778 if (((dest_level > 0 || dest_binding_target == GL_TEXTURE_CUBE_MAP) && | |
16779 method == DIRECT_DRAW) || | |
16780 (source_level > 0 && method == DIRECT_COPY)) { | |
16781 method = DRAW_AND_COPY; | |
16782 } | |
16783 | |
16784 if (feature_info_->feature_flags().desktop_srgb_support) { | 16764 if (feature_info_->feature_flags().desktop_srgb_support) { |
16785 bool enable_framebuffer_srgb = | 16765 bool enable_framebuffer_srgb = |
16786 GLES2Util::GetColorEncodingFromInternalFormat(source_internal_format) == | 16766 GLES2Util::GetColorEncodingFromInternalFormat(source_internal_format) == |
16787 GL_SRGB || | 16767 GL_SRGB || |
16788 GLES2Util::GetColorEncodingFromInternalFormat(dest_internal_format) == | 16768 GLES2Util::GetColorEncodingFromInternalFormat(dest_internal_format) == |
16789 GL_SRGB; | 16769 GL_SRGB; |
16790 state_.EnableDisableFramebufferSRGB(enable_framebuffer_srgb); | 16770 state_.EnableDisableFramebufferSRGB(enable_framebuffer_srgb); |
16791 } | 16771 } |
16792 | 16772 |
16793 // Clear the source texture if necessary. | 16773 // Clear the source texture if necessary. |
(...skipping 2516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
19310 } | 19290 } |
19311 | 19291 |
19312 // Include the auto-generated part of this file. We split this because it means | 19292 // Include the auto-generated part of this file. We split this because it means |
19313 // we can easily edit the non-auto generated parts right here in this file | 19293 // we can easily edit the non-auto generated parts right here in this file |
19314 // instead of having to edit some template or the code generator. | 19294 // instead of having to edit some template or the code generator. |
19315 #include "base/macros.h" | 19295 #include "base/macros.h" |
19316 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 19296 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
19317 | 19297 |
19318 } // namespace gles2 | 19298 } // namespace gles2 |
19319 } // namespace gpu | 19299 } // namespace gpu |
OLD | NEW |