Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: gpu/command_buffer/service/gles2_cmd_decoder.cc

Issue 2770113003: gpu: Fix AsyncSwapBuffer tracing. (Closed)
Patch Set: Remove queue. Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 FinishAsyncSwapBuffers(gfx::SwapResult result);
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
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 next_async_swap_id_ = 1;
2376 uint32_t pending_swaps_ = 0;
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
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 DCHECK_LT(pending_swaps_, 2u);
11891 uint32_t async_swap_id = next_async_swap_id_++;
11892 ++pending_swaps_;
11893 TRACE_EVENT_ASYNC_BEGIN0("gpu", "AsyncSwapBuffers", async_swap_id);
11894
11888 surface_->PostSubBufferAsync( 11895 surface_->PostSubBufferAsync(
11889 c.x, c.y, c.width, c.height, 11896 c.x, c.y, c.width, c.height,
11890 base::Bind(&GLES2DecoderImpl::FinishSwapBuffers, 11897 base::Bind(&GLES2DecoderImpl::FinishAsyncSwapBuffers,
11891 base::AsWeakPtr(this))); 11898 base::AsWeakPtr(this)));
11892 } else { 11899 } else {
11893 FinishSwapBuffers(surface_->PostSubBuffer(c.x, c.y, c.width, c.height)); 11900 FinishSwapBuffers(surface_->PostSubBuffer(c.x, c.y, c.width, c.height));
11894 } 11901 }
11895 11902
11896 return error::kNoError; 11903 return error::kNoError;
11897 } 11904 }
11898 11905
11899 error::Error GLES2DecoderImpl::HandleScheduleOverlayPlaneCHROMIUM( 11906 error::Error GLES2DecoderImpl::HandleScheduleOverlayPlaneCHROMIUM(
11900 uint32_t immediate_data_size, 11907 uint32_t immediate_data_size,
(...skipping 3597 matching lines...) Expand 10 before | Expand all | Expand 10 after
15498 offscreen_saved_color_texture_.get()); 15505 offscreen_saved_color_texture_.get());
15499 } 15506 }
15500 15507
15501 // Ensure the side effects of the copy are visible to the parent 15508 // 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 15509 // context. There is no need to do this for ANGLE because it uses a
15503 // single D3D device for all contexts. 15510 // single D3D device for all contexts.
15504 if (!gl_version_info().is_angle) 15511 if (!gl_version_info().is_angle)
15505 glFlush(); 15512 glFlush();
15506 } 15513 }
15507 } else if (supports_async_swap_) { 15514 } else if (supports_async_swap_) {
15508 TRACE_EVENT_ASYNC_BEGIN0("cc", "GLES2DecoderImpl::AsyncSwapBuffers", this); 15515 DCHECK_LT(pending_swaps_, 2u);
15509 surface_->SwapBuffersAsync(base::Bind(&GLES2DecoderImpl::FinishSwapBuffers, 15516 uint32_t async_swap_id = next_async_swap_id_++;
15510 base::AsWeakPtr(this))); 15517 ++pending_swaps_;
15518 TRACE_EVENT_ASYNC_BEGIN0("gpu", "AsyncSwapBuffers", async_swap_id);
15519
15520 surface_->SwapBuffersAsync(base::Bind(
15521 &GLES2DecoderImpl::FinishAsyncSwapBuffers, 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::FinishAsyncSwapBuffers(gfx::SwapResult result) {
15532 DCHECK(pending_swaps_);
reveman 2017/03/27 14:21:22 nit: DCHECK_NE(pending_swaps_, 0u)
Daniele Castagna 2017/03/27 16:11:10 Changed to DCHECK_NE(0u, pending_swaps_).
15533 uint32_t async_swap_id = next_async_swap_id_ - pending_swaps_;
15534 --pending_swaps_;
15535 TRACE_EVENT_ASYNC_END0("gpu", "AsyncSwapBuffers", async_swap_id);
15536
15537 FinishSwapBuffers(result);
15538 }
15539
15520 void GLES2DecoderImpl::FinishSwapBuffers(gfx::SwapResult result) { 15540 void GLES2DecoderImpl::FinishSwapBuffers(gfx::SwapResult result) {
15521 if (result == gfx::SwapResult::SWAP_FAILED) { 15541 if (result == gfx::SwapResult::SWAP_FAILED) {
15522 LOG(ERROR) << "Context lost because SwapBuffers failed."; 15542 LOG(ERROR) << "Context lost because SwapBuffers failed.";
15523 if (!CheckResetStatus()) { 15543 if (!CheckResetStatus()) {
15524 MarkContextLost(error::kUnknown); 15544 MarkContextLost(error::kUnknown);
15525 group_->LoseContexts(error::kUnknown); 15545 group_->LoseContexts(error::kUnknown);
15526 } 15546 }
15527 } 15547 }
15528 ++swaps_since_resize_; 15548 ++swaps_since_resize_;
15529 if (swaps_since_resize_ == 1 && surface_->BuffersFlipped()) { 15549 if (swaps_since_resize_ == 1 && surface_->BuffersFlipped()) {
15530 // The second buffer after a resize is new and needs to be cleared to 15550 // The second buffer after a resize is new and needs to be cleared to
15531 // known values. 15551 // known values.
15532 backbuffer_needs_clear_bits_ |= GL_COLOR_BUFFER_BIT; 15552 backbuffer_needs_clear_bits_ |= GL_COLOR_BUFFER_BIT;
15533 } 15553 }
15534
15535 if (supports_async_swap_) {
15536 TRACE_EVENT_ASYNC_END0("cc", "GLES2DecoderImpl::AsyncSwapBuffers", this);
15537 }
15538 } 15554 }
15539 15555
15540 void GLES2DecoderImpl::DoCommitOverlayPlanes() { 15556 void GLES2DecoderImpl::DoCommitOverlayPlanes() {
15541 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoCommitOverlayPlanes"); 15557 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoCommitOverlayPlanes");
15542 if (!supports_commit_overlay_planes_) { 15558 if (!supports_commit_overlay_planes_) {
15543 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glCommitOverlayPlanes", 15559 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glCommitOverlayPlanes",
15544 "command not supported by surface"); 15560 "command not supported by surface");
15545 return; 15561 return;
15546 } 15562 }
15547 ClearScheduleCALayerState(); 15563 ClearScheduleCALayerState();
(...skipping 3965 matching lines...) Expand 10 before | Expand all | Expand 10 after
19513 } 19529 }
19514 19530
19515 // Include the auto-generated part of this file. We split this because it means 19531 // 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 19532 // 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. 19533 // instead of having to edit some template or the code generator.
19518 #include "base/macros.h" 19534 #include "base/macros.h"
19519 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 19535 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
19520 19536
19521 } // namespace gles2 19537 } // namespace gles2
19522 } // namespace gpu 19538 } // namespace gpu
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698