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

Side by Side Diff: command_buffer/client/cross/cmd_buffer_helper.h

Issue 329046: Splits the command buffers into common commands... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/o3d/
Patch Set: '' Created 11 years, 1 month 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
OLDNEW
1 /* 1 /*
2 * Copyright 2009, Google Inc. 2 * Copyright 2009, Google Inc.
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 template <typename T> 163 template <typename T>
164 T& GetImmediateCmdSpace(size_t space) { 164 T& GetImmediateCmdSpace(size_t space) {
165 COMPILE_ASSERT(T::kArgFlags == cmd::kAtLeastN, Cmd_kArgFlags_not_kAtLeastN); 165 COMPILE_ASSERT(T::kArgFlags == cmd::kAtLeastN, Cmd_kArgFlags_not_kAtLeastN);
166 uint32 space_needed = ComputeNumEntries(sizeof(T) + space); 166 uint32 space_needed = ComputeNumEntries(sizeof(T) + space);
167 void* data = GetSpace(space_needed); 167 void* data = GetSpace(space_needed);
168 return *reinterpret_cast<T*>(data); 168 return *reinterpret_cast<T*>(data);
169 } 169 }
170 170
171 parse_error::ParseError GetParseError(); 171 parse_error::ParseError GetParseError();
172 172
173 // Common Commands
174 void Noop(uint32 skip_count) {
175 cmd::Noop& cmd = GetImmediateCmdSpace<cmd::Noop>(
176 skip_count * sizeof(CommandBufferEntry));
177 cmd.Init(skip_count);
178 }
179
180 void SetToken(uint32 token) {
181 cmd::SetToken& cmd = GetCmdSpace<cmd::SetToken>();
182 cmd.Init(token);
183 }
184
185
173 private: 186 private:
174 // Waits until get changes, updating the value of get_. 187 // Waits until get changes, updating the value of get_.
175 void WaitForGetChange(); 188 void WaitForGetChange();
176 189
177 // Returns the number of available entries (they may not be contiguous). 190 // Returns the number of available entries (they may not be contiguous).
178 int32 AvailableEntries() { 191 int32 AvailableEntries() {
179 return (get_ - put_ - 1 + entry_count_) % entry_count_; 192 return (get_ - put_ - 1 + entry_count_) % entry_count_;
180 } 193 }
181 194
182 NPP npp_; 195 NPP npp_;
183 gpu_plugin::NPObjectPointer<NPObject> command_buffer_; 196 gpu_plugin::NPObjectPointer<NPObject> command_buffer_;
184 gpu_plugin::NPObjectPointer<NPObject> ring_buffer_; 197 gpu_plugin::NPObjectPointer<NPObject> ring_buffer_;
185 CommandBufferEntry *entries_; 198 CommandBufferEntry *entries_;
186 int32 entry_count_; 199 int32 entry_count_;
187 int32 token_; 200 int32 token_;
188 int32 last_token_read_; 201 int32 last_token_read_;
189 int32 get_; 202 int32 get_;
190 int32 put_; 203 int32 put_;
191 204
192 friend class CommandBufferHelperTest; 205 friend class CommandBufferHelperTest;
193 DISALLOW_COPY_AND_ASSIGN(CommandBufferHelper); 206 DISALLOW_COPY_AND_ASSIGN(CommandBufferHelper);
194 }; 207 };
195 208
196 } // namespace command_buffer 209 } // namespace command_buffer
197 } // namespace o3d 210 } // namespace o3d
198 211
199 #endif // O3D_COMMAND_BUFFER_CLIENT_CROSS_CMD_BUFFER_HELPER_H_ 212 #endif // O3D_COMMAND_BUFFER_CLIENT_CROSS_CMD_BUFFER_HELPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698