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

Side by Side Diff: gpu/command_buffer/client/cmd_buffer_helper.cc

Issue 1697002: Added facility to stub log and check. It is still not ideal but workable. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 10 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | gpu/command_buffer/common/logging.h » ('j') | 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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 // This file contains the implementation of the command buffer helper class. 5 // This file contains the implementation of the command buffer helper class.
6 6
7 #include "../client/cmd_buffer_helper.h" 7 #include "../client/cmd_buffer_helper.h"
8 #include "../common/command_buffer.h" 8 #include "../common/command_buffer.h"
9 9
10 namespace gpu { 10 namespace gpu {
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 // in argument. 76 // in argument.
77 void CommandBufferHelper::WaitForToken(int32 token) { 77 void CommandBufferHelper::WaitForToken(int32 token) {
78 // Return immediately if corresponding InsertToken failed. 78 // Return immediately if corresponding InsertToken failed.
79 if (token < 0) 79 if (token < 0)
80 return; 80 return;
81 if (last_token_read_ >= token) return; // fast path. 81 if (last_token_read_ >= token) return; // fast path.
82 if (token > token_) return; // we wrapped 82 if (token > token_) return; // we wrapped
83 Flush(); 83 Flush();
84 while (last_token_read_ < token) { 84 while (last_token_read_ < token) {
85 if (get_ == put_) { 85 if (get_ == put_) {
86 GPU_LOG(FATAL) << "Empty command buffer while waiting on a token."; 86 LOG(FATAL) << "Empty command buffer while waiting on a token.";
87 return; 87 return;
88 } 88 }
89 // Do not loop forever if the flush fails, meaning the command buffer reader 89 // Do not loop forever if the flush fails, meaning the command buffer reader
90 // has shutdown. 90 // has shutdown.
91 if (!Flush()) 91 if (!Flush())
92 return; 92 return;
93 } 93 }
94 } 94 }
95 95
96 // Waits for available entries, basically waiting until get >= put + count + 1. 96 // Waits for available entries, basically waiting until get >= put + count + 1.
97 // It actually waits for contiguous entries, so it may need to wrap the buffer 97 // It actually waits for contiguous entries, so it may need to wrap the buffer
98 // around, adding noops. Thus this function may change the value of put_. 98 // around, adding noops. Thus this function may change the value of put_.
99 // The function will return early if an error occurs, in which case the 99 // The function will return early if an error occurs, in which case the
100 // available space may not be available. 100 // available space may not be available.
101 void CommandBufferHelper::WaitForAvailableEntries(int32 count) { 101 void CommandBufferHelper::WaitForAvailableEntries(int32 count) {
102 GPU_CHECK(count < entry_count_); 102 CHECK(count < entry_count_);
103 if (put_ + count > entry_count_) { 103 if (put_ + count > entry_count_) {
104 // There's not enough room between the current put and the end of the 104 // There's not enough room between the current put and the end of the
105 // buffer, so we need to wrap. We will add noops all the way to the end, 105 // buffer, so we need to wrap. We will add noops all the way to the end,
106 // but we need to make sure get wraps first, actually that get is 1 or 106 // but we need to make sure get wraps first, actually that get is 1 or
107 // more (since put will wrap to 0 after we add the noops). 107 // more (since put will wrap to 0 after we add the noops).
108 DCHECK_LE(1, put_); 108 DCHECK_LE(1, put_);
109 Flush(); 109 Flush();
110 while (get_ > put_ || get_ == 0) { 110 while (get_ > put_ || get_ == 0) {
111 // Do not loop forever if the flush fails, meaning the command buffer 111 // Do not loop forever if the flush fails, meaning the command buffer
112 // reader has shutdown. 112 // reader has shutdown.
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 SynchronizeState(state); 151 SynchronizeState(state);
152 return static_cast<error::Error>(state.error); 152 return static_cast<error::Error>(state.error);
153 } 153 }
154 154
155 void CommandBufferHelper::SynchronizeState(CommandBuffer::State state) { 155 void CommandBufferHelper::SynchronizeState(CommandBuffer::State state) {
156 get_ = state.get_offset; 156 get_ = state.get_offset;
157 last_token_read_ = state.token; 157 last_token_read_ = state.token;
158 } 158 }
159 159
160 } // namespace gpu 160 } // namespace gpu
OLDNEW
« no previous file with comments | « no previous file | gpu/command_buffer/common/logging.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698