cc: Added inline to Tile::IsReadyToDraw
[chromium-blink-merge.git] / gpu / command_buffer / client / gles2_implementation.h
blob9f8a7a2516af3493c03346d2424ba723027705ed
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_H_
6 #define GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_H_
8 #include <GLES2/gl2.h>
10 #include <map>
11 #include <queue>
12 #include <set>
13 #include <string>
14 #include <vector>
16 #include "base/memory/scoped_ptr.h"
17 #include "gles2_impl_export.h"
18 #include "gpu/command_buffer/client/buffer_tracker.h"
19 #include "gpu/command_buffer/client/client_context_state.h"
20 #include "gpu/command_buffer/client/gles2_cmd_helper.h"
21 #include "gpu/command_buffer/client/gles2_interface.h"
22 #include "gpu/command_buffer/client/gpu_memory_buffer_tracker.h"
23 #include "gpu/command_buffer/client/mapped_memory.h"
24 #include "gpu/command_buffer/client/query_tracker.h"
25 #include "gpu/command_buffer/client/ref_counted.h"
26 #include "gpu/command_buffer/client/ring_buffer.h"
27 #include "gpu/command_buffer/client/share_group.h"
28 #include "gpu/command_buffer/common/compiler_specific.h"
29 #include "gpu/command_buffer/common/debug_marker_manager.h"
30 #include "gpu/command_buffer/common/gles2_cmd_utils.h"
32 #if !defined(NDEBUG) && !defined(__native_client__) && !defined(GLES2_CONFORMANCE_TESTS) // NOLINT
33 #if defined(GLES2_INLINE_OPTIMIZATION)
34 // TODO(gman): Replace with macros that work with inline optmization.
35 #define GPU_CLIENT_SINGLE_THREAD_CHECK()
36 #define GPU_CLIENT_LOG(args)
37 #define GPU_CLIENT_LOG_CODE_BLOCK(code)
38 #define GPU_CLIENT_DCHECK_CODE_BLOCK(code)
39 #else
40 #include "base/logging.h"
41 #define GPU_CLIENT_SINGLE_THREAD_CHECK() SingleThreadChecker checker(this);
42 #define GPU_CLIENT_LOG(args) DLOG_IF(INFO, debug_) << args;
43 #define GPU_CLIENT_LOG_CODE_BLOCK(code) code
44 #define GPU_CLIENT_DCHECK_CODE_BLOCK(code) code
45 #define GPU_CLIENT_DEBUG
46 #endif
47 #else
48 #define GPU_CLIENT_SINGLE_THREAD_CHECK()
49 #define GPU_CLIENT_LOG(args)
50 #define GPU_CLIENT_LOG_CODE_BLOCK(code)
51 #define GPU_CLIENT_DCHECK_CODE_BLOCK(code)
52 #endif
54 #if defined(GPU_CLIENT_DEBUG)
55 // Set to 1 to have the client fail when a GL error is generated.
56 // This helps find bugs in the renderer since the debugger stops on the error.
57 # if 0
58 # define GL_CLIENT_FAIL_GL_ERRORS
59 # endif
60 #endif
62 // Check that destination pointers point to initialized memory.
63 // When the context is lost, calling GL function has no effect so if destination
64 // pointers point to initialized memory it can often lead to crash bugs. eg.
66 // GLsizei len;
67 // glGetShaderSource(shader, max_size, &len, buffer);
68 // std::string src(buffer, buffer + len); // len can be uninitialized here!!!
70 // Because this check is not official GL this check happens only on Chrome code,
71 // not Pepper.
73 // If it was up to us we'd just always write to the destination but the OpenGL
74 // spec defines the behavior of OpenGL functions, not us. :-(
75 #if defined(__native_client__) || defined(GLES2_CONFORMANCE_TESTS)
76 #define GPU_CLIENT_VALIDATE_DESTINATION_INITALIZATION_ASSERT(v)
77 #define GPU_CLIENT_DCHECK(v)
78 #elif defined(GPU_DCHECK)
79 #define GPU_CLIENT_VALIDATE_DESTINATION_INITALIZATION_ASSERT(v) GPU_DCHECK(v)
80 #define GPU_CLIENT_DCHECK(v) GPU_DCHECK(v)
81 #elif defined(DCHECK)
82 #define GPU_CLIENT_VALIDATE_DESTINATION_INITALIZATION_ASSERT(v) DCHECK(v)
83 #define GPU_CLIENT_DCHECK(v) DCHECK(v)
84 #else
85 #define GPU_CLIENT_VALIDATE_DESTINATION_INITALIZATION_ASSERT(v) ASSERT(v)
86 #define GPU_CLIENT_DCHECK(v) ASSERT(v)
87 #endif
89 #define GPU_CLIENT_VALIDATE_DESTINATION_INITALIZATION(type, ptr) \
90 GPU_CLIENT_VALIDATE_DESTINATION_INITALIZATION_ASSERT(ptr && \
91 (ptr[0] == static_cast<type>(0) || ptr[0] == static_cast<type>(-1)));
93 #define GPU_CLIENT_VALIDATE_DESTINATION_OPTIONAL_INITALIZATION(type, ptr) \
94 GPU_CLIENT_VALIDATE_DESTINATION_INITALIZATION_ASSERT(!ptr || \
95 (ptr[0] == static_cast<type>(0) || ptr[0] == static_cast<type>(-1)));
97 struct GLUniformDefinitionCHROMIUM;
99 namespace gpu {
101 class GpuControl;
102 class ScopedTransferBufferPtr;
103 class TransferBufferInterface;
105 namespace gles2 {
107 class ImageFactory;
108 class VertexArrayObjectManager;
110 // This class emulates GLES2 over command buffers. It can be used by a client
111 // program so that the program does not need deal with shared memory and command
112 // buffer management. See gl2_lib.h. Note that there is a performance gain to
113 // be had by changing your code to use command buffers directly by using the
114 // GLES2CmdHelper but that entails changing your code to use and deal with
115 // shared memory and synchronization issues.
116 class GLES2_IMPL_EXPORT GLES2Implementation : public GLES2Interface {
117 public:
118 enum MappedMemoryLimit {
119 kNoLimit = MappedMemoryManager::kNoLimit,
121 class ErrorMessageCallback {
122 public:
123 virtual ~ErrorMessageCallback() { }
124 virtual void OnErrorMessage(const char* msg, int id) = 0;
127 // Stores GL state that never changes.
128 struct GLES2_IMPL_EXPORT GLStaticState {
129 GLStaticState();
130 ~GLStaticState();
132 struct GLES2_IMPL_EXPORT IntState {
133 IntState();
134 GLint max_combined_texture_image_units;
135 GLint max_cube_map_texture_size;
136 GLint max_fragment_uniform_vectors;
137 GLint max_renderbuffer_size;
138 GLint max_texture_image_units;
139 GLint max_texture_size;
140 GLint max_varying_vectors;
141 GLint max_vertex_attribs;
142 GLint max_vertex_texture_image_units;
143 GLint max_vertex_uniform_vectors;
144 GLint num_compressed_texture_formats;
145 GLint num_shader_binary_formats;
147 IntState int_state;
149 typedef std::pair<GLenum,GLenum> ShaderPrecisionKey;
150 typedef std::map<ShaderPrecisionKey,
151 cmds::GetShaderPrecisionFormat::Result>
152 ShaderPrecisionMap;
153 ShaderPrecisionMap shader_precisions;
156 // The maxiumum result size from simple GL get commands.
157 static const size_t kMaxSizeOfSimpleResult = 16 * sizeof(uint32); // NOLINT.
159 // used for testing only. If more things are reseved add them here.
160 static const unsigned int kStartingOffset = kMaxSizeOfSimpleResult;
162 // Size in bytes to issue async flush for transfer buffer.
163 static const unsigned int kSizeToFlush = 256 * 1024;
165 // The bucket used for results. Public for testing only.
166 static const uint32 kResultBucketId = 1;
168 // Alignment of allocations.
169 static const unsigned int kAlignment = 4;
171 // GL names for the buffers used to emulate client side buffers.
172 static const GLuint kClientSideArrayId = 0xFEDCBA98u;
173 static const GLuint kClientSideElementArrayId = 0xFEDCBA99u;
175 // Number of swap buffers allowed before waiting.
176 static const size_t kMaxSwapBuffers = 2;
178 GLES2Implementation(
179 GLES2CmdHelper* helper,
180 ShareGroup* share_group,
181 TransferBufferInterface* transfer_buffer,
182 bool bind_generates_resource,
183 GpuControl* gpu_control);
185 virtual ~GLES2Implementation();
187 bool Initialize(
188 unsigned int starting_transfer_buffer_size,
189 unsigned int min_transfer_buffer_size,
190 unsigned int max_transfer_buffer_size,
191 unsigned int mapped_memory_limit);
193 // The GLES2CmdHelper being used by this GLES2Implementation. You can use
194 // this to issue cmds at a lower level for certain kinds of optimization.
195 GLES2CmdHelper* helper() const;
197 // Gets client side generated errors.
198 GLenum GetClientSideGLError();
200 // Include the auto-generated part of this class. We split this because
201 // it means we can easily edit the non-auto generated parts right here in
202 // this file instead of having to edit some template or the code generator.
203 #include "gpu/command_buffer/client/gles2_implementation_autogen.h"
205 virtual void DisableVertexAttribArray(GLuint index) OVERRIDE;
206 virtual void EnableVertexAttribArray(GLuint index) OVERRIDE;
207 virtual void GetVertexAttribfv(
208 GLuint index, GLenum pname, GLfloat* params) OVERRIDE;
209 virtual void GetVertexAttribiv(
210 GLuint index, GLenum pname, GLint* params) OVERRIDE;
212 void GetProgramInfoCHROMIUMHelper(GLuint program, std::vector<int8>* result);
213 GLint GetAttribLocationHelper(GLuint program, const char* name);
214 GLint GetUniformLocationHelper(GLuint program, const char* name);
215 bool GetActiveAttribHelper(
216 GLuint program, GLuint index, GLsizei bufsize, GLsizei* length,
217 GLint* size, GLenum* type, char* name);
218 bool GetActiveUniformHelper(
219 GLuint program, GLuint index, GLsizei bufsize, GLsizei* length,
220 GLint* size, GLenum* type, char* name);
223 void FreeUnusedSharedMemory();
224 void FreeEverything();
226 void SetErrorMessageCallback(ErrorMessageCallback* callback) {
227 error_message_callback_ = callback;
230 ShareGroup* share_group() const {
231 return share_group_.get();
234 private:
235 friend class GLES2ImplementationTest;
236 friend class VertexArrayObjectManager;
238 // Used to track whether an extension is available
239 enum ExtensionStatus {
240 kAvailableExtensionStatus,
241 kUnavailableExtensionStatus,
242 kUnknownExtensionStatus
245 // Base class for mapped resources.
246 struct MappedResource {
247 MappedResource(GLenum _access, int _shm_id, void* mem, unsigned int offset)
248 : access(_access),
249 shm_id(_shm_id),
250 shm_memory(mem),
251 shm_offset(offset) {
254 // access mode. Currently only GL_WRITE_ONLY is valid
255 GLenum access;
257 // Shared memory ID for buffer.
258 int shm_id;
260 // Address of shared memory
261 void* shm_memory;
263 // Offset of shared memory
264 unsigned int shm_offset;
267 // Used to track mapped textures.
268 struct MappedTexture : public MappedResource {
269 MappedTexture(
270 GLenum access,
271 int shm_id,
272 void* shm_mem,
273 unsigned int shm_offset,
274 GLenum _target,
275 GLint _level,
276 GLint _xoffset,
277 GLint _yoffset,
278 GLsizei _width,
279 GLsizei _height,
280 GLenum _format,
281 GLenum _type)
282 : MappedResource(access, shm_id, shm_mem, shm_offset),
283 target(_target),
284 level(_level),
285 xoffset(_xoffset),
286 yoffset(_yoffset),
287 width(_width),
288 height(_height),
289 format(_format),
290 type(_type) {
293 // These match the arguments to TexSubImage2D.
294 GLenum target;
295 GLint level;
296 GLint xoffset;
297 GLint yoffset;
298 GLsizei width;
299 GLsizei height;
300 GLenum format;
301 GLenum type;
304 // Used to track mapped buffers.
305 struct MappedBuffer : public MappedResource {
306 MappedBuffer(
307 GLenum access,
308 int shm_id,
309 void* shm_mem,
310 unsigned int shm_offset,
311 GLenum _target,
312 GLintptr _offset,
313 GLsizeiptr _size)
314 : MappedResource(access, shm_id, shm_mem, shm_offset),
315 target(_target),
316 offset(_offset),
317 size(_size) {
320 // These match the arguments to BufferSubData.
321 GLenum target;
322 GLintptr offset;
323 GLsizeiptr size;
326 struct TextureUnit {
327 TextureUnit()
328 : bound_texture_2d(0),
329 bound_texture_cube_map(0) {
332 // texture currently bound to this unit's GL_TEXTURE_2D with glBindTexture
333 GLuint bound_texture_2d;
335 // texture currently bound to this unit's GL_TEXTURE_CUBE_MAP with
336 // glBindTexture
337 GLuint bound_texture_cube_map;
340 // Checks for single threaded access.
341 class SingleThreadChecker {
342 public:
343 SingleThreadChecker(GLES2Implementation* gles2_implementation);
344 ~SingleThreadChecker();
346 private:
347 GLES2Implementation* gles2_implementation_;
350 // Gets the value of the result.
351 template <typename T>
352 T GetResultAs() {
353 return static_cast<T>(GetResultBuffer());
356 void* GetResultBuffer();
357 int32 GetResultShmId();
358 uint32 GetResultShmOffset();
360 bool QueryAndCacheStaticState();
362 // Helpers used to batch synchronous GetIntergerv calls with other
363 // synchronous calls.
364 struct GetMultipleIntegervState {
365 GetMultipleIntegervState(const GLenum* pnames, GLuint pnames_count,
366 GLint* results, GLsizeiptr results_size)
367 : pnames(pnames),
368 pnames_count(pnames_count),
369 results(results),
370 results_size(results_size)
372 // inputs
373 const GLenum* pnames;
374 GLuint pnames_count;
375 // outputs
376 GLint* results;
377 GLsizeiptr results_size;
378 // transfer buffer
379 int num_results;
380 int transfer_buffer_size_needed;
381 void* buffer;
382 void* results_buffer;
384 bool GetMultipleIntegervSetup(
385 GetMultipleIntegervState* state);
386 void GetMultipleIntegervRequest(
387 GetMultipleIntegervState* state);
388 void GetMultipleIntegervOnCompleted(
389 GetMultipleIntegervState* state);
391 // Helpers used to batch synchronous GetShaderPrecision calls with other
392 // synchronous calls.
393 struct GetAllShaderPrecisionFormatsState {
394 GetAllShaderPrecisionFormatsState(
395 const GLenum (*precision_params)[2],
396 int precision_params_count)
397 : precision_params(precision_params),
398 precision_params_count(precision_params_count)
400 const GLenum (*precision_params)[2];
401 int precision_params_count;
402 int transfer_buffer_size_needed;
403 void* results_buffer;
405 void GetAllShaderPrecisionFormatsSetup(
406 GetAllShaderPrecisionFormatsState* state);
407 void GetAllShaderPrecisionFormatsRequest(
408 GetAllShaderPrecisionFormatsState* state);
409 void GetAllShaderPrecisionFormatsOnCompleted(
410 GetAllShaderPrecisionFormatsState* state);
412 // Lazily determines if GL_ANGLE_pack_reverse_row_order is available
413 bool IsAnglePackReverseRowOrderAvailable();
414 bool IsChromiumFramebufferMultisampleAvailable();
416 bool IsExtensionAvailableHelper(
417 const char* extension, ExtensionStatus* status);
419 // Gets the GLError through our wrapper.
420 GLenum GetGLError();
422 // Sets our wrapper for the GLError.
423 void SetGLError(GLenum error, const char* function_name, const char* msg);
424 void SetGLErrorInvalidEnum(
425 const char* function_name, GLenum value, const char* label);
427 // Returns the last error and clears it. Useful for debugging.
428 const std::string& GetLastError() {
429 return last_error_;
432 // Waits for all commands to execute.
433 void WaitForCmd();
435 // TODO(gman): These bucket functions really seem like they belong in
436 // CommandBufferHelper (or maybe BucketHelper?). Unfortunately they need
437 // a transfer buffer to function which is currently managed by this class.
439 // Gets the contents of a bucket.
440 bool GetBucketContents(uint32 bucket_id, std::vector<int8>* data);
442 // Sets the contents of a bucket.
443 void SetBucketContents(uint32 bucket_id, const void* data, size_t size);
445 // Sets the contents of a bucket as a string.
446 void SetBucketAsCString(uint32 bucket_id, const char* str);
448 // Gets the contents of a bucket as a string. Returns false if there is no
449 // string available which is a separate case from the empty string.
450 bool GetBucketAsString(uint32 bucket_id, std::string* str);
452 // Sets the contents of a bucket as a string.
453 void SetBucketAsString(uint32 bucket_id, const std::string& str);
455 // Returns true if id is reserved.
456 bool IsBufferReservedId(GLuint id);
457 bool IsFramebufferReservedId(GLuint id) { return false; }
458 bool IsRenderbufferReservedId(GLuint id) { return false; }
459 bool IsTextureReservedId(GLuint id) { return false; }
460 bool IsVertexArrayReservedId(GLuint id) { return false; }
462 bool BindBufferHelper(GLenum target, GLuint texture);
463 bool BindFramebufferHelper(GLenum target, GLuint texture);
464 bool BindRenderbufferHelper(GLenum target, GLuint texture);
465 bool BindTextureHelper(GLenum target, GLuint texture);
466 bool BindVertexArrayHelper(GLuint array);
468 void GenBuffersHelper(GLsizei n, const GLuint* buffers);
469 void GenFramebuffersHelper(GLsizei n, const GLuint* framebuffers);
470 void GenRenderbuffersHelper(GLsizei n, const GLuint* renderbuffers);
471 void GenTexturesHelper(GLsizei n, const GLuint* textures);
472 void GenVertexArraysOESHelper(GLsizei n, const GLuint* arrays);
473 void GenQueriesEXTHelper(GLsizei n, const GLuint* queries);
475 void DeleteBuffersHelper(GLsizei n, const GLuint* buffers);
476 void DeleteFramebuffersHelper(GLsizei n, const GLuint* framebuffers);
477 void DeleteRenderbuffersHelper(GLsizei n, const GLuint* renderbuffers);
478 void DeleteTexturesHelper(GLsizei n, const GLuint* textures);
479 bool DeleteProgramHelper(GLuint program);
480 bool DeleteShaderHelper(GLuint shader);
481 void DeleteQueriesEXTHelper(GLsizei n, const GLuint* queries);
482 void DeleteVertexArraysOESHelper(GLsizei n, const GLuint* arrays);
484 void DeleteBuffersStub(GLsizei n, const GLuint* buffers);
485 void DeleteFramebuffersStub(GLsizei n, const GLuint* framebuffers);
486 void DeleteRenderbuffersStub(GLsizei n, const GLuint* renderbuffers);
487 void DeleteTexturesStub(GLsizei n, const GLuint* textures);
488 void DeleteProgramStub(GLsizei n, const GLuint* programs);
489 void DeleteShaderStub(GLsizei n, const GLuint* shaders);
490 // TODO(gman): Remove this as queries are not shared.
491 void DeleteQueriesStub(GLsizei n, const GLuint* queries);
492 void DeleteVertexArraysOESStub(GLsizei n, const GLuint* arrays);
494 void BufferDataHelper(
495 GLenum target, GLsizeiptr size, const void* data, GLenum usage);
496 void BufferSubDataHelper(
497 GLenum target, GLintptr offset, GLsizeiptr size, const void* data);
498 void BufferSubDataHelperImpl(
499 GLenum target, GLintptr offset, GLsizeiptr size, const void* data,
500 ScopedTransferBufferPtr* buffer);
502 GLuint CreateImageCHROMIUMHelper(
503 GLsizei width, GLsizei height, GLenum internalformat);
504 void DestroyImageCHROMIUMHelper(GLuint image_id);
505 void* MapImageCHROMIUMHelper(GLuint image_id, GLenum access);
506 void UnmapImageCHROMIUMHelper(GLuint image_id);
507 void GetImageParameterivCHROMIUMHelper(
508 GLuint image_id, GLenum pname, GLint* params);
510 // Helper for GetVertexAttrib
511 bool GetVertexAttribHelper(GLuint index, GLenum pname, uint32* param);
513 GLuint GetMaxValueInBufferCHROMIUMHelper(
514 GLuint buffer_id, GLsizei count, GLenum type, GLuint offset);
516 void RestoreElementAndArrayBuffers(bool restore);
517 void RestoreArrayBuffer(bool restrore);
519 // The pixels pointer should already account for unpack skip rows and skip
520 // pixels.
521 void TexSubImage2DImpl(
522 GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width,
523 GLsizei height, GLenum format, GLenum type, uint32 unpadded_row_size,
524 const void* pixels, uint32 pixels_padded_row_size, GLboolean internal,
525 ScopedTransferBufferPtr* buffer, uint32 buffer_padded_row_size);
527 // Helpers for query functions.
528 bool GetHelper(GLenum pname, GLint* params);
529 bool GetBooleanvHelper(GLenum pname, GLboolean* params);
530 bool GetBufferParameterivHelper(GLenum target, GLenum pname, GLint* params);
531 bool GetFloatvHelper(GLenum pname, GLfloat* params);
532 bool GetFramebufferAttachmentParameterivHelper(
533 GLenum target, GLenum attachment, GLenum pname, GLint* params);
534 bool GetIntegervHelper(GLenum pname, GLint* params);
535 bool GetProgramivHelper(GLuint program, GLenum pname, GLint* params);
536 bool GetRenderbufferParameterivHelper(
537 GLenum target, GLenum pname, GLint* params);
538 bool GetShaderivHelper(GLuint shader, GLenum pname, GLint* params);
539 bool GetTexParameterfvHelper(GLenum target, GLenum pname, GLfloat* params);
540 bool GetTexParameterivHelper(GLenum target, GLenum pname, GLint* params);
541 const GLubyte* GetStringHelper(GLenum name);
543 bool IsExtensionAvailable(const char* ext);
545 // Caches certain capabilties state. Return true if cached.
546 bool SetCapabilityState(GLenum cap, bool enabled);
548 IdHandlerInterface* GetIdHandler(int id_namespace) const;
550 void FinishHelper();
552 // Asserts that the context is lost.
553 // NOTE: This is an expensive call and should only be called
554 // for error checking.
555 bool MustBeContextLost();
557 bool GetBoundPixelTransferBuffer(
558 GLenum target, const char* function_name, GLuint* buffer_id);
559 BufferTracker::Buffer* GetBoundPixelUnpackTransferBufferIfValid(
560 GLuint buffer_id,
561 const char* function_name, GLuint offset, GLsizei size);
563 const std::string& GetLogPrefix() const;
565 #if defined(GL_CLIENT_FAIL_GL_ERRORS)
566 void CheckGLError();
567 void FailGLError(GLenum error);
568 #else
569 void CheckGLError() { }
570 void FailGLError(GLenum /* error */) { }
571 #endif
573 GLES2Util util_;
574 GLES2CmdHelper* helper_;
575 TransferBufferInterface* transfer_buffer_;
576 std::string last_error_;
577 DebugMarkerManager debug_marker_manager_;
578 std::string this_in_hex_;
580 std::queue<int32> swap_buffers_tokens_;
581 std::queue<int32> rate_limit_tokens_;
583 ExtensionStatus angle_pack_reverse_row_order_status_;
584 ExtensionStatus chromium_framebuffer_multisample_;
586 GLStaticState static_state_;
587 ClientContextState state_;
589 // pack alignment as last set by glPixelStorei
590 GLint pack_alignment_;
592 // unpack alignment as last set by glPixelStorei
593 GLint unpack_alignment_;
595 // unpack yflip as last set by glPixelstorei
596 bool unpack_flip_y_;
598 // unpack row length as last set by glPixelStorei
599 GLint unpack_row_length_;
601 // unpack skip rows as last set by glPixelStorei
602 GLint unpack_skip_rows_;
604 // unpack skip pixels as last set by glPixelStorei
605 GLint unpack_skip_pixels_;
607 // pack reverse row order as last set by glPixelstorei
608 bool pack_reverse_row_order_;
610 scoped_ptr<TextureUnit[]> texture_units_;
612 // 0 to gl_state_.max_combined_texture_image_units.
613 GLuint active_texture_unit_;
615 GLuint bound_framebuffer_;
616 GLuint bound_read_framebuffer_;
617 GLuint bound_renderbuffer_;
619 // The program in use by glUseProgram
620 GLuint current_program_;
622 // The currently bound array buffer.
623 GLuint bound_array_buffer_id_;
625 // The currently bound pixel transfer buffers.
626 GLuint bound_pixel_pack_transfer_buffer_id_;
627 GLuint bound_pixel_unpack_transfer_buffer_id_;
629 // Client side management for vertex array objects. Needed to correctly
630 // track client side arrays.
631 scoped_ptr<VertexArrayObjectManager> vertex_array_object_manager_;
633 GLuint reserved_ids_[2];
635 // Current GL error bits.
636 uint32 error_bits_;
638 // Whether or not to print debugging info.
639 bool debug_;
641 // Used to check for single threaded access.
642 int use_count_;
644 // Map of GLenum to Strings for glGetString. We need to cache these because
645 // the pointer passed back to the client has to remain valid for eternity.
646 typedef std::map<uint32, std::set<std::string> > GLStringMap;
647 GLStringMap gl_strings_;
649 // Similar cache for glGetRequestableExtensionsCHROMIUM. We don't
650 // have an enum for this so handle it separately.
651 std::set<std::string> requestable_extensions_set_;
653 typedef std::map<const void*, MappedBuffer> MappedBufferMap;
654 MappedBufferMap mapped_buffers_;
656 typedef std::map<const void*, MappedTexture> MappedTextureMap;
657 MappedTextureMap mapped_textures_;
659 scoped_ptr<MappedMemoryManager> mapped_memory_;
661 scoped_refptr<ShareGroup> share_group_;
663 scoped_ptr<QueryTracker> query_tracker_;
664 QueryTracker::Query* current_query_;
666 scoped_ptr<BufferTracker> buffer_tracker_;
668 scoped_ptr<GpuMemoryBufferTracker> gpu_memory_buffer_tracker_;
670 ErrorMessageCallback* error_message_callback_;
672 scoped_ptr<std::string> current_trace_name_;
674 GpuControl* gpu_control_;
676 DISALLOW_COPY_AND_ASSIGN(GLES2Implementation);
679 inline bool GLES2Implementation::GetBufferParameterivHelper(
680 GLenum /* target */, GLenum /* pname */, GLint* /* params */) {
681 return false;
684 inline bool GLES2Implementation::GetFramebufferAttachmentParameterivHelper(
685 GLenum /* target */,
686 GLenum /* attachment */,
687 GLenum /* pname */,
688 GLint* /* params */) {
689 return false;
692 inline bool GLES2Implementation::GetRenderbufferParameterivHelper(
693 GLenum /* target */, GLenum /* pname */, GLint* /* params */) {
694 return false;
697 inline bool GLES2Implementation::GetShaderivHelper(
698 GLuint /* shader */, GLenum /* pname */, GLint* /* params */) {
699 return false;
702 inline bool GLES2Implementation::GetTexParameterfvHelper(
703 GLenum /* target */, GLenum /* pname */, GLfloat* /* params */) {
704 return false;
707 inline bool GLES2Implementation::GetTexParameterivHelper(
708 GLenum /* target */, GLenum /* pname */, GLint* /* params */) {
709 return false;
712 } // namespace gles2
713 } // namespace gpu
715 #endif // GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_H_