diff options
author | gman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-21 02:59:47 +0000 |
---|---|---|
committer | gman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-21 02:59:47 +0000 |
commit | df0729f92408c852c004f3b16880e7b67866d38a (patch) | |
tree | 62d78c4a9e8e99f5724150ee62c1e2a17fe41349 /gpu | |
parent | ba29d04db72509c150a87483b145f31797a8b892 (diff) | |
download | chromium_src-df0729f92408c852c004f3b16880e7b67866d38a.zip chromium_src-df0729f92408c852c004f3b16880e7b67866d38a.tar.gz chromium_src-df0729f92408c852c004f3b16880e7b67866d38a.tar.bz2 |
Fix IsExtensionAvailable so it calls GetStringHelper
This is so it does not trigger the single threaded checks
TEST=unit test
BUG=none
R=zmo@chromium.org
Review URL: http://codereview.chromium.org/9006021
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@115265 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu')
-rwxr-xr-x | gpu/command_buffer/build_gles2_cmd_buffer.py | 1 | ||||
-rw-r--r-- | gpu/command_buffer/client/gles2_implementation.cc | 83 | ||||
-rw-r--r-- | gpu/command_buffer/client/gles2_implementation.h | 11 | ||||
-rw-r--r-- | gpu/command_buffer/client/gles2_implementation_autogen.h | 13 | ||||
-rw-r--r-- | gpu/command_buffer/common/gles2_cmd_utils_implementation_autogen.h | 4 | ||||
-rw-r--r-- | gpu/gpu.gyp | 23 |
6 files changed, 93 insertions, 42 deletions
diff --git a/gpu/command_buffer/build_gles2_cmd_buffer.py b/gpu/command_buffer/build_gles2_cmd_buffer.py index fbeb98f..9804080 100755 --- a/gpu/command_buffer/build_gles2_cmd_buffer.py +++ b/gpu/command_buffer/build_gles2_cmd_buffer.py @@ -1403,6 +1403,7 @@ _FUNCTION_INFO = { 'client_test': False, 'extension': True, 'chromium': True, + 'impl_func': False, }, 'GetMultipleIntegervCHROMIUM': { 'type': 'Custom', diff --git a/gpu/command_buffer/client/gles2_implementation.cc b/gpu/command_buffer/client/gles2_implementation.cc index cad8722..30303f1 100644 --- a/gpu/command_buffer/client/gles2_implementation.cc +++ b/gpu/command_buffer/client/gles2_implementation.cc @@ -436,7 +436,7 @@ class ClientSideBufferHelper { gl_helper->BindBuffer(GL_ARRAY_BUFFER, array_buffer_id_); array_buffer_offset_ = 0; if (total_size > array_buffer_size_) { - gl->BufferData(GL_ARRAY_BUFFER, total_size, NULL, GL_DYNAMIC_DRAW); + gl->BufferDataHelper(GL_ARRAY_BUFFER, total_size, NULL, GL_DYNAMIC_DRAW); array_buffer_size_ = total_size; } for (GLuint ii = 0; ii < max_vertex_attribs_; ++ii) { @@ -449,7 +449,7 @@ class ClientSideBufferHelper { info.stride() : static_cast<GLsizei>(bytes_per_element); GLsizei bytes_collected = CollectData( info.pointer(), bytes_per_element, real_stride, num_elements); - gl->BufferSubData( + gl->BufferSubDataHelper( GL_ARRAY_BUFFER, array_buffer_offset_, bytes_collected, collection_buffer_.get()); gl_helper->VertexAttribPointer( @@ -474,10 +474,11 @@ class ClientSideBufferHelper { GLsizei bytes_needed = bytes_per_element * count; if (bytes_needed > element_array_buffer_size_) { element_array_buffer_size_ = bytes_needed; - gl->BufferData(GL_ELEMENT_ARRAY_BUFFER, bytes_needed, NULL, - GL_DYNAMIC_DRAW); + gl->BufferDataHelper( + GL_ELEMENT_ARRAY_BUFFER, bytes_needed, NULL, GL_DYNAMIC_DRAW); } - gl->BufferSubData(GL_ELEMENT_ARRAY_BUFFER, 0, bytes_needed, indices); + gl->BufferSubDataHelper( + GL_ELEMENT_ARRAY_BUFFER, 0, bytes_needed, indices); GLsizei max_index = -1; switch (type) { case GL_UNSIGNED_BYTE: { @@ -745,10 +746,9 @@ void GLES2Implementation::WaitForCmd() { helper_->CommandBufferHelper::Finish(); } -namespace { -bool IsExtensionAvailable(GLES2Implementation* gles2, const char ext[]) { - const char* extensions = reinterpret_cast<const char*>( - gles2->GetString(GL_EXTENSIONS)); +bool GLES2Implementation::IsExtensionAvailable(const char* ext) { + const char* extensions = + reinterpret_cast<const char*>(GetStringHelper(GL_EXTENSIONS)); int length = strlen(ext); while (true) { int n = strcspn(extensions, " "); @@ -758,10 +758,9 @@ bool IsExtensionAvailable(GLES2Implementation* gles2, const char ext[]) { if ('\0' == extensions[n]) { return false; } - extensions += n+1; + extensions += n + 1; } } -} bool GLES2Implementation::IsAnglePackReverseRowOrderAvailable() { switch (angle_pack_reverse_row_order_status) { @@ -770,7 +769,7 @@ bool GLES2Implementation::IsAnglePackReverseRowOrderAvailable() { case kUnavailableExtensionStatus: return false; default: - if (IsExtensionAvailable(this, "GL_ANGLE_pack_reverse_row_order")) { + if (IsExtensionAvailable("GL_ANGLE_pack_reverse_row_order")) { angle_pack_reverse_row_order_status = kAvailableExtensionStatus; return true; } else { @@ -1018,6 +1017,30 @@ bool GLES2Implementation::GetIntegervHelper(GLenum pname, GLint* params) { return GetHelper(pname, params); } +GLuint GLES2Implementation::GetMaxValueInBufferCHROMIUMHelper( + GLuint buffer_id, GLsizei count, GLenum type, GLuint offset) { + typedef GetMaxValueInBufferCHROMIUM::Result Result; + Result* result = GetResultAs<Result*>(); + *result = 0; + helper_->GetMaxValueInBufferCHROMIUM( + buffer_id, count, type, offset, GetResultShmId(), GetResultShmOffset()); + WaitForCmd(); + return *result; +} + +GLuint GLES2Implementation::GetMaxValueInBufferCHROMIUM( + GLuint buffer_id, GLsizei count, GLenum type, GLuint offset) { + GPU_CLIENT_SINGLE_THREAD_CHECK(); + GPU_CLIENT_LOG("[" << this << "] glGetMaxValueInBufferCHROMIUM(" + << buffer_id << ", " << count << ", " + << GLES2Util::GetStringGetMaxIndexType(type) + << ", " << offset << ")"); + GLuint result = GetMaxValueInBufferCHROMIUMHelper( + buffer_id, count, type, offset); + GPU_CLIENT_LOG("returned " << result); + return result; +} + void GLES2Implementation::DrawElements( GLenum mode, GLsizei count, GLenum type, const void* indices) { GPU_CLIENT_SINGLE_THREAD_CHECK(); @@ -1050,7 +1073,7 @@ void GLES2Implementation::DrawElements( // changes the contents of any of the buffers. The service will still // validate the indices. We just need to know how much to copy across. if (have_client_side) { - num_elements = GetMaxValueInBufferCHROMIUM( + num_elements = GetMaxValueInBufferCHROMIUMHelper( bound_element_array_buffer_id_, count, type, ToGLuint(indices)) + 1; } } @@ -1482,14 +1505,8 @@ void GLES2Implementation::ShaderSource( helper_->SetBucketSize(kResultBucketId, 0); } -void GLES2Implementation::BufferData( +void GLES2Implementation::BufferDataHelper( GLenum target, GLsizeiptr size, const void* data, GLenum usage) { - GPU_CLIENT_SINGLE_THREAD_CHECK(); - GPU_CLIENT_LOG("[" << this << "] glBufferData(" - << GLES2Util::GetStringBufferTarget(target) << ", " - << size << ", " - << static_cast<const void*>(data) << ", " - << GLES2Util::GetStringBufferUsage(usage) << ")"); AlignedRingBuffer* transfer_buffer = transfer_buffer_.GetBuffer(); GLsizeiptr max_size = transfer_buffer->GetLargestFreeOrPendingSize(); if (size > max_size || !data) { @@ -1511,13 +1528,19 @@ void GLES2Implementation::BufferData( transfer_buffer->FreePendingToken(buffer, helper_->InsertToken()); } -void GLES2Implementation::BufferSubData( - GLenum target, GLintptr offset, GLsizeiptr size, const void* data) { +void GLES2Implementation::BufferData( + GLenum target, GLsizeiptr size, const void* data, GLenum usage) { GPU_CLIENT_SINGLE_THREAD_CHECK(); - GPU_CLIENT_LOG("[" << this << "] glBufferSubData(" + GPU_CLIENT_LOG("[" << this << "] glBufferData(" << GLES2Util::GetStringBufferTarget(target) << ", " - << offset << ", " << size << ", " - << static_cast<const void*>(data) << ")"); + << size << ", " + << static_cast<const void*>(data) << ", " + << GLES2Util::GetStringBufferUsage(usage) << ")"); + BufferDataHelper(target, size, data, usage); +} + +void GLES2Implementation::BufferSubDataHelper( + GLenum target, GLintptr offset, GLsizeiptr size, const void* data) { if (size == 0) { return; } @@ -1544,6 +1567,16 @@ void GLES2Implementation::BufferSubData( } } +void GLES2Implementation::BufferSubData( + GLenum target, GLintptr offset, GLsizeiptr size, const void* data) { + GPU_CLIENT_SINGLE_THREAD_CHECK(); + GPU_CLIENT_LOG("[" << this << "] glBufferSubData(" + << GLES2Util::GetStringBufferTarget(target) << ", " + << offset << ", " << size << ", " + << static_cast<const void*>(data) << ")"); + BufferSubDataHelper(target, offset, size, data); +} + void GLES2Implementation::CompressedTexImage2D( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei image_size, const void* data) { diff --git a/gpu/command_buffer/client/gles2_implementation.h b/gpu/command_buffer/client/gles2_implementation.h index 690f4ba..e186f01 100644 --- a/gpu/command_buffer/client/gles2_implementation.h +++ b/gpu/command_buffer/client/gles2_implementation.h @@ -284,6 +284,8 @@ class GLES2Implementation { void FreeEverything(); private: + friend class ClientSideBufferHelper; + // Used to track whether an extension is available enum ExtensionStatus { kAvailableExtensionStatus, @@ -465,11 +467,15 @@ class GLES2Implementation { bool DeleteProgramHelper(GLuint program); bool DeleteShaderHelper(GLuint shader); + void BufferDataHelper( + GLenum target, GLsizeiptr size, const void* data, GLenum usage); + void BufferSubDataHelper( + GLenum target, GLintptr offset, GLsizeiptr size, const void* data); + // Helper for GetVertexAttrib bool GetVertexAttribHelper(GLuint index, GLenum pname, uint32* param); - // Asks the service for the max index in an element array buffer. - GLsizei GetMaxIndexInElementArrayBuffer( + GLuint GetMaxValueInBufferCHROMIUMHelper( GLuint buffer_id, GLsizei count, GLenum type, GLuint offset); bool CopyRectToBufferFlipped( @@ -496,6 +502,7 @@ class GLES2Implementation { bool GetTexParameterivHelper(GLenum target, GLenum pname, GLint* params); const GLubyte* GetStringHelper(GLenum name); + bool IsExtensionAvailable(const char* ext); GLES2Util util_; GLES2CmdHelper* helper_; diff --git a/gpu/command_buffer/client/gles2_implementation_autogen.h b/gpu/command_buffer/client/gles2_implementation_autogen.h index 7047d3752..abaf00c 100644 --- a/gpu/command_buffer/client/gles2_implementation_autogen.h +++ b/gpu/command_buffer/client/gles2_implementation_autogen.h @@ -1358,18 +1358,7 @@ void TexStorage2DEXT( void SwapBuffers(); GLuint GetMaxValueInBufferCHROMIUM( - GLuint buffer_id, GLsizei count, GLenum type, GLuint offset) { - GPU_CLIENT_SINGLE_THREAD_CHECK(); - GPU_CLIENT_LOG("[" << this << "] glGetMaxValueInBufferCHROMIUM(" << buffer_id << ", " << count << ", " << GLES2Util::GetStringGetMaxIndexType(type) << ", " << offset << ")"); // NOLINT - typedef GetMaxValueInBufferCHROMIUM::Result Result; - Result* result = GetResultAs<Result*>(); - *result = 0; - helper_->GetMaxValueInBufferCHROMIUM( - buffer_id, count, type, offset, GetResultShmId(), GetResultShmOffset()); - WaitForCmd(); - GPU_CLIENT_LOG("returned " << *result); - return *result; -} + GLuint buffer_id, GLsizei count, GLenum type, GLuint offset); void GenSharedIdsCHROMIUM( GLuint namespace_id, GLuint id_offset, GLsizei n, GLuint* ids); diff --git a/gpu/command_buffer/common/gles2_cmd_utils_implementation_autogen.h b/gpu/command_buffer/common/gles2_cmd_utils_implementation_autogen.h index 572db3f..8433c1d 100644 --- a/gpu/command_buffer/common/gles2_cmd_utils_implementation_autogen.h +++ b/gpu/command_buffer/common/gles2_cmd_utils_implementation_autogen.h @@ -205,7 +205,7 @@ static GLES2Util::EnumToString enum_to_string_table[] = { { 0x00000400, "GL_STENCIL_BUFFER_BIT", }, { 0x800A, "GL_FUNC_SUBTRACT", }, { 0x8E2C, "GL_DEPTH_COMPONENT16_NONLINEAR_NV", }, - { 0x8508, "GL_DECR_WRAP", }, + { 0x889F, "GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING", }, { 0x8006, "GL_FUNC_ADD", }, { 0x8007, "GL_MIN_EXT", }, { 0x8004, "GL_ONE_MINUS_CONSTANT_ALPHA", }, @@ -465,7 +465,7 @@ static GLES2Util::EnumToString enum_to_string_table[] = { { 0x8CE4, "GL_COLOR_ATTACHMENT4_NV", }, { 0x8CD6, "GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT", }, { 0x8872, "GL_MAX_TEXTURE_IMAGE_UNITS", }, - { 0x889F, "GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING", }, + { 0x8508, "GL_DECR_WRAP", }, { 0x8507, "GL_INCR_WRAP", }, { 0x8895, "GL_ELEMENT_ARRAY_BUFFER_BINDING", }, { 0x8894, "GL_ARRAY_BUFFER_BINDING", }, diff --git a/gpu/gpu.gyp b/gpu/gpu.gyp index 8b70850..2873c29 100644 --- a/gpu/gpu.gyp +++ b/gpu/gpu.gyp @@ -100,6 +100,27 @@ 'type': 'static_library', 'defines': [ 'GLES2_SUPPORT_CLIENT_SIDE_ARRAYS=1', + ], + 'dependencies': [ + '../base/base.gyp:base', + 'gles2_cmd_helper', + ], + 'all_dependent_settings': { + 'include_dirs': [ + # For GLES2/gl2.h + '<(DEPTH)/third_party/khronos', + ], + }, + 'sources': [ + '<@(gles2_implementation_source_files)', + ], + }, + { + # Library emulates GLES2 using command_buffers. + 'target_name': 'gles2_implementation_client_side_arrays_no_check', + 'type': 'static_library', + 'defines': [ + 'GLES2_SUPPORT_CLIENT_SIDE_ARRAYS=1', 'GLES2_CONFORMANCE_TESTS=1', ], 'dependencies': [ @@ -138,7 +159,7 @@ 'GLES2_CONFORMANCE_TESTS=1', ], 'dependencies': [ - 'gles2_implementation_client_side_arrays', + 'gles2_implementation_client_side_arrays_no_check', ], 'sources': [ '<@(gles2_c_lib_source_files)', |