| OLD | NEW |
| 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 "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
| 17 #include "gles2_impl_export.h" | 17 #include "gles2_impl_export.h" |
| 18 #include "gpu/command_buffer/client/buffer_tracker.h" | 18 #include "gpu/command_buffer/client/buffer_tracker.h" |
| 19 #include "gpu/command_buffer/client/client_context_state.h" | 19 #include "gpu/command_buffer/client/client_context_state.h" |
| 20 #include "gpu/command_buffer/client/gles2_cmd_helper.h" | 20 #include "gpu/command_buffer/client/gles2_cmd_helper.h" |
| 21 #include "gpu/command_buffer/client/gles2_interface.h" | 21 #include "gpu/command_buffer/client/gles2_interface.h" |
| 22 #include "gpu/command_buffer/client/gpu_memory_buffer_tracker.h" | 22 #include "gpu/command_buffer/client/gpu_memory_buffer_tracker.h" |
| 23 #include "gpu/command_buffer/client/image_factory.h" | 23 #include "gpu/command_buffer/client/image_factory.h" |
| 24 #include "gpu/command_buffer/client/mapped_memory.h" |
| 24 #include "gpu/command_buffer/client/query_tracker.h" | 25 #include "gpu/command_buffer/client/query_tracker.h" |
| 25 #include "gpu/command_buffer/client/ref_counted.h" | 26 #include "gpu/command_buffer/client/ref_counted.h" |
| 26 #include "gpu/command_buffer/client/ring_buffer.h" | 27 #include "gpu/command_buffer/client/ring_buffer.h" |
| 27 #include "gpu/command_buffer/client/share_group.h" | 28 #include "gpu/command_buffer/client/share_group.h" |
| 28 #include "gpu/command_buffer/common/compiler_specific.h" | 29 #include "gpu/command_buffer/common/compiler_specific.h" |
| 29 #include "gpu/command_buffer/common/debug_marker_manager.h" | 30 #include "gpu/command_buffer/common/debug_marker_manager.h" |
| 30 #include "gpu/command_buffer/common/gles2_cmd_utils.h" | 31 #include "gpu/command_buffer/common/gles2_cmd_utils.h" |
| 31 | 32 |
| 32 #if !defined(NDEBUG) && !defined(__native_client__) && !defined(GLES2_CONFORMANC
E_TESTS) // NOLINT | 33 #if !defined(NDEBUG) && !defined(__native_client__) && !defined(GLES2_CONFORMANC
E_TESTS) // NOLINT |
| 33 #if defined(GLES2_INLINE_OPTIMIZATION) | 34 #if defined(GLES2_INLINE_OPTIMIZATION) |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 (ptr[0] == static_cast<type>(0) || ptr[0] == static_cast<type>(-1))); | 92 (ptr[0] == static_cast<type>(0) || ptr[0] == static_cast<type>(-1))); |
| 92 | 93 |
| 93 #define GPU_CLIENT_VALIDATE_DESTINATION_OPTIONAL_INITALIZATION(type, ptr) \ | 94 #define GPU_CLIENT_VALIDATE_DESTINATION_OPTIONAL_INITALIZATION(type, ptr) \ |
| 94 GPU_CLIENT_VALIDATE_DESTINATION_INITALIZATION_ASSERT(!ptr || \ | 95 GPU_CLIENT_VALIDATE_DESTINATION_INITALIZATION_ASSERT(!ptr || \ |
| 95 (ptr[0] == static_cast<type>(0) || ptr[0] == static_cast<type>(-1))); | 96 (ptr[0] == static_cast<type>(0) || ptr[0] == static_cast<type>(-1))); |
| 96 | 97 |
| 97 struct GLUniformDefinitionCHROMIUM; | 98 struct GLUniformDefinitionCHROMIUM; |
| 98 | 99 |
| 99 namespace gpu { | 100 namespace gpu { |
| 100 | 101 |
| 101 class MappedMemoryManager; | |
| 102 class ScopedTransferBufferPtr; | 102 class ScopedTransferBufferPtr; |
| 103 class TransferBufferInterface; | 103 class TransferBufferInterface; |
| 104 | 104 |
| 105 namespace gles2 { | 105 namespace gles2 { |
| 106 | 106 |
| 107 class ImageFactory; | 107 class ImageFactory; |
| 108 class VertexArrayObjectManager; | 108 class VertexArrayObjectManager; |
| 109 | 109 |
| 110 // This class emulates GLES2 over command buffers. It can be used by a client | 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 | 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 | 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 | 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 | 114 // GLES2CmdHelper but that entails changing your code to use and deal with |
| 115 // shared memory and synchronization issues. | 115 // shared memory and synchronization issues. |
| 116 class GLES2_IMPL_EXPORT GLES2Implementation : public GLES2Interface { | 116 class GLES2_IMPL_EXPORT GLES2Implementation : public GLES2Interface { |
| 117 public: | 117 public: |
| 118 enum MappedMemoryLimit { |
| 119 kNoLimit = MappedMemoryManager::kNoLimit, |
| 120 }; |
| 118 class ErrorMessageCallback { | 121 class ErrorMessageCallback { |
| 119 public: | 122 public: |
| 120 virtual ~ErrorMessageCallback() { } | 123 virtual ~ErrorMessageCallback() { } |
| 121 virtual void OnErrorMessage(const char* msg, int id) = 0; | 124 virtual void OnErrorMessage(const char* msg, int id) = 0; |
| 122 }; | 125 }; |
| 123 | 126 |
| 124 // Stores GL state that never changes. | 127 // Stores GL state that never changes. |
| 125 struct GLES2_IMPL_EXPORT GLStaticState { | 128 struct GLES2_IMPL_EXPORT GLStaticState { |
| 126 GLStaticState(); | 129 GLStaticState(); |
| 127 ~GLStaticState(); | 130 ~GLStaticState(); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 bool bind_generates_resource, | 182 bool bind_generates_resource, |
| 180 ImageFactory* image_factory); | 183 ImageFactory* image_factory); |
| 181 | 184 |
| 182 virtual ~GLES2Implementation(); | 185 virtual ~GLES2Implementation(); |
| 183 | 186 |
| 184 bool Initialize( | 187 bool Initialize( |
| 185 unsigned int starting_transfer_buffer_size, | 188 unsigned int starting_transfer_buffer_size, |
| 186 unsigned int min_transfer_buffer_size, | 189 unsigned int min_transfer_buffer_size, |
| 187 unsigned int max_transfer_buffer_size); | 190 unsigned int max_transfer_buffer_size); |
| 188 | 191 |
| 192 bool InitializeWithMemoryLimit( |
| 193 unsigned int starting_transfer_buffer_size, |
| 194 unsigned int min_transfer_buffer_size, |
| 195 unsigned int max_transfer_buffer_size, |
| 196 unsigned int mapped_memory_limit); |
| 197 |
| 189 // The GLES2CmdHelper being used by this GLES2Implementation. You can use | 198 // The GLES2CmdHelper being used by this GLES2Implementation. You can use |
| 190 // this to issue cmds at a lower level for certain kinds of optimization. | 199 // this to issue cmds at a lower level for certain kinds of optimization. |
| 191 GLES2CmdHelper* helper() const; | 200 GLES2CmdHelper* helper() const; |
| 192 | 201 |
| 193 // Gets client side generated errors. | 202 // Gets client side generated errors. |
| 194 GLenum GetClientSideGLError(); | 203 GLenum GetClientSideGLError(); |
| 195 | 204 |
| 196 // Include the auto-generated part of this class. We split this because | 205 // Include the auto-generated part of this class. We split this because |
| 197 // it means we can easily edit the non-auto generated parts right here in | 206 // it means we can easily edit the non-auto generated parts right here in |
| 198 // this file instead of having to edit some template or the code generator. | 207 // this file instead of having to edit some template or the code generator. |
| 199 #include "gpu/command_buffer/client/gles2_implementation_autogen.h" | 208 #include "gpu/command_buffer/client/gles2_implementation_autogen.h" |
| 200 | 209 |
| 201 virtual void DisableVertexAttribArray(GLuint index) OVERRIDE; | 210 virtual void DisableVertexAttribArray(GLuint index) OVERRIDE; |
| 202 virtual void EnableVertexAttribArray(GLuint index) OVERRIDE; | 211 virtual void EnableVertexAttribArray(GLuint index) OVERRIDE; |
| 203 virtual void GetVertexAttribfv( | 212 virtual void GetVertexAttribfv( |
| 204 GLuint index, GLenum pname, GLfloat* params) OVERRIDE; | 213 GLuint index, GLenum pname, GLfloat* params) OVERRIDE; |
| 205 virtual void GetVertexAttribiv( | 214 virtual void GetVertexAttribiv( |
| 206 GLuint index, GLenum pname, GLint* params) OVERRIDE; | 215 GLuint index, GLenum pname, GLint* params) OVERRIDE; |
| 207 | 216 |
| 208 void GetProgramInfoCHROMIUMHelper(GLuint program, std::vector<int8>* result); | 217 void GetProgramInfoCHROMIUMHelper(GLuint program, std::vector<int8>* result); |
| 209 GLint GetAttribLocationHelper(GLuint program, const char* name); | 218 GLint GetAttribLocationHelper(GLuint program, const char* name); |
| 210 GLint GetUniformLocationHelper(GLuint program, const char* name); | 219 GLint GetUniformLocationHelper(GLuint program, const char* name); |
| 211 bool GetActiveAttribHelper( | 220 bool GetActiveAttribHelper( |
| 212 GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, | 221 GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, |
| 213 GLint* size, GLenum* type, char* name); | 222 GLint* size, GLenum* type, char* name); |
| 214 bool GetActiveUniformHelper( | 223 bool GetActiveUniformHelper( |
| 215 GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, | 224 GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, |
| 216 GLint* size, GLenum* type, char* name); | 225 GLint* size, GLenum* type, char* name); |
| 217 | 226 |
| 218 void SetSharedMemoryChunkSizeMultiple(unsigned int multiple); | |
| 219 | 227 |
| 220 void FreeUnusedSharedMemory(); | 228 void FreeUnusedSharedMemory(); |
| 221 void FreeEverything(); | 229 void FreeEverything(); |
| 222 | 230 |
| 223 void SetErrorMessageCallback(ErrorMessageCallback* callback) { | 231 void SetErrorMessageCallback(ErrorMessageCallback* callback) { |
| 224 error_message_callback_ = callback; | 232 error_message_callback_ = callback; |
| 225 } | 233 } |
| 226 | 234 |
| 227 ShareGroup* share_group() const { | 235 ShareGroup* share_group() const { |
| 228 return share_group_.get(); | 236 return share_group_.get(); |
| (...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 703 | 711 |
| 704 inline bool GLES2Implementation::GetTexParameterivHelper( | 712 inline bool GLES2Implementation::GetTexParameterivHelper( |
| 705 GLenum /* target */, GLenum /* pname */, GLint* /* params */) { | 713 GLenum /* target */, GLenum /* pname */, GLint* /* params */) { |
| 706 return false; | 714 return false; |
| 707 } | 715 } |
| 708 | 716 |
| 709 } // namespace gles2 | 717 } // namespace gles2 |
| 710 } // namespace gpu | 718 } // namespace gpu |
| 711 | 719 |
| 712 #endif // GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_H_ | 720 #endif // GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_H_ |
| OLD | NEW |