Chromium Code Reviews| 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 908 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 919 GLint border); | 919 GLint border); |
| 920 | 920 |
| 921 // Wrapper for SwapBuffers. | 921 // Wrapper for SwapBuffers. |
| 922 void DoSwapBuffers(); | 922 void DoSwapBuffers(); |
| 923 | 923 |
| 924 // Wrapper for SwapBuffersWithBoundsCHROMIUM. | 924 // Wrapper for SwapBuffersWithBoundsCHROMIUM. |
| 925 void DoSwapBuffersWithBoundsCHROMIUM(GLsizei count, | 925 void DoSwapBuffersWithBoundsCHROMIUM(GLsizei count, |
| 926 const volatile GLint* rects); | 926 const volatile GLint* rects); |
| 927 | 927 |
| 928 // Callback for async SwapBuffers. | 928 // Callback for async SwapBuffers. |
| 929 void RegisterTraceAndFinishSwapBuffers(gfx::SwapResult result); | |
|
reveman
2017/03/24 06:35:09
how about FinishAsyncSwapBuffers?
Daniele Castagna
2017/03/24 06:51:24
Done.
| |
| 929 void FinishSwapBuffers(gfx::SwapResult result); | 930 void FinishSwapBuffers(gfx::SwapResult result); |
| 930 | 931 |
| 931 void DoCommitOverlayPlanes(); | 932 void DoCommitOverlayPlanes(); |
| 932 | 933 |
| 933 // Wrapper for SwapInterval. | 934 // Wrapper for SwapInterval. |
| 934 void DoSwapInterval(int interval); | 935 void DoSwapInterval(int interval); |
| 935 | 936 |
| 936 // Wrapper for CopyTexSubImage2D. | 937 // Wrapper for CopyTexSubImage2D. |
| 937 void DoCopyTexSubImage2D( | 938 void DoCopyTexSubImage2D( |
| 938 GLenum target, | 939 GLenum target, |
| (...skipping 1425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2364 int commands_to_process_; | 2365 int commands_to_process_; |
| 2365 | 2366 |
| 2366 bool has_robustness_extension_; | 2367 bool has_robustness_extension_; |
| 2367 error::ContextLostReason context_lost_reason_; | 2368 error::ContextLostReason context_lost_reason_; |
| 2368 bool context_was_lost_; | 2369 bool context_was_lost_; |
| 2369 bool reset_by_robustness_extension_; | 2370 bool reset_by_robustness_extension_; |
| 2370 bool supports_post_sub_buffer_; | 2371 bool supports_post_sub_buffer_; |
| 2371 bool supports_swap_buffers_with_bounds_; | 2372 bool supports_swap_buffers_with_bounds_; |
| 2372 bool supports_commit_overlay_planes_; | 2373 bool supports_commit_overlay_planes_; |
| 2373 bool supports_async_swap_; | 2374 bool supports_async_swap_; |
| 2375 uint32_t async_swap_id_ = 0; | |
|
reveman
2017/03/24 06:35:09
nit: next_async_swap_id_ = 1
Daniele Castagna
2017/03/24 06:51:24
Not sure why you prefer to start from 1, but done.
| |
| 2376 std::queue<uint32_t> pending_swaps_; | |
| 2374 bool supports_dc_layers_ = false; | 2377 bool supports_dc_layers_ = false; |
| 2375 | 2378 |
| 2376 // These flags are used to override the state of the shared feature_info_ | 2379 // These flags are used to override the state of the shared feature_info_ |
| 2377 // member. Because the same FeatureInfo instance may be shared among many | 2380 // member. Because the same FeatureInfo instance may be shared among many |
| 2378 // contexts, the assumptions on the availablity of extensions in WebGL | 2381 // contexts, the assumptions on the availablity of extensions in WebGL |
| 2379 // contexts may be broken. These flags override the shared state to preserve | 2382 // contexts may be broken. These flags override the shared state to preserve |
| 2380 // WebGL semantics. | 2383 // WebGL semantics. |
| 2381 bool derivatives_explicitly_enabled_; | 2384 bool derivatives_explicitly_enabled_; |
| 2382 bool frag_depth_explicitly_enabled_; | 2385 bool frag_depth_explicitly_enabled_; |
| 2383 bool draw_buffers_explicitly_enabled_; | 2386 bool draw_buffers_explicitly_enabled_; |
| (...skipping 9493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 11877 bool is_offscreen = !!offscreen_target_frame_buffer_.get(); | 11880 bool is_offscreen = !!offscreen_target_frame_buffer_.get(); |
| 11878 ScopedFramebufferBinder binder(this, GetBoundDrawFramebufferServiceId()); | 11881 ScopedFramebufferBinder binder(this, GetBoundDrawFramebufferServiceId()); |
| 11879 gpu_state_tracer_->TakeSnapshotWithCurrentFramebuffer( | 11882 gpu_state_tracer_->TakeSnapshotWithCurrentFramebuffer( |
| 11880 is_offscreen ? offscreen_size_ : surface_->GetSize()); | 11883 is_offscreen ? offscreen_size_ : surface_->GetSize()); |
| 11881 } | 11884 } |
| 11882 | 11885 |
| 11883 ClearScheduleCALayerState(); | 11886 ClearScheduleCALayerState(); |
| 11884 ClearScheduleDCLayerState(); | 11887 ClearScheduleDCLayerState(); |
| 11885 | 11888 |
| 11886 if (supports_async_swap_) { | 11889 if (supports_async_swap_) { |
| 11887 TRACE_EVENT_ASYNC_BEGIN0("cc", "GLES2DecoderImpl::AsyncSwapBuffers", this); | 11890 CHECK_LT(pending_swaps_.size(), 2); |
|
reveman
2017/03/24 06:35:09
nit: s/CHECK_LT/DCHECK_LT/
Daniele Castagna
2017/03/24 06:51:24
Done.
| |
| 11891 ++async_swap_id_; | |
|
reveman
2017/03/24 06:35:09
nit: uint32_t async_swap_id = next_async_swap_id_+
Daniele Castagna
2017/03/24 06:51:24
Done.
| |
| 11892 pending_swaps_.push(async_swap_id_); | |
| 11893 TRACE_EVENT_ASYNC_BEGIN0("gpu", "AsyncSwapBuffers", async_swap_id_); | |
| 11888 surface_->PostSubBufferAsync( | 11894 surface_->PostSubBufferAsync( |
| 11889 c.x, c.y, c.width, c.height, | 11895 c.x, c.y, c.width, c.height, |
| 11890 base::Bind(&GLES2DecoderImpl::FinishSwapBuffers, | 11896 base::Bind(&GLES2DecoderImpl::RegisterTraceAndFinishSwapBuffers, |
| 11891 base::AsWeakPtr(this))); | 11897 base::AsWeakPtr(this))); |
| 11892 } else { | 11898 } else { |
| 11893 FinishSwapBuffers(surface_->PostSubBuffer(c.x, c.y, c.width, c.height)); | 11899 FinishSwapBuffers(surface_->PostSubBuffer(c.x, c.y, c.width, c.height)); |
| 11894 } | 11900 } |
| 11895 | 11901 |
| 11896 return error::kNoError; | 11902 return error::kNoError; |
| 11897 } | 11903 } |
| 11898 | 11904 |
| 11899 error::Error GLES2DecoderImpl::HandleScheduleOverlayPlaneCHROMIUM( | 11905 error::Error GLES2DecoderImpl::HandleScheduleOverlayPlaneCHROMIUM( |
| 11900 uint32_t immediate_data_size, | 11906 uint32_t immediate_data_size, |
| (...skipping 3597 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 15498 offscreen_saved_color_texture_.get()); | 15504 offscreen_saved_color_texture_.get()); |
| 15499 } | 15505 } |
| 15500 | 15506 |
| 15501 // Ensure the side effects of the copy are visible to the parent | 15507 // Ensure the side effects of the copy are visible to the parent |
| 15502 // context. There is no need to do this for ANGLE because it uses a | 15508 // context. There is no need to do this for ANGLE because it uses a |
| 15503 // single D3D device for all contexts. | 15509 // single D3D device for all contexts. |
| 15504 if (!gl_version_info().is_angle) | 15510 if (!gl_version_info().is_angle) |
| 15505 glFlush(); | 15511 glFlush(); |
| 15506 } | 15512 } |
| 15507 } else if (supports_async_swap_) { | 15513 } else if (supports_async_swap_) { |
| 15508 TRACE_EVENT_ASYNC_BEGIN0("cc", "GLES2DecoderImpl::AsyncSwapBuffers", this); | 15514 CHECK_LT(pending_swaps_.size(), 2); |
|
reveman
2017/03/24 06:35:09
nit: s/CHECK_LT/DCHECK_LT/
Daniele Castagna
2017/03/24 06:51:24
Done.
| |
| 15509 surface_->SwapBuffersAsync(base::Bind(&GLES2DecoderImpl::FinishSwapBuffers, | 15515 ++async_swap_id_; |
|
reveman
2017/03/24 06:35:09
nit: uint32_t async_swap_id = next_async_swap_id_+
Daniele Castagna
2017/03/24 06:51:24
Done.
| |
| 15510 base::AsWeakPtr(this))); | 15516 pending_swaps_.push(async_swap_id_); |
| 15517 TRACE_EVENT_ASYNC_BEGIN0("gpu", "AsyncSwapBuffers", async_swap_id_); | |
| 15518 | |
| 15519 surface_->SwapBuffersAsync( | |
| 15520 base::Bind(&GLES2DecoderImpl::RegisterTraceAndFinishSwapBuffers, | |
| 15521 base::AsWeakPtr(this))); | |
| 15511 } else { | 15522 } else { |
| 15512 FinishSwapBuffers(surface_->SwapBuffers()); | 15523 FinishSwapBuffers(surface_->SwapBuffers()); |
| 15513 } | 15524 } |
| 15514 | 15525 |
| 15515 // This may be a slow command. Exit command processing to allow for | 15526 // This may be a slow command. Exit command processing to allow for |
| 15516 // context preemption and GPU watchdog checks. | 15527 // context preemption and GPU watchdog checks. |
| 15517 ExitCommandProcessingEarly(); | 15528 ExitCommandProcessingEarly(); |
| 15518 } | 15529 } |
| 15519 | 15530 |
| 15531 void GLES2DecoderImpl::RegisterTraceAndFinishSwapBuffers( | |
| 15532 gfx::SwapResult result) { | |
| 15533 DCHECK(!pending_swaps_.empty()); | |
| 15534 uint32_t oldest_swap_id = pending_swaps_.front(); | |
|
reveman
2017/03/24 06:35:10
nit: s/oldest_swap_id/async_swap_id/
Daniele Castagna
2017/03/24 06:51:24
Done.
| |
| 15535 pending_swaps_.pop(); | |
| 15536 TRACE_EVENT_ASYNC_END0("gpu", "AsyncSwapBuffers", oldest_swap_id); | |
| 15537 | |
| 15538 FinishSwapBuffers(result); | |
| 15539 } | |
| 15540 | |
| 15520 void GLES2DecoderImpl::FinishSwapBuffers(gfx::SwapResult result) { | 15541 void GLES2DecoderImpl::FinishSwapBuffers(gfx::SwapResult result) { |
| 15521 if (result == gfx::SwapResult::SWAP_FAILED) { | 15542 if (result == gfx::SwapResult::SWAP_FAILED) { |
| 15522 LOG(ERROR) << "Context lost because SwapBuffers failed."; | 15543 LOG(ERROR) << "Context lost because SwapBuffers failed."; |
| 15523 if (!CheckResetStatus()) { | 15544 if (!CheckResetStatus()) { |
| 15524 MarkContextLost(error::kUnknown); | 15545 MarkContextLost(error::kUnknown); |
| 15525 group_->LoseContexts(error::kUnknown); | 15546 group_->LoseContexts(error::kUnknown); |
| 15526 } | 15547 } |
| 15527 } | 15548 } |
| 15528 ++swaps_since_resize_; | 15549 ++swaps_since_resize_; |
| 15529 if (swaps_since_resize_ == 1 && surface_->BuffersFlipped()) { | 15550 if (swaps_since_resize_ == 1 && surface_->BuffersFlipped()) { |
| 15530 // The second buffer after a resize is new and needs to be cleared to | 15551 // The second buffer after a resize is new and needs to be cleared to |
| 15531 // known values. | 15552 // known values. |
| 15532 backbuffer_needs_clear_bits_ |= GL_COLOR_BUFFER_BIT; | 15553 backbuffer_needs_clear_bits_ |= GL_COLOR_BUFFER_BIT; |
| 15533 } | 15554 } |
| 15534 | |
| 15535 if (supports_async_swap_) { | |
| 15536 TRACE_EVENT_ASYNC_END0("cc", "GLES2DecoderImpl::AsyncSwapBuffers", this); | |
| 15537 } | |
| 15538 } | 15555 } |
| 15539 | 15556 |
| 15540 void GLES2DecoderImpl::DoCommitOverlayPlanes() { | 15557 void GLES2DecoderImpl::DoCommitOverlayPlanes() { |
| 15541 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoCommitOverlayPlanes"); | 15558 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoCommitOverlayPlanes"); |
| 15542 if (!supports_commit_overlay_planes_) { | 15559 if (!supports_commit_overlay_planes_) { |
| 15543 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glCommitOverlayPlanes", | 15560 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glCommitOverlayPlanes", |
| 15544 "command not supported by surface"); | 15561 "command not supported by surface"); |
| 15545 return; | 15562 return; |
| 15546 } | 15563 } |
| 15547 ClearScheduleCALayerState(); | 15564 ClearScheduleCALayerState(); |
| (...skipping 3965 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 19513 } | 19530 } |
| 19514 | 19531 |
| 19515 // Include the auto-generated part of this file. We split this because it means | 19532 // Include the auto-generated part of this file. We split this because it means |
| 19516 // we can easily edit the non-auto generated parts right here in this file | 19533 // we can easily edit the non-auto generated parts right here in this file |
| 19517 // instead of having to edit some template or the code generator. | 19534 // instead of having to edit some template or the code generator. |
| 19518 #include "base/macros.h" | 19535 #include "base/macros.h" |
| 19519 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 19536 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
| 19520 | 19537 |
| 19521 } // namespace gles2 | 19538 } // namespace gles2 |
| 19522 } // namespace gpu | 19539 } // namespace gpu |
| OLD | NEW |