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

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

Issue 2956005: Adds MapBufferSubData and MapTexSubImage2D.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 5 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
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 <GLES2/gl2.h> 8 #include <GLES2/gl2.h>
9 9
10 #include <map> 10 #include <map>
11 #include <string> 11 #include <string>
12 #include <vector> 12 #include <vector>
13 13
14 #include "../common/gles2_cmd_utils.h" 14 #include "../common/gles2_cmd_utils.h"
15 #include "../common/scoped_ptr.h" 15 #include "../common/scoped_ptr.h"
16 #include "../client/gles2_cmd_helper.h" 16 #include "../client/gles2_cmd_helper.h"
17 #include "../client/ring_buffer.h" 17 #include "../client/ring_buffer.h"
18 18
19 #define GLES2_SUPPORT_CLIENT_SIDE_BUFFERS 1 19 #define GLES2_SUPPORT_CLIENT_SIDE_BUFFERS 1
20 20
21 namespace gpu { 21 namespace gpu {
22
23 class MappedMemoryManager;
24
22 namespace gles2 { 25 namespace gles2 {
23 26
24 class ClientSideBufferHelper; 27 class ClientSideBufferHelper;
25 28
26 // Base class for IdHandlers 29 // Base class for IdHandlers
27 class IdHandlerInterface { 30 class IdHandlerInterface {
28 public: 31 public:
29 IdHandlerInterface() { } 32 IdHandlerInterface() { }
30 virtual ~IdHandlerInterface() { } 33 virtual ~IdHandlerInterface() { }
31 34
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 typedef GetVertexAttribiv::Result Result; 141 typedef GetVertexAttribiv::Result Result;
139 Result* result = GetResultAs<Result*>(); 142 Result* result = GetResultAs<Result*>();
140 result->SetNumResults(0); 143 result->SetNumResults(0);
141 helper_->GetVertexAttribiv( 144 helper_->GetVertexAttribiv(
142 index, pname, result_shm_id(), result_shm_offset()); 145 index, pname, result_shm_id(), result_shm_offset());
143 WaitForCmd(); 146 WaitForCmd();
144 result->CopyResult(params); 147 result->CopyResult(params);
145 } 148 }
146 #endif 149 #endif
147 150
148 GLuint MakeTextureId() { 151 GLuint MakeTextureId() {
149 GLuint id; 152 GLuint id;
150 texture_id_handler_->MakeIds(0, 1, &id); 153 texture_id_handler_->MakeIds(0, 1, &id);
151 return id; 154 return id;
152 } 155 }
153 156
154 void FreeTextureId(GLuint id) { 157 void FreeTextureId(GLuint id) {
155 texture_id_handler_->FreeIds(1, &id); 158 texture_id_handler_->FreeIds(1, &id);
156 } 159 }
157 160
158 private: 161 private:
159 // Wraps RingBufferWrapper to provide aligned allocations. 162 // Wraps RingBufferWrapper to provide aligned allocations.
160 class AlignedRingBuffer : public RingBufferWrapper { 163 class AlignedRingBuffer : public RingBufferWrapper {
161 public: 164 public:
162 AlignedRingBuffer(RingBuffer::Offset base_offset, 165 AlignedRingBuffer(RingBuffer::Offset base_offset,
163 unsigned int size, 166 unsigned int size,
164 CommandBufferHelper *helper, 167 CommandBufferHelper *helper,
165 void *base) 168 void *base)
166 : RingBufferWrapper(base_offset, size, helper, base) { 169 : RingBufferWrapper(base_offset, size, helper, base) {
167 } 170 }
168 171
169 static unsigned int RoundToAlignment(unsigned int size) { 172 static unsigned int RoundToAlignment(unsigned int size) {
170 return (size + kAlignment - 1) & ~(kAlignment - 1); 173 return (size + kAlignment - 1) & ~(kAlignment - 1);
171 } 174 }
172 175
173 // Overrriden from RingBufferWrapper 176 // Overrriden from RingBufferWrapper
174 void *Alloc(unsigned int size) { 177 void *Alloc(unsigned int size) {
175 return RingBufferWrapper::Alloc(RoundToAlignment(size)); 178 return RingBufferWrapper::Alloc(RoundToAlignment(size));
176 } 179 }
177 180
178 // Overrriden from RingBufferWrapper 181 // Overrriden from RingBufferWrapper
179 template <typename T> T *AllocTyped(unsigned int count) { 182 template <typename T> T *AllocTyped(unsigned int count) {
180 return static_cast<T *>(Alloc(count * sizeof(T))); 183 return static_cast<T *>(Alloc(count * sizeof(T)));
181 } 184 }
182 }; 185 };
183 186
187 // Base class for mapped resources.
188 struct MappedResource {
189 MappedResource(GLenum _access, int _shm_id, void* mem, unsigned int offset)
190 : access(_access),
191 shm_id(_shm_id),
192 shm_memory(mem),
193 shm_offset(offset) {
194 }
195
196 // access mode. Currently only GL_WRITE_ONLY is valid
197 GLenum access;
198
199 // Shared memory ID for buffer.
200 int shm_id;
201
202 // Address of shared memory
203 void* shm_memory;
204
205 // Offset of shared memory
206 unsigned int shm_offset;
207 };
208
209 // Used to track mapped textures.
210 struct MappedTexture : public MappedResource {
211 MappedTexture(
212 GLenum access,
213 int shm_id,
214 void* shm_mem,
215 unsigned int shm_offset,
216 GLenum _target,
217 GLint _level,
218 GLint _xoffset,
219 GLint _yoffset,
220 GLsizei _width,
221 GLsizei _height,
222 GLenum _format,
223 GLenum _type)
224 : MappedResource(access, shm_id, shm_mem, shm_offset),
225 target(_target),
226 level(_level),
227 xoffset(_xoffset),
228 yoffset(_yoffset),
229 width(_width),
230 height(_height),
231 format(_format),
232 type(_type) {
233 }
234
235 // These match the arguments to TexSubImage2D.
236 GLenum target;
237 GLint level;
238 GLint xoffset;
239 GLint yoffset;
240 GLsizei width;
241 GLsizei height;
242 GLenum format;
243 GLenum type;
244 };
245
246 // Used to track mapped buffers.
247 struct MappedBuffer : public MappedResource {
248 MappedBuffer(
249 GLenum access,
250 int shm_id,
251 void* shm_mem,
252 unsigned int shm_offset,
253 GLenum _target,
254 GLintptr _offset,
255 GLsizeiptr _size)
256 : MappedResource(access, shm_id, shm_mem, shm_offset),
257 target(_target),
258 offset(_offset),
259 size(_size) {
260 }
261
262 // These match the arguments to BufferSubData.
263 GLenum target;
264 GLintptr offset;
265 GLsizeiptr size;
266 };
267
184 // Gets the shared memory id for the result buffer. 268 // Gets the shared memory id for the result buffer.
185 uint32 result_shm_id() const { 269 uint32 result_shm_id() const {
186 return transfer_buffer_id_; 270 return transfer_buffer_id_;
187 } 271 }
188 272
189 // Gets the shared memory offset for the result buffer. 273 // Gets the shared memory offset for the result buffer.
190 uint32 result_shm_offset() const { 274 uint32 result_shm_offset() const {
191 return result_shm_offset_; 275 return result_shm_offset_;
192 } 276 }
193 277
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 #endif 368 #endif
285 369
286 // Current GL error bits. 370 // Current GL error bits.
287 uint32 error_bits_; 371 uint32 error_bits_;
288 372
289 // Map of GLenum to Strings for glGetString. We need to cache these because 373 // Map of GLenum to Strings for glGetString. We need to cache these because
290 // the pointer passed back to the client has to remain valid for eternity. 374 // the pointer passed back to the client has to remain valid for eternity.
291 typedef std::map<uint32, std::string> GLStringMap; 375 typedef std::map<uint32, std::string> GLStringMap;
292 GLStringMap gl_strings_; 376 GLStringMap gl_strings_;
293 377
378 typedef std::map<const void*, MappedBuffer> MappedBufferMap;
379 MappedBufferMap mapped_buffers_;
380
381 typedef std::map<const void*, MappedTexture> MappedTextureMap;
382 MappedTextureMap mapped_textures_;
383
384 scoped_ptr<MappedMemoryManager> mapped_memory_;
385
294 DISALLOW_COPY_AND_ASSIGN(GLES2Implementation); 386 DISALLOW_COPY_AND_ASSIGN(GLES2Implementation);
295 }; 387 };
296 388
297 } // namespace gles2 389 } // namespace gles2
298 } // namespace gpu 390 } // namespace gpu
299 391
300 #endif // GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_H_ 392 #endif // GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_H_
301 393
OLDNEW
« no previous file with comments | « gpu/command_buffer/client/gles2_c_lib_autogen.h ('k') | gpu/command_buffer/client/gles2_implementation.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698