| 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 1684 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1695 | 1695 |
| 1696 // Cached from ContextGroup | 1696 // Cached from ContextGroup |
| 1697 const Validators* validators_; | 1697 const Validators* validators_; |
| 1698 scoped_refptr<FeatureInfo> feature_info_; | 1698 scoped_refptr<FeatureInfo> feature_info_; |
| 1699 | 1699 |
| 1700 int frame_number_; | 1700 int frame_number_; |
| 1701 | 1701 |
| 1702 bool has_robustness_extension_; | 1702 bool has_robustness_extension_; |
| 1703 GLenum reset_status_; | 1703 GLenum reset_status_; |
| 1704 bool reset_by_robustness_extension_; | 1704 bool reset_by_robustness_extension_; |
| 1705 bool supports_post_sub_buffer_; |
| 1705 | 1706 |
| 1706 // These flags are used to override the state of the shared feature_info_ | 1707 // These flags are used to override the state of the shared feature_info_ |
| 1707 // member. Because the same FeatureInfo instance may be shared among many | 1708 // member. Because the same FeatureInfo instance may be shared among many |
| 1708 // contexts, the assumptions on the availablity of extensions in WebGL | 1709 // contexts, the assumptions on the availablity of extensions in WebGL |
| 1709 // contexts may be broken. These flags override the shared state to preserve | 1710 // contexts may be broken. These flags override the shared state to preserve |
| 1710 // WebGL semantics. | 1711 // WebGL semantics. |
| 1711 bool force_webgl_glsl_validation_; | 1712 bool force_webgl_glsl_validation_; |
| 1712 bool derivatives_explicitly_enabled_; | 1713 bool derivatives_explicitly_enabled_; |
| 1713 bool frag_depth_explicitly_enabled_; | 1714 bool frag_depth_explicitly_enabled_; |
| 1714 bool draw_buffers_explicitly_enabled_; | 1715 bool draw_buffers_explicitly_enabled_; |
| (...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2200 back_buffer_has_stencil_(false), | 2201 back_buffer_has_stencil_(false), |
| 2201 backbuffer_needs_clear_bits_(0), | 2202 backbuffer_needs_clear_bits_(0), |
| 2202 current_decoder_error_(error::kNoError), | 2203 current_decoder_error_(error::kNoError), |
| 2203 use_shader_translator_(true), | 2204 use_shader_translator_(true), |
| 2204 validators_(group_->feature_info()->validators()), | 2205 validators_(group_->feature_info()->validators()), |
| 2205 feature_info_(group_->feature_info()), | 2206 feature_info_(group_->feature_info()), |
| 2206 frame_number_(0), | 2207 frame_number_(0), |
| 2207 has_robustness_extension_(false), | 2208 has_robustness_extension_(false), |
| 2208 reset_status_(GL_NO_ERROR), | 2209 reset_status_(GL_NO_ERROR), |
| 2209 reset_by_robustness_extension_(false), | 2210 reset_by_robustness_extension_(false), |
| 2211 supports_post_sub_buffer_(false), |
| 2210 force_webgl_glsl_validation_(false), | 2212 force_webgl_glsl_validation_(false), |
| 2211 derivatives_explicitly_enabled_(false), | 2213 derivatives_explicitly_enabled_(false), |
| 2212 frag_depth_explicitly_enabled_(false), | 2214 frag_depth_explicitly_enabled_(false), |
| 2213 draw_buffers_explicitly_enabled_(false), | 2215 draw_buffers_explicitly_enabled_(false), |
| 2214 compile_shader_always_succeeds_(false), | 2216 compile_shader_always_succeeds_(false), |
| 2215 service_logging_(CommandLine::ForCurrentProcess()->HasSwitch( | 2217 service_logging_(CommandLine::ForCurrentProcess()->HasSwitch( |
| 2216 switches::kEnableGPUServiceLoggingGPU)), | 2218 switches::kEnableGPUServiceLoggingGPU)), |
| 2217 viewport_max_width_(0), | 2219 viewport_max_width_(0), |
| 2218 viewport_max_height_(0), | 2220 viewport_max_height_(0), |
| 2219 texture_state_(group_->feature_info() | 2221 texture_state_(group_->feature_info() |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2560 // because the system already clears the buffer before each draw. Proper | 2562 // because the system already clears the buffer before each draw. Proper |
| 2561 // fix might be setting the scissor clip properly before initialize. See | 2563 // fix might be setting the scissor clip properly before initialize. See |
| 2562 // crbug.com/259023 for details. | 2564 // crbug.com/259023 for details. |
| 2563 call_gl_clear = surface_->GetHandle(); | 2565 call_gl_clear = surface_->GetHandle(); |
| 2564 #endif | 2566 #endif |
| 2565 if (call_gl_clear) { | 2567 if (call_gl_clear) { |
| 2566 // Clear the backbuffer. | 2568 // Clear the backbuffer. |
| 2567 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); | 2569 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); |
| 2568 } | 2570 } |
| 2569 | 2571 |
| 2572 supports_post_sub_buffer_ = surface->SupportsPostSubBuffer(); |
| 2573 if (feature_info_->workarounds() |
| 2574 .disable_post_sub_buffers_for_onscreen_surfaces && |
| 2575 !surface->IsOffscreen()) |
| 2576 supports_post_sub_buffer_ = false; |
| 2577 |
| 2570 if (feature_info_->workarounds().reverse_point_sprite_coord_origin) { | 2578 if (feature_info_->workarounds().reverse_point_sprite_coord_origin) { |
| 2571 glPointParameteri(GL_POINT_SPRITE_COORD_ORIGIN, GL_LOWER_LEFT); | 2579 glPointParameteri(GL_POINT_SPRITE_COORD_ORIGIN, GL_LOWER_LEFT); |
| 2572 } | 2580 } |
| 2573 | 2581 |
| 2574 if (feature_info_->workarounds().unbind_fbo_on_context_switch) { | 2582 if (feature_info_->workarounds().unbind_fbo_on_context_switch) { |
| 2575 context_->SetUnbindFboOnMakeCurrent(); | 2583 context_->SetUnbindFboOnMakeCurrent(); |
| 2576 } | 2584 } |
| 2577 | 2585 |
| 2578 if (feature_info_->workarounds().release_image_after_use) { | 2586 if (feature_info_->workarounds().release_image_after_use) { |
| 2579 image_manager()->SetReleaseAfterUse(); | 2587 image_manager()->SetReleaseAfterUse(); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2612 caps.texture_usage = feature_info_->feature_flags().angle_texture_usage; | 2620 caps.texture_usage = feature_info_->feature_flags().angle_texture_usage; |
| 2613 caps.texture_storage = feature_info_->feature_flags().ext_texture_storage; | 2621 caps.texture_storage = feature_info_->feature_flags().ext_texture_storage; |
| 2614 caps.discard_framebuffer = | 2622 caps.discard_framebuffer = |
| 2615 feature_info_->feature_flags().ext_discard_framebuffer; | 2623 feature_info_->feature_flags().ext_discard_framebuffer; |
| 2616 | 2624 |
| 2617 #if defined(OS_MACOSX) | 2625 #if defined(OS_MACOSX) |
| 2618 // This is unconditionally true on mac, no need to test for it at runtime. | 2626 // This is unconditionally true on mac, no need to test for it at runtime. |
| 2619 caps.iosurface = true; | 2627 caps.iosurface = true; |
| 2620 #endif | 2628 #endif |
| 2621 | 2629 |
| 2622 caps.post_sub_buffer = surface_->HasExtension("GL_CHROMIUM_post_sub_buffer"); | 2630 caps.post_sub_buffer = supports_post_sub_buffer_; |
| 2623 | 2631 |
| 2624 return caps; | 2632 return caps; |
| 2625 } | 2633 } |
| 2626 | 2634 |
| 2627 void GLES2DecoderImpl::UpdateCapabilities() { | 2635 void GLES2DecoderImpl::UpdateCapabilities() { |
| 2628 util_.set_num_compressed_texture_formats( | 2636 util_.set_num_compressed_texture_formats( |
| 2629 validators_->compressed_texture_format.GetValues().size()); | 2637 validators_->compressed_texture_format.GetValues().size()); |
| 2630 util_.set_num_shader_binary_formats( | 2638 util_.set_num_shader_binary_formats( |
| 2631 validators_->shader_binary_format.GetValues().size()); | 2639 validators_->shader_binary_format.GetValues().size()); |
| 2632 } | 2640 } |
| (...skipping 4793 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7426 // Validation should have prevented us from getting here. | 7434 // Validation should have prevented us from getting here. |
| 7427 NOTREACHED(); | 7435 NOTREACHED(); |
| 7428 break; | 7436 break; |
| 7429 } | 7437 } |
| 7430 return error::kNoError; | 7438 return error::kNoError; |
| 7431 } | 7439 } |
| 7432 | 7440 |
| 7433 error::Error GLES2DecoderImpl::HandlePostSubBufferCHROMIUM( | 7441 error::Error GLES2DecoderImpl::HandlePostSubBufferCHROMIUM( |
| 7434 uint32 immediate_data_size, const cmds::PostSubBufferCHROMIUM& c) { | 7442 uint32 immediate_data_size, const cmds::PostSubBufferCHROMIUM& c) { |
| 7435 TRACE_EVENT0("gpu", "GLES2DecoderImpl::HandlePostSubBufferCHROMIUM"); | 7443 TRACE_EVENT0("gpu", "GLES2DecoderImpl::HandlePostSubBufferCHROMIUM"); |
| 7436 if (!surface_->HasExtension("GL_CHROMIUM_post_sub_buffer")) { | 7444 if (!supports_post_sub_buffer_) { |
| 7437 LOCAL_SET_GL_ERROR( | 7445 LOCAL_SET_GL_ERROR( |
| 7438 GL_INVALID_OPERATION, | 7446 GL_INVALID_OPERATION, |
| 7439 "glPostSubBufferCHROMIUM", "command not supported by surface"); | 7447 "glPostSubBufferCHROMIUM", "command not supported by surface"); |
| 7440 return error::kNoError; | 7448 return error::kNoError; |
| 7441 } | 7449 } |
| 7442 bool is_tracing; | 7450 bool is_tracing; |
| 7443 TRACE_EVENT_CATEGORY_GROUP_ENABLED(TRACE_DISABLED_BY_DEFAULT("gpu.debug"), | 7451 TRACE_EVENT_CATEGORY_GROUP_ENABLED(TRACE_DISABLED_BY_DEFAULT("gpu.debug"), |
| 7444 &is_tracing); | 7452 &is_tracing); |
| 7445 if (is_tracing) { | 7453 if (is_tracing) { |
| 7446 bool is_offscreen = !!offscreen_target_frame_buffer_.get(); | 7454 bool is_offscreen = !!offscreen_target_frame_buffer_.get(); |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7620 if (!draw_buffers_explicitly_enabled_) { | 7628 if (!draw_buffers_explicitly_enabled_) { |
| 7621 size_t offset = extensions.find(kEXTDrawBuffersExtension); | 7629 size_t offset = extensions.find(kEXTDrawBuffersExtension); |
| 7622 if (std::string::npos != offset) { | 7630 if (std::string::npos != offset) { |
| 7623 extensions.replace(offset, arraysize(kEXTDrawBuffersExtension), | 7631 extensions.replace(offset, arraysize(kEXTDrawBuffersExtension), |
| 7624 std::string()); | 7632 std::string()); |
| 7625 } | 7633 } |
| 7626 } | 7634 } |
| 7627 } else { | 7635 } else { |
| 7628 extensions = feature_info_->extensions().c_str(); | 7636 extensions = feature_info_->extensions().c_str(); |
| 7629 } | 7637 } |
| 7630 std::string surface_extensions = surface_->GetExtensions(); | 7638 if (supports_post_sub_buffer_) |
| 7631 if (!surface_extensions.empty()) | 7639 extensions += " GL_CHROMIUM_post_sub_buffer"; |
| 7632 extensions += " " + surface_extensions; | |
| 7633 str = extensions.c_str(); | 7640 str = extensions.c_str(); |
| 7634 } | 7641 } |
| 7635 break; | 7642 break; |
| 7636 default: | 7643 default: |
| 7637 break; | 7644 break; |
| 7638 } | 7645 } |
| 7639 Bucket* bucket = CreateBucket(c.bucket_id); | 7646 Bucket* bucket = CreateBucket(c.bucket_id); |
| 7640 bucket->SetFromString(str); | 7647 bucket->SetFromString(str); |
| 7641 return error::kNoError; | 7648 return error::kNoError; |
| 7642 } | 7649 } |
| (...skipping 2901 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10544 DoDidUseTexImageIfNeeded(texture, texture->target()); | 10551 DoDidUseTexImageIfNeeded(texture, texture->target()); |
| 10545 } | 10552 } |
| 10546 | 10553 |
| 10547 // Include the auto-generated part of this file. We split this because it means | 10554 // Include the auto-generated part of this file. We split this because it means |
| 10548 // we can easily edit the non-auto generated parts right here in this file | 10555 // we can easily edit the non-auto generated parts right here in this file |
| 10549 // instead of having to edit some template or the code generator. | 10556 // instead of having to edit some template or the code generator. |
| 10550 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 10557 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
| 10551 | 10558 |
| 10552 } // namespace gles2 | 10559 } // namespace gles2 |
| 10553 } // namespace gpu | 10560 } // namespace gpu |
| OLD | NEW |