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

Side by Side Diff: gpu/command_buffer/client/gles2_implementation.h

Issue 1796002: Changes the GLES2Implementation to use a RingBuffer... (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/client/gles2_implementation.cc » ('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 #ifndef GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_H_ 5 #ifndef GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_H_
6 #define GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_H_ 6 #define GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 #include "../common/gles2_cmd_utils.h" 11 #include "../common/gles2_cmd_utils.h"
12 #include "../common/scoped_ptr.h" 12 #include "../common/scoped_ptr.h"
13 #include "../client/gles2_cmd_helper.h" 13 #include "../client/gles2_cmd_helper.h"
14 #include "../client/id_allocator.h" 14 #include "../client/id_allocator.h"
15 #include "../client/fenced_allocator.h" 15 #include "../client/ring_buffer.h"
16 16
17 #define GLES2_SUPPORT_CLIENT_SIDE_BUFFERS 1 17 #define GLES2_SUPPORT_CLIENT_SIDE_BUFFERS 1
18 18
19 namespace gpu { 19 namespace gpu {
20 namespace gles2 { 20 namespace gles2 {
21 21
22 class ClientSideBufferHelper; 22 class ClientSideBufferHelper;
23 23
24 // This class emulates GLES2 over command buffers. It can be used by a client 24 // This class emulates GLES2 over command buffers. It can be used by a client
25 // program so that the program does not need deal with shared memory and command 25 // program so that the program does not need deal with shared memory and command
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 132
133 GLuint MakeTextureId() { 133 GLuint MakeTextureId() {
134 return texture_id_allocator_.AllocateID(); 134 return texture_id_allocator_.AllocateID();
135 } 135 }
136 136
137 void FreeTextureId(GLuint id) { 137 void FreeTextureId(GLuint id) {
138 texture_id_allocator_.FreeID(id); 138 texture_id_allocator_.FreeID(id);
139 } 139 }
140 140
141 private: 141 private:
142 // Wraps FencedAllocatorWrapper to provide aligned allocations. 142 // Wraps RingBufferWrapper to provide aligned allocations.
143 class AlignedFencedAllocator : public FencedAllocatorWrapper { 143 class AlignedRingBuffer : public RingBufferWrapper {
144 public: 144 public:
145 AlignedFencedAllocator(unsigned int size, 145 AlignedRingBuffer(RingBuffer::Offset base_offset,
146 CommandBufferHelper *helper, 146 unsigned int size,
147 void *base) 147 CommandBufferHelper *helper,
148 : FencedAllocatorWrapper(size, helper, base) { 148 void *base)
149 : RingBufferWrapper(base_offset, size, helper, base) {
149 } 150 }
150 151
151 static unsigned int RoundToAlignment(unsigned int size) { 152 static unsigned int RoundToAlignment(unsigned int size) {
152 return (size + kAlignment - 1) & ~(kAlignment - 1); 153 return (size + kAlignment - 1) & ~(kAlignment - 1);
153 } 154 }
154 155
155 // Overrriden from FencedAllocatorWrapper 156 // Overrriden from RingBufferWrapper
156 void *Alloc(unsigned int size) { 157 void *Alloc(unsigned int size) {
157 return FencedAllocatorWrapper::Alloc(RoundToAlignment(size)); 158 return RingBufferWrapper::Alloc(RoundToAlignment(size));
158 } 159 }
159 160
160 // Overrriden from FencedAllocatorWrapper 161 // Overrriden from RingBufferWrapper
161 template <typename T> T *AllocTyped(unsigned int count) { 162 template <typename T> T *AllocTyped(unsigned int count) {
162 return static_cast<T *>(Alloc(count * sizeof(T))); 163 return static_cast<T *>(Alloc(count * sizeof(T)));
163 } 164 }
164 }; 165 };
165 166
166 // Gets the shared memory id for the result buffer. 167 // Gets the shared memory id for the result buffer.
167 uint32 result_shm_id() const { 168 uint32 result_shm_id() const {
168 return transfer_buffer_id_; 169 return transfer_buffer_id_;
169 } 170 }
170 171
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 GLuint buffer_id, GLsizei count, GLenum type, GLuint offset); 224 GLuint buffer_id, GLsizei count, GLenum type, GLuint offset);
224 #endif 225 #endif
225 226
226 GLES2Util util_; 227 GLES2Util util_;
227 GLES2CmdHelper* helper_; 228 GLES2CmdHelper* helper_;
228 IdAllocator buffer_id_allocator_; 229 IdAllocator buffer_id_allocator_;
229 IdAllocator framebuffer_id_allocator_; 230 IdAllocator framebuffer_id_allocator_;
230 IdAllocator renderbuffer_id_allocator_; 231 IdAllocator renderbuffer_id_allocator_;
231 IdAllocator program_and_shader_id_allocator_; 232 IdAllocator program_and_shader_id_allocator_;
232 IdAllocator texture_id_allocator_; 233 IdAllocator texture_id_allocator_;
233 AlignedFencedAllocator transfer_buffer_; 234 AlignedRingBuffer transfer_buffer_;
234 int transfer_buffer_id_; 235 int transfer_buffer_id_;
235 void* result_buffer_; 236 void* result_buffer_;
236 uint32 result_shm_offset_; 237 uint32 result_shm_offset_;
237 238
238 // pack alignment as last set by glPixelStorei 239 // pack alignment as last set by glPixelStorei
239 GLint pack_alignment_; 240 GLint pack_alignment_;
240 241
241 // unpack alignment as last set by glPixelStorei 242 // unpack alignment as last set by glPixelStorei
242 GLint unpack_alignment_; 243 GLint unpack_alignment_;
243 244
(...skipping 20 matching lines...) Expand all
264 GLStringMap gl_strings_; 265 GLStringMap gl_strings_;
265 266
266 DISALLOW_COPY_AND_ASSIGN(GLES2Implementation); 267 DISALLOW_COPY_AND_ASSIGN(GLES2Implementation);
267 }; 268 };
268 269
269 } // namespace gles2 270 } // namespace gles2
270 } // namespace gpu 271 } // namespace gpu
271 272
272 #endif // GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_H_ 273 #endif // GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_H_
273 274
OLDNEW
« no previous file with comments | « no previous file | gpu/command_buffer/client/gles2_implementation.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698