OLD | NEW |
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 #ifndef GPU_COMMAND_BUFFER_SERVICE_COMMON_DECODER_H_ | 5 #ifndef GPU_COMMAND_BUFFER_SERVICE_COMMON_DECODER_H_ |
6 #define GPU_COMMAND_BUFFER_SERVICE_COMMON_DECODER_H_ | 6 #define GPU_COMMAND_BUFFER_SERVICE_COMMON_DECODER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
| 9 #include <stack> |
9 #include "base/linked_ptr.h" | 10 #include "base/linked_ptr.h" |
10 #include "base/scoped_ptr.h" | 11 #include "base/scoped_ptr.h" |
11 #include "gpu/command_buffer/service/cmd_parser.h" | 12 #include "gpu/command_buffer/service/cmd_parser.h" |
12 | 13 |
13 namespace gpu { | 14 namespace gpu { |
14 | 15 |
15 class CommandBufferEngine; | 16 class CommandBufferEngine; |
16 | 17 |
17 // This class is a helper base class for implementing the common parts of the | 18 // This class is a helper base class for implementing the common parts of the |
18 // o3d/gl2 command buffer decoder. | 19 // o3d/gl2 command buffer decoder. |
19 class CommonDecoder : public AsyncAPIInterface { | 20 class CommonDecoder : public AsyncAPIInterface { |
20 public: | 21 public: |
21 typedef parse_error::ParseError ParseError; | 22 typedef parse_error::ParseError ParseError; |
22 | 23 |
| 24 static const unsigned int kMaxStackDepth = 32; |
| 25 |
23 // A bucket is a buffer to help collect memory across a command buffer. When | 26 // A bucket is a buffer to help collect memory across a command buffer. When |
24 // creating a command buffer implementation of an existing API, sometimes that | 27 // creating a command buffer implementation of an existing API, sometimes that |
25 // API has functions that take a pointer to data. A good example is OpenGL's | 28 // API has functions that take a pointer to data. A good example is OpenGL's |
26 // glBufferData. Because the data is separated between client and service, | 29 // glBufferData. Because the data is separated between client and service, |
27 // there are 2 ways to get this data across. 1 is to put all the data in | 30 // there are 2 ways to get this data across. 1 is to put all the data in |
28 // shared memory. The problem with this is the data can be arbitarily large | 31 // shared memory. The problem with this is the data can be arbitarily large |
29 // and the host OS may not support that much shared memory. Another solution | 32 // and the host OS may not support that much shared memory. Another solution |
30 // is to shuffle memory across a little bit at a time, collecting it on the | 33 // is to shuffle memory across a little bit at a time, collecting it on the |
31 // service side and when it is all there then call glBufferData. Buckets | 34 // service side and when it is all there then call glBufferData. Buckets |
32 // implement this second solution. Using the common commands, SetBucketSize, | 35 // implement this second solution. Using the common commands, SetBucketSize, |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 // typesafe way. | 139 // typesafe way. |
137 #define COMMON_COMMAND_BUFFER_CMD_OP(name) \ | 140 #define COMMON_COMMAND_BUFFER_CMD_OP(name) \ |
138 parse_error::ParseError Handle ## name( \ | 141 parse_error::ParseError Handle ## name( \ |
139 uint32 immediate_data_size, \ | 142 uint32 immediate_data_size, \ |
140 const cmd::name& args); \ | 143 const cmd::name& args); \ |
141 | 144 |
142 COMMON_COMMAND_BUFFER_CMDS(COMMON_COMMAND_BUFFER_CMD_OP) | 145 COMMON_COMMAND_BUFFER_CMDS(COMMON_COMMAND_BUFFER_CMD_OP) |
143 | 146 |
144 #undef COMMON_COMMAND_BUFFER_CMD_OP | 147 #undef COMMON_COMMAND_BUFFER_CMD_OP |
145 | 148 |
| 149 // Pushes an address on the call stack. |
| 150 bool PushAddress(uint32 offset); |
| 151 |
146 CommandBufferEngine* engine_; | 152 CommandBufferEngine* engine_; |
147 | 153 |
148 typedef std::map<uint32, linked_ptr<Bucket> > BucketMap; | 154 typedef std::map<uint32, linked_ptr<Bucket> > BucketMap; |
149 BucketMap buckets_; | 155 BucketMap buckets_; |
| 156 |
| 157 // The value put on the call stack. |
| 158 struct CommandAddress { |
| 159 explicit CommandAddress(uint32 _offset) |
| 160 : offset(_offset) { |
| 161 } |
| 162 |
| 163 uint32 offset; |
| 164 }; |
| 165 std::stack<CommandAddress> call_stack_; |
150 }; | 166 }; |
151 | 167 |
152 } // namespace gpu | 168 } // namespace gpu |
153 | 169 |
154 #endif // GPU_COMMAND_BUFFER_SERVICE_COMMON_DECODER_H_ | 170 #endif // GPU_COMMAND_BUFFER_SERVICE_COMMON_DECODER_H_ |
155 | 171 |
OLD | NEW |