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 1959 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1970 | 1970 |
1971 // copyTexImage2D doesn't work on OSX under very specific conditions. | 1971 // copyTexImage2D doesn't work on OSX under very specific conditions. |
1972 // Returns whether those conditions have been met. If this method returns | 1972 // Returns whether those conditions have been met. If this method returns |
1973 // true, |source_texture_service_id| and |source_texture_target| are also | 1973 // true, |source_texture_service_id| and |source_texture_target| are also |
1974 // populated, since they are needed to implement the workaround. | 1974 // populated, since they are needed to implement the workaround. |
1975 bool NeedsCopyTextureImageWorkaround(GLenum internal_format, | 1975 bool NeedsCopyTextureImageWorkaround(GLenum internal_format, |
1976 int32_t channels_exist, | 1976 int32_t channels_exist, |
1977 GLuint* source_texture_service_id, | 1977 GLuint* source_texture_service_id, |
1978 GLenum* source_texture_target); | 1978 GLenum* source_texture_target); |
1979 | 1979 |
1980 // On Mac OS X, calling glReadPixels() against an FBO whose color attachment | |
1981 // is an IOSurface-backed texture causes corruption of future glReadPixels() | |
1982 // calls, even those on different OpenGL contexts. It is believed that this | |
1983 // is the root cause of top crasher | |
1984 // http://crbug.com/99393. <rdar://problem/10949687> | |
1985 bool NeedsIOSurfaceReadbackWorkaround(); | |
1986 | |
1987 bool InitializeCopyTextureCHROMIUM(const char* function_name); | 1980 bool InitializeCopyTextureCHROMIUM(const char* function_name); |
1988 // Generate a member function prototype for each command in an automated and | 1981 // Generate a member function prototype for each command in an automated and |
1989 // typesafe way. | 1982 // typesafe way. |
1990 #define GLES2_CMD_OP(name) \ | 1983 #define GLES2_CMD_OP(name) \ |
1991 Error Handle##name(uint32_t immediate_data_size, const void* data); | 1984 Error Handle##name(uint32_t immediate_data_size, const void* data); |
1992 | 1985 |
1993 GLES2_COMMAND_LIST(GLES2_CMD_OP) | 1986 GLES2_COMMAND_LIST(GLES2_CMD_OP) |
1994 | 1987 |
1995 #undef GLES2_CMD_OP | 1988 #undef GLES2_CMD_OP |
1996 | 1989 |
(...skipping 1481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3478 | 3471 |
3479 int driver_bug_workarounds = 0; | 3472 int driver_bug_workarounds = 0; |
3480 if (workarounds().needs_glsl_built_in_function_emulation) | 3473 if (workarounds().needs_glsl_built_in_function_emulation) |
3481 driver_bug_workarounds |= SH_EMULATE_BUILT_IN_FUNCTIONS; | 3474 driver_bug_workarounds |= SH_EMULATE_BUILT_IN_FUNCTIONS; |
3482 if (workarounds().init_gl_position_in_vertex_shader) | 3475 if (workarounds().init_gl_position_in_vertex_shader) |
3483 driver_bug_workarounds |= SH_INIT_GL_POSITION; | 3476 driver_bug_workarounds |= SH_INIT_GL_POSITION; |
3484 if (workarounds().unfold_short_circuit_as_ternary_operation) | 3477 if (workarounds().unfold_short_circuit_as_ternary_operation) |
3485 driver_bug_workarounds |= SH_UNFOLD_SHORT_CIRCUIT; | 3478 driver_bug_workarounds |= SH_UNFOLD_SHORT_CIRCUIT; |
3486 if (workarounds().init_varyings_without_static_use) | 3479 if (workarounds().init_varyings_without_static_use) |
3487 driver_bug_workarounds |= SH_INIT_VARYINGS_WITHOUT_STATIC_USE; | 3480 driver_bug_workarounds |= SH_INIT_VARYINGS_WITHOUT_STATIC_USE; |
3488 if (workarounds().unroll_for_loop_with_sampler_array_index) | |
3489 driver_bug_workarounds |= SH_UNROLL_FOR_LOOP_WITH_SAMPLER_ARRAY_INDEX; | |
3490 if (workarounds().scalarize_vec_and_mat_constructor_args) | 3481 if (workarounds().scalarize_vec_and_mat_constructor_args) |
3491 driver_bug_workarounds |= SH_SCALARIZE_VEC_AND_MAT_CONSTRUCTOR_ARGS; | 3482 driver_bug_workarounds |= SH_SCALARIZE_VEC_AND_MAT_CONSTRUCTOR_ARGS; |
3492 if (workarounds().regenerate_struct_names) | 3483 if (workarounds().regenerate_struct_names) |
3493 driver_bug_workarounds |= SH_REGENERATE_STRUCT_NAMES; | 3484 driver_bug_workarounds |= SH_REGENERATE_STRUCT_NAMES; |
3494 if (workarounds().remove_pow_with_constant_exponent) | 3485 if (workarounds().remove_pow_with_constant_exponent) |
3495 driver_bug_workarounds |= SH_REMOVE_POW_WITH_CONSTANT_EXPONENT; | 3486 driver_bug_workarounds |= SH_REMOVE_POW_WITH_CONSTANT_EXPONENT; |
3496 | 3487 |
3497 resources.WEBGL_debug_shader_precision = | 3488 resources.WEBGL_debug_shader_precision = |
3498 group_->gpu_preferences().emulate_shader_precision; | 3489 group_->gpu_preferences().emulate_shader_precision; |
3499 | 3490 |
(...skipping 6517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10017 if (!SafeAddInt32(x, width, &max_x) || !SafeAddInt32(y, height, &max_y)) { | 10008 if (!SafeAddInt32(x, width, &max_x) || !SafeAddInt32(y, height, &max_y)) { |
10018 LOCAL_SET_GL_ERROR( | 10009 LOCAL_SET_GL_ERROR( |
10019 GL_INVALID_VALUE, "glReadPixels", "dimensions out of range"); | 10010 GL_INVALID_VALUE, "glReadPixels", "dimensions out of range"); |
10020 return error::kNoError; | 10011 return error::kNoError; |
10021 } | 10012 } |
10022 | 10013 |
10023 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glReadPixels"); | 10014 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glReadPixels"); |
10024 | 10015 |
10025 ScopedResolvedFrameBufferBinder binder(this, false, true); | 10016 ScopedResolvedFrameBufferBinder binder(this, false, true); |
10026 std::unique_ptr<ScopedFrameBufferReadPixelHelper> helper; | 10017 std::unique_ptr<ScopedFrameBufferReadPixelHelper> helper; |
10027 if (NeedsIOSurfaceReadbackWorkaround()) | |
10028 helper.reset(new ScopedFrameBufferReadPixelHelper(&state_, this)); | |
10029 | 10018 |
10030 gfx::Rect rect(x, y, width, height); // Safe before we checked above. | 10019 gfx::Rect rect(x, y, width, height); // Safe before we checked above. |
10031 gfx::Rect max_rect(max_size); | 10020 gfx::Rect max_rect(max_size); |
10032 if (!max_rect.Contains(rect)) { | 10021 if (!max_rect.Contains(rect)) { |
10033 rect.Intersect(max_rect); | 10022 rect.Intersect(max_rect); |
10034 if (!rect.IsEmpty()) { | 10023 if (!rect.IsEmpty()) { |
10035 if (y < 0) { | 10024 if (y < 0) { |
10036 pixels += static_cast<uint32_t>(-y) * padded_row_size;; | 10025 pixels += static_cast<uint32_t>(-y) * padded_row_size;; |
10037 } | 10026 } |
10038 if (x < 0) { | 10027 if (x < 0) { |
(...skipping 6565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16604 // The workaround only works if the source texture consists of the channels | 16593 // The workaround only works if the source texture consists of the channels |
16605 // kRGB or kRGBA. | 16594 // kRGB or kRGBA. |
16606 if (channels_exist != GLES2Util::kRGBA && channels_exist != GLES2Util::kRGB) | 16595 if (channels_exist != GLES2Util::kRGBA && channels_exist != GLES2Util::kRGB) |
16607 return false; | 16596 return false; |
16608 | 16597 |
16609 *source_texture_target = texture->texture()->target(); | 16598 *source_texture_target = texture->texture()->target(); |
16610 *source_texture_service_id = texture->service_id(); | 16599 *source_texture_service_id = texture->service_id(); |
16611 return true; | 16600 return true; |
16612 } | 16601 } |
16613 | 16602 |
16614 bool GLES2DecoderImpl::NeedsIOSurfaceReadbackWorkaround() { | |
16615 if (!workarounds().iosurface_readback_workaround) | |
16616 return false; | |
16617 | |
16618 Framebuffer* framebuffer = | |
16619 GetFramebufferInfoForTarget(GL_READ_FRAMEBUFFER_EXT); | |
16620 if (!framebuffer) | |
16621 return false; | |
16622 | |
16623 const Framebuffer::Attachment* attachment = | |
16624 framebuffer->GetReadBufferAttachment(); | |
16625 if (!attachment) | |
16626 return false; | |
16627 | |
16628 if (!attachment->IsTextureAttachment()) | |
16629 return false; | |
16630 | |
16631 TextureRef* texture = | |
16632 texture_manager()->GetTexture(attachment->object_name()); | |
16633 return texture->texture()->HasImages(); | |
16634 } | |
16635 | |
16636 error::Error GLES2DecoderImpl::HandleBindFragmentInputLocationCHROMIUMBucket( | 16603 error::Error GLES2DecoderImpl::HandleBindFragmentInputLocationCHROMIUMBucket( |
16637 uint32_t immediate_data_size, | 16604 uint32_t immediate_data_size, |
16638 const void* cmd_data) { | 16605 const void* cmd_data) { |
16639 const gles2::cmds::BindFragmentInputLocationCHROMIUMBucket& c = | 16606 const gles2::cmds::BindFragmentInputLocationCHROMIUMBucket& c = |
16640 *static_cast<const gles2::cmds::BindFragmentInputLocationCHROMIUMBucket*>( | 16607 *static_cast<const gles2::cmds::BindFragmentInputLocationCHROMIUMBucket*>( |
16641 cmd_data); | 16608 cmd_data); |
16642 if (!features().chromium_path_rendering) { | 16609 if (!features().chromium_path_rendering) { |
16643 return error::kUnknownCommand; | 16610 return error::kUnknownCommand; |
16644 } | 16611 } |
16645 | 16612 |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16789 } | 16756 } |
16790 | 16757 |
16791 // Include the auto-generated part of this file. We split this because it means | 16758 // Include the auto-generated part of this file. We split this because it means |
16792 // we can easily edit the non-auto generated parts right here in this file | 16759 // we can easily edit the non-auto generated parts right here in this file |
16793 // instead of having to edit some template or the code generator. | 16760 // instead of having to edit some template or the code generator. |
16794 #include "base/macros.h" | 16761 #include "base/macros.h" |
16795 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 16762 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
16796 | 16763 |
16797 } // namespace gles2 | 16764 } // namespace gles2 |
16798 } // namespace gpu | 16765 } // namespace gpu |
OLD | NEW |