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

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

Issue 11363191: Cache more GL state both service and client side. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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 <queue> 11 #include <queue>
12 #include <set> 12 #include <set>
13 #include <string> 13 #include <string>
14 #include <vector> 14 #include <vector>
15 15
16 #include "../common/compiler_specific.h" 16 #include "../common/compiler_specific.h"
17 #include "../common/debug_marker_manager.h" 17 #include "../common/debug_marker_manager.h"
18 #include "../common/gles2_cmd_utils.h" 18 #include "../common/gles2_cmd_utils.h"
19 #include "../common/scoped_ptr.h" 19 #include "../common/scoped_ptr.h"
20 #include "../client/ref_counted.h" 20 #include "../client/ref_counted.h"
21 #include "../client/client_context_state.h"
21 #include "../client/gles2_cmd_helper.h" 22 #include "../client/gles2_cmd_helper.h"
22 #include "../client/gles2_interface.h" 23 #include "../client/gles2_interface.h"
23 #include "../client/query_tracker.h" 24 #include "../client/query_tracker.h"
24 #include "../client/ring_buffer.h" 25 #include "../client/ring_buffer.h"
25 #include "../client/share_group.h" 26 #include "../client/share_group.h"
26 #include "gles2_impl_export.h" 27 #include "gles2_impl_export.h"
27 28
28 #if !defined(NDEBUG) && !defined(__native_client__) && !defined(GLES2_CONFORMANC E_TESTS) // NOLINT 29 #if !defined(NDEBUG) && !defined(__native_client__) && !defined(GLES2_CONFORMANC E_TESTS) // NOLINT
29 #if defined(GLES2_INLINE_OPTIMIZATION) 30 #if defined(GLES2_INLINE_OPTIMIZATION)
30 // TODO(gman): Replace with macros that work with inline optmization. 31 // TODO(gman): Replace with macros that work with inline optmization.
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 // GLES2CmdHelper but that entails changing your code to use and deal with 102 // GLES2CmdHelper but that entails changing your code to use and deal with
102 // shared memory and synchronization issues. 103 // shared memory and synchronization issues.
103 class GLES2_IMPL_EXPORT GLES2Implementation : public GLES2Interface { 104 class GLES2_IMPL_EXPORT GLES2Implementation : public GLES2Interface {
104 public: 105 public:
105 class ErrorMessageCallback { 106 class ErrorMessageCallback {
106 public: 107 public:
107 virtual ~ErrorMessageCallback() { } 108 virtual ~ErrorMessageCallback() { }
108 virtual void OnErrorMessage(const char* msg, int id) = 0; 109 virtual void OnErrorMessage(const char* msg, int id) = 0;
109 }; 110 };
110 111
111 // Stores client side cached GL state. 112 // Stores GL state that never changes.
112 struct GLCachedState { 113 struct GLStaticState {
113 struct GLES2_IMPL_EXPORT IntState { 114 struct GLES2_IMPL_EXPORT IntState {
114 IntState(); 115 IntState();
115 GLint max_combined_texture_image_units; 116 GLint max_combined_texture_image_units;
116 GLint max_cube_map_texture_size; 117 GLint max_cube_map_texture_size;
117 GLint max_fragment_uniform_vectors; 118 GLint max_fragment_uniform_vectors;
118 GLint max_renderbuffer_size; 119 GLint max_renderbuffer_size;
119 GLint max_texture_image_units; 120 GLint max_texture_image_units;
120 GLint max_texture_size; 121 GLint max_texture_size;
121 GLint max_varying_vectors; 122 GLint max_varying_vectors;
122 GLint max_vertex_attribs; 123 GLint max_vertex_attribs;
123 GLint max_vertex_texture_image_units; 124 GLint max_vertex_texture_image_units;
124 GLint max_vertex_uniform_vectors; 125 GLint max_vertex_uniform_vectors;
125 GLint num_compressed_texture_formats; 126 GLint num_compressed_texture_formats;
126 GLint num_shader_binary_formats; 127 GLint num_shader_binary_formats;
127 }; 128 };
128 struct EnableState {
129 EnableState()
130 : blend(false),
131 cull_face(false),
132 depth_test(false),
133 dither(false),
134 polygon_offset_fill(false),
135 sample_alpha_to_coverage(false),
136 sample_coverage(false),
137 scissor_test(false),
138 stencil_test(false) {
139 }
140
141 bool blend;
142 bool cull_face;
143 bool depth_test;
144 bool dither;
145 bool polygon_offset_fill;
146 bool sample_alpha_to_coverage;
147 bool sample_coverage;
148 bool scissor_test;
149 bool stencil_test;
150 };
151
152 IntState int_state; 129 IntState int_state;
153 EnableState enable_state;
154 }; 130 };
155 131
156 // The maxiumum result size from simple GL get commands. 132 // The maxiumum result size from simple GL get commands.
157 static const size_t kMaxSizeOfSimpleResult = 16 * sizeof(uint32); // NOLINT. 133 static const size_t kMaxSizeOfSimpleResult = 16 * sizeof(uint32); // NOLINT.
158 134
159 // used for testing only. If more things are reseved add them here. 135 // used for testing only. If more things are reseved add them here.
160 static const unsigned int kStartingOffset = kMaxSizeOfSimpleResult; 136 static const unsigned int kStartingOffset = kMaxSizeOfSimpleResult;
161 137
162 // Size in bytes to issue async flush for transfer buffer. 138 // Size in bytes to issue async flush for transfer buffer.
163 static const unsigned int kSizeToFlush = 256 * 1024; 139 static const unsigned int kSizeToFlush = 256 * 1024;
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 // Sets the contents of a bucket as a string. 375 // Sets the contents of a bucket as a string.
400 void SetBucketAsString(uint32 bucket_id, const std::string& str); 376 void SetBucketAsString(uint32 bucket_id, const std::string& str);
401 377
402 // Returns true if id is reserved. 378 // Returns true if id is reserved.
403 bool IsBufferReservedId(GLuint id); 379 bool IsBufferReservedId(GLuint id);
404 bool IsFramebufferReservedId(GLuint id) { return false; } 380 bool IsFramebufferReservedId(GLuint id) { return false; }
405 bool IsRenderbufferReservedId(GLuint id) { return false; } 381 bool IsRenderbufferReservedId(GLuint id) { return false; }
406 bool IsTextureReservedId(GLuint id) { return false; } 382 bool IsTextureReservedId(GLuint id) { return false; }
407 bool IsVertexArrayReservedId(GLuint id) { return false; } 383 bool IsVertexArrayReservedId(GLuint id) { return false; }
408 384
409 void BindBufferHelper(GLenum target, GLuint texture); 385 bool BindBufferHelper(GLenum target, GLuint texture);
410 void BindFramebufferHelper(GLenum target, GLuint texture); 386 bool BindFramebufferHelper(GLenum target, GLuint texture);
411 void BindRenderbufferHelper(GLenum target, GLuint texture); 387 bool BindRenderbufferHelper(GLenum target, GLuint texture);
412 void BindTextureHelper(GLenum target, GLuint texture); 388 bool BindTextureHelper(GLenum target, GLuint texture);
413 void BindVertexArrayHelper(GLuint array); 389 bool BindVertexArrayHelper(GLuint array);
414 390
415 void DeleteBuffersHelper(GLsizei n, const GLuint* buffers); 391 void DeleteBuffersHelper(GLsizei n, const GLuint* buffers);
416 void DeleteFramebuffersHelper(GLsizei n, const GLuint* framebuffers); 392 void DeleteFramebuffersHelper(GLsizei n, const GLuint* framebuffers);
417 void DeleteRenderbuffersHelper(GLsizei n, const GLuint* renderbuffers); 393 void DeleteRenderbuffersHelper(GLsizei n, const GLuint* renderbuffers);
418 void DeleteTexturesHelper(GLsizei n, const GLuint* textures); 394 void DeleteTexturesHelper(GLsizei n, const GLuint* textures);
419 bool DeleteProgramHelper(GLuint program); 395 bool DeleteProgramHelper(GLuint program);
420 bool DeleteShaderHelper(GLuint shader); 396 bool DeleteShaderHelper(GLuint shader);
421 void DeleteQueriesEXTHelper(GLsizei n, const GLuint* textures); 397 void DeleteQueriesEXTHelper(GLsizei n, const GLuint* textures);
422 void DeleteVertexArraysOESHelper(GLsizei n, const GLuint* arrays); 398 void DeleteVertexArraysOESHelper(GLsizei n, const GLuint* arrays);
423 399
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 TransferBufferInterface* transfer_buffer_; 466 TransferBufferInterface* transfer_buffer_;
491 std::string last_error_; 467 std::string last_error_;
492 DebugMarkerManager debug_marker_manager_; 468 DebugMarkerManager debug_marker_manager_;
493 std::string this_in_hex_; 469 std::string this_in_hex_;
494 470
495 std::queue<int32> swap_buffers_tokens_; 471 std::queue<int32> swap_buffers_tokens_;
496 std::queue<int32> rate_limit_tokens_; 472 std::queue<int32> rate_limit_tokens_;
497 473
498 ExtensionStatus angle_pack_reverse_row_order_status; 474 ExtensionStatus angle_pack_reverse_row_order_status;
499 475
500 GLCachedState gl_state_; 476 GLStaticState static_state_;
477 ClientContextState state_;
501 478
502 // pack alignment as last set by glPixelStorei 479 // pack alignment as last set by glPixelStorei
503 GLint pack_alignment_; 480 GLint pack_alignment_;
504 481
505 // unpack alignment as last set by glPixelStorei 482 // unpack alignment as last set by glPixelStorei
506 GLint unpack_alignment_; 483 GLint unpack_alignment_;
507 484
508 // unpack yflip as last set by glPixelstorei 485 // unpack yflip as last set by glPixelstorei
509 bool unpack_flip_y_; 486 bool unpack_flip_y_;
510 487
(...skipping 10 matching lines...) Expand all
521 bool pack_reverse_row_order_; 498 bool pack_reverse_row_order_;
522 499
523 scoped_array<TextureUnit> texture_units_; 500 scoped_array<TextureUnit> texture_units_;
524 501
525 // 0 to gl_state_.max_combined_texture_image_units. 502 // 0 to gl_state_.max_combined_texture_image_units.
526 GLuint active_texture_unit_; 503 GLuint active_texture_unit_;
527 504
528 GLuint bound_framebuffer_; 505 GLuint bound_framebuffer_;
529 GLuint bound_renderbuffer_; 506 GLuint bound_renderbuffer_;
530 507
508 // The program in use by glUseProgram
509 GLuint current_program_;
510
531 // The currently bound array buffer. 511 // The currently bound array buffer.
532 GLuint bound_array_buffer_id_; 512 GLuint bound_array_buffer_id_;
533 513
534 // The currently bound element array buffer. 514 // The currently bound element array buffer.
535 GLuint bound_element_array_buffer_id_; 515 GLuint bound_element_array_buffer_id_;
536 516
537 // GL names for the buffers used to emulate client side buffers. 517 // GL names for the buffers used to emulate client side buffers.
538 GLuint client_side_array_id_; 518 GLuint client_side_array_id_;
539 GLuint client_side_element_array_id_; 519 GLuint client_side_element_array_id_;
540 520
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
613 593
614 inline bool GLES2Implementation::GetTexParameterivHelper( 594 inline bool GLES2Implementation::GetTexParameterivHelper(
615 GLenum /* target */, GLenum /* pname */, GLint* /* params */) { 595 GLenum /* target */, GLenum /* pname */, GLint* /* params */) {
616 return false; 596 return false;
617 } 597 }
618 598
619 } // namespace gles2 599 } // namespace gles2
620 } // namespace gpu 600 } // namespace gpu
621 601
622 #endif // GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_H_ 602 #endif // GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_H_
OLDNEW
« no previous file with comments | « gpu/command_buffer/client/client_context_state_impl_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