diff options
author | penghuang <penghuang@chromium.org> | 2014-11-03 13:05:35 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-11-03 21:06:25 +0000 |
commit | 5527fa12043d5c268b31e3744e2e03d86b7e8231 (patch) | |
tree | 31b699415964a25def350b170448d95b00634f3b | |
parent | 00f53a49a90a56c22d412a8e0e27e3a4a6ae5155 (diff) | |
download | chromium_src-5527fa12043d5c268b31e3744e2e03d86b7e8231.zip chromium_src-5527fa12043d5c268b31e3744e2e03d86b7e8231.tar.gz chromium_src-5527fa12043d5c268b31e3744e2e03d86b7e8231.tar.bz2 |
PepperGL: Enable client side arrays support.
Currently, the client side arrays feature is controlled by a compile flag.
And the flag is only defined in nacl build. This change uses a variable to
control it. So we could enable it in runtime.
BUG=429179
Review URL: https://codereview.chromium.org/702493002
Cr-Commit-Position: refs/heads/master@{#302478}
-rw-r--r-- | content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.cc | 5 | ||||
-rw-r--r-- | gpu/BUILD.gn | 7 | ||||
-rw-r--r-- | gpu/command_buffer/client/BUILD.gn | 25 | ||||
-rw-r--r-- | gpu/command_buffer/client/gl_in_process_context.cc | 4 | ||||
-rw-r--r-- | gpu/command_buffer/client/gles2_implementation.cc | 33 | ||||
-rw-r--r-- | gpu/command_buffer/client/gles2_implementation.h | 4 | ||||
-rw-r--r-- | gpu/command_buffer/client/gles2_implementation_unittest.cc | 2 | ||||
-rw-r--r-- | gpu/command_buffer/client/vertex_array_object_manager.cc | 22 | ||||
-rw-r--r-- | gpu/command_buffer/client/vertex_array_object_manager.h | 5 | ||||
-rw-r--r-- | gpu/command_buffer/client/vertex_array_object_manager_unittest.cc | 4 | ||||
-rw-r--r-- | gpu/command_buffer/tests/gl_manager.cc | 2 | ||||
-rw-r--r-- | gpu/gles2_conform_support/egl/display.cc | 2 | ||||
-rw-r--r-- | gpu/gles2_conform_support/gles2_conform_support.gyp | 2 | ||||
-rw-r--r-- | gpu/gpu.gyp | 33 | ||||
-rw-r--r-- | ppapi/shared_impl/ppb_graphics_3d_shared.cc | 2 |
15 files changed, 52 insertions, 100 deletions
diff --git a/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.cc b/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.cc index 83d9dbf..bc76245c 100644 --- a/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.cc +++ b/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.cc @@ -240,13 +240,16 @@ bool WebGraphicsContext3DCommandBufferImpl::CreateContext(bool onscreen) { DCHECK(host_.get()); // Create the object exposing the OpenGL API. - bool bind_generates_resources = false; + const bool bind_generates_resources = false; + const bool support_client_side_arrays = false; + real_gl_.reset( new gpu::gles2::GLES2Implementation(gles2_helper_.get(), gles2_share_group.get(), transfer_buffer_.get(), bind_generates_resources, lose_context_when_out_of_memory_, + support_client_side_arrays, command_buffer_.get())); setGLInterface(real_gl_.get()); diff --git a/gpu/BUILD.gn b/gpu/BUILD.gn index bf13b05..110fb44 100644 --- a/gpu/BUILD.gn +++ b/gpu/BUILD.gn @@ -19,9 +19,6 @@ # # gpu.gyp:gles2_implementation => # //gpu/command_buffer/client:gles2_implementation - -# gpu.gyp:gles2_implementation_client_side_arrays => -# //gpu/command_buffer/client:gles2_implementation_client_side_arrays # # gpu.gyp:gpu_config => //gpu/config # @@ -114,7 +111,7 @@ test("gl_tests") { "//ui/gl", "//gpu/command_buffer/common:gles2_utils", "//gpu/command_buffer/client:gles2_c_lib", - "//gpu/command_buffer/client:gles2_implementation_client_side_arrays", + "//gpu/command_buffer/client:gles2_implementation", ] libs = [] @@ -241,7 +238,7 @@ test("gpu_unittests") { "//ui/gl", "//gpu/command_buffer/common:gles2_utils", "//gpu/command_buffer/client:gles2_c_lib", - "//gpu/command_buffer/client:gles2_implementation_client_side_arrays", + "//gpu/command_buffer/client:gles2_implementation", ] } diff --git a/gpu/command_buffer/client/BUILD.gn b/gpu/command_buffer/client/BUILD.gn index 9d8db96..810948a 100644 --- a/gpu/command_buffer/client/BUILD.gn +++ b/gpu/command_buffer/client/BUILD.gn @@ -135,31 +135,6 @@ component("gles2_implementation") { ] } -# Library emulates GLES2 using command_buffers. -component("gles2_implementation_client_side_arrays") { - sources = gles2_implementation_source_files - - defines = [ - "GLES2_IMPL_IMPLEMENTATION", - "GLES2_SUPPORT_CLIENT_SIDE_ARRAYS=1", - ] - all_dependent_configs = [ "//third_party/khronos:khronos_headers" ] - - if (is_win) { - # TODO(jschuh): crbug.com/167187 fix size_t to int truncations. - cflags = [ "/wd4267" ] # size_t to int truncation. - } - - deps = [ - ":gles2_cmd_helper", - ":gles2_interface", - "//base", - "//gpu/command_buffer/common", - "//ui/gfx/geometry", - "//ui/gl", - ] -} - component("gl_in_process_context") { sources = [ "gl_in_process_context.h", diff --git a/gpu/command_buffer/client/gl_in_process_context.cc b/gpu/command_buffer/client/gl_in_process_context.cc index 2405c0d..015a2a7 100644 --- a/gpu/command_buffer/client/gl_in_process_context.cc +++ b/gpu/command_buffer/client/gl_in_process_context.cc @@ -204,7 +204,8 @@ bool GLInProcessContextImpl::Initialize( // Check for consistency. DCHECK(!attribs.bind_generates_resource); - bool bind_generates_resource = false; + const bool bind_generates_resource = false; + const bool support_client_side_arrays = false; // Create the object exposing the OpenGL API. gles2_implementation_.reset( @@ -213,6 +214,7 @@ bool GLInProcessContextImpl::Initialize( transfer_buffer_.get(), bind_generates_resource, attribs.lose_context_when_out_of_memory, + support_client_side_arrays, command_buffer_.get())); if (use_global_share_group) { diff --git a/gpu/command_buffer/client/gles2_implementation.cc b/gpu/command_buffer/client/gles2_implementation.cc index ccb1c81..66d8c2b 100644 --- a/gpu/command_buffer/client/gles2_implementation.cc +++ b/gpu/command_buffer/client/gles2_implementation.cc @@ -25,10 +25,6 @@ #include "gpu/command_buffer/common/gles2_cmd_utils.h" #include "gpu/command_buffer/common/trace_event.h" -#if defined(__native_client__) && !defined(GLES2_SUPPORT_CLIENT_SIDE_ARRAYS) -#define GLES2_SUPPORT_CLIENT_SIDE_ARRAYS -#endif - #if defined(GPU_CLIENT_DEBUG) #include "base/command_line.h" #include "gpu/command_buffer/client/gpu_switches.h" @@ -86,6 +82,7 @@ GLES2Implementation::GLES2Implementation( TransferBufferInterface* transfer_buffer, bool bind_generates_resource, bool lose_context_when_out_of_memory, + bool support_client_side_arrays, GpuControl* gpu_control) : helper_(helper), transfer_buffer_(transfer_buffer), @@ -113,6 +110,7 @@ GLES2Implementation::GLES2Implementation( error_bits_(0), debug_(false), lose_context_when_out_of_memory_(lose_context_when_out_of_memory), + support_client_side_arrays_(support_client_side_arrays), use_count_(0), error_message_callback_(NULL), gpu_control_(gpu_control), @@ -191,15 +189,16 @@ bool GLES2Implementation::Initialize( buffer_tracker_.reset(new BufferTracker(mapped_memory_.get())); query_id_allocator_.reset(new IdAllocator()); -#if defined(GLES2_SUPPORT_CLIENT_SIDE_ARRAYS) - GetIdHandler(id_namespaces::kBuffers)->MakeIds( - this, kClientSideArrayId, arraysize(reserved_ids_), &reserved_ids_[0]); -#endif + if (support_client_side_arrays_) { + GetIdHandler(id_namespaces::kBuffers)->MakeIds( + this, kClientSideArrayId, arraysize(reserved_ids_), &reserved_ids_[0]); + } vertex_array_object_manager_.reset(new VertexArrayObjectManager( static_state_.int_state.max_vertex_attribs, reserved_ids_[0], - reserved_ids_[1])); + reserved_ids_[1], + support_client_side_arrays_)); // GL_BIND_GENERATES_RESOURCE_CHROMIUM state must be the same // on Client & Service. @@ -296,9 +295,8 @@ GLES2Implementation::~GLES2Implementation() { WaitForCmd(); query_tracker_.reset(); -#if defined(GLES2_SUPPORT_CLIENT_SIDE_ARRAYS) - DeleteBuffers(arraysize(reserved_ids_), &reserved_ids_[0]); -#endif + if (support_client_side_arrays_) + DeleteBuffers(arraysize(reserved_ids_), &reserved_ids_[0]); // Release any per-context data in share group. share_group_->FreeContext(this); @@ -1213,8 +1211,7 @@ void GLES2Implementation::VertexAttribPointer( "client side arrays are not allowed in vertex array objects."); return; } -#if defined(GLES2_SUPPORT_CLIENT_SIDE_ARRAYS) - if (bound_array_buffer_id_ != 0) { + if (!support_client_side_arrays_ || bound_array_buffer_id_ != 0) { // Only report NON client side buffers to the service. if (!ValidateOffset("glVertexAttribPointer", reinterpret_cast<GLintptr>(ptr))) { @@ -1223,14 +1220,6 @@ void GLES2Implementation::VertexAttribPointer( helper_->VertexAttribPointer(index, size, type, normalized, stride, ToGLuint(ptr)); } -#else // !defined(GLES2_SUPPORT_CLIENT_SIDE_ARRAYS) - if (!ValidateOffset("glVertexAttribPointer", - reinterpret_cast<GLintptr>(ptr))) { - return; - } - helper_->VertexAttribPointer(index, size, type, normalized, stride, - ToGLuint(ptr)); -#endif // !defined(GLES2_SUPPORT_CLIENT_SIDE_ARRAYS) CheckGLError(); } diff --git a/gpu/command_buffer/client/gles2_implementation.h b/gpu/command_buffer/client/gles2_implementation.h index 972291e..a612ac2 100644 --- a/gpu/command_buffer/client/gles2_implementation.h +++ b/gpu/command_buffer/client/gles2_implementation.h @@ -189,6 +189,7 @@ class GLES2_IMPL_EXPORT GLES2Implementation TransferBufferInterface* transfer_buffer, bool bind_generates_resource, bool lose_context_when_out_of_memory, + bool support_client_side_arrays, GpuControl* gpu_control); ~GLES2Implementation() override; @@ -736,6 +737,9 @@ class GLES2_IMPL_EXPORT GLES2Implementation // When true, the context is lost when a GL_OUT_OF_MEMORY error occurs. bool lose_context_when_out_of_memory_; + // Whether or not to support client side arrays. + bool support_client_side_arrays_; + // Used to check for single threaded access. int use_count_; diff --git a/gpu/command_buffer/client/gles2_implementation_unittest.cc b/gpu/command_buffer/client/gles2_implementation_unittest.cc index 4102060..3d2f089 100644 --- a/gpu/command_buffer/client/gles2_implementation_unittest.cc +++ b/gpu/command_buffer/client/gles2_implementation_unittest.cc @@ -445,11 +445,13 @@ class GLES2ImplementationTest : public testing::Test { .RetiresOnSaturation(); GetNextToken(); // eat the token that starting up will use. + const bool support_client_side_arrays = true; gl_.reset(new GLES2Implementation(helper_.get(), share_group, transfer_buffer_.get(), bind_generates_resource_client, lose_context_when_out_of_memory, + support_client_side_arrays, gpu_control_.get())); if (!gl_->Initialize(kTransferBufferSize, diff --git a/gpu/command_buffer/client/vertex_array_object_manager.cc b/gpu/command_buffer/client/vertex_array_object_manager.cc index 3e98bd0..a1098e9 100644 --- a/gpu/command_buffer/client/vertex_array_object_manager.cc +++ b/gpu/command_buffer/client/vertex_array_object_manager.cc @@ -8,21 +8,13 @@ #include "gpu/command_buffer/client/gles2_cmd_helper.h" #include "gpu/command_buffer/client/gles2_implementation.h" -#if defined(__native_client__) && !defined(GLES2_SUPPORT_CLIENT_SIDE_ARRAYS) -#define GLES2_SUPPORT_CLIENT_SIDE_ARRAYS -#endif - namespace gpu { namespace gles2 { -#if defined(GLES2_SUPPORT_CLIENT_SIDE_ARRAYS) - static GLsizei RoundUpToMultipleOf4(GLsizei size) { return (size + 3) & ~3; } -#endif // defined(GLES2_SUPPORT_CLIENT_SIDE_ARRAYS) - // A 32-bit and 64-bit compatible way of converting a pointer to a GLuint. static GLuint ToGLuint(const void* ptr) { return static_cast<GLuint>(reinterpret_cast<size_t>(ptr)); @@ -329,7 +321,8 @@ const VertexArrayObject::VertexAttrib* VertexArrayObject::GetAttrib( VertexArrayObjectManager::VertexArrayObjectManager( GLuint max_vertex_attribs, GLuint array_buffer_id, - GLuint element_array_buffer_id) + GLuint element_array_buffer_id, + bool support_client_side_arrays) : max_vertex_attribs_(max_vertex_attribs), array_buffer_id_(array_buffer_id), array_buffer_size_(0), @@ -338,7 +331,8 @@ VertexArrayObjectManager::VertexArrayObjectManager( element_array_buffer_size_(0), collection_buffer_size_(0), default_vertex_array_object_(new VertexArrayObject(max_vertex_attribs)), - bound_vertex_array_object_(default_vertex_array_object_) { + bound_vertex_array_object_(default_vertex_array_object_), + support_client_side_arrays_(support_client_side_arrays) { } VertexArrayObjectManager::~VertexArrayObjectManager() { @@ -483,7 +477,8 @@ bool VertexArrayObjectManager::SetupSimulatedClientSideBuffers( GLsizei primcount, bool* simulated) { *simulated = false; -#if defined(GLES2_SUPPORT_CLIENT_SIDE_ARRAYS) + if (!support_client_side_arrays_) + return true; if (!bound_vertex_array_object_->HaveEnabledClientSideBuffers()) { return true; } @@ -537,7 +532,6 @@ bool VertexArrayObjectManager::SetupSimulatedClientSideBuffers( DCHECK_LE(array_buffer_offset_, array_buffer_size_); } } -#endif // defined(GLES2_SUPPORT_CLIENT_SIDE_ARRAYS) return true; } @@ -554,7 +548,8 @@ bool VertexArrayObjectManager::SetupSimulatedIndexAndClientSideBuffers( bool* simulated) { *simulated = false; *offset = ToGLuint(indices); -#if defined(GLES2_SUPPORT_CLIENT_SIDE_ARRAYS) + if (!support_client_side_arrays_) + return true; GLsizei num_elements = 0; if (bound_vertex_array_object_->bound_element_array_buffer() == 0) { *simulated = true; @@ -630,7 +625,6 @@ bool VertexArrayObjectManager::SetupSimulatedIndexAndClientSideBuffers( function_name, gl, gl_helper, num_elements, primcount, &simulated_client_side_buffers); *simulated = *simulated || simulated_client_side_buffers; -#endif // defined(GLES2_SUPPORT_CLIENT_SIDE_ARRAYS) return true; } diff --git a/gpu/command_buffer/client/vertex_array_object_manager.h b/gpu/command_buffer/client/vertex_array_object_manager.h index 34f630d..8638584 100644 --- a/gpu/command_buffer/client/vertex_array_object_manager.h +++ b/gpu/command_buffer/client/vertex_array_object_manager.h @@ -26,7 +26,8 @@ class GLES2_IMPL_EXPORT VertexArrayObjectManager { VertexArrayObjectManager( GLuint max_vertex_attribs, GLuint array_buffer_id, - GLuint element_array_buffer_id); + GLuint element_array_buffer_id, + bool support_client_side_arrays); ~VertexArrayObjectManager(); bool IsReservedId(GLuint id) const; @@ -116,6 +117,8 @@ class GLES2_IMPL_EXPORT VertexArrayObjectManager { VertexArrayObject* bound_vertex_array_object_; VertexArrayObjectMap vertex_array_objects_; + bool support_client_side_arrays_; + DISALLOW_COPY_AND_ASSIGN(VertexArrayObjectManager); }; diff --git a/gpu/command_buffer/client/vertex_array_object_manager_unittest.cc b/gpu/command_buffer/client/vertex_array_object_manager_unittest.cc index e891184..e643baf 100644 --- a/gpu/command_buffer/client/vertex_array_object_manager_unittest.cc +++ b/gpu/command_buffer/client/vertex_array_object_manager_unittest.cc @@ -15,12 +15,14 @@ class VertexArrayObjectManagerTest : public testing::Test { static const GLuint kMaxAttribs = 4; static const GLuint kClientSideArrayBuffer = 0x1234; static const GLuint kClientSideElementArrayBuffer = 0x1235; + static const bool kSupportClientSideArrays = true; void SetUp() override { manager_.reset(new VertexArrayObjectManager( kMaxAttribs, kClientSideArrayBuffer, - kClientSideElementArrayBuffer)); + kClientSideElementArrayBuffer, + kSupportClientSideArrays)); } void TearDown() override {} diff --git a/gpu/command_buffer/tests/gl_manager.cc b/gpu/command_buffer/tests/gl_manager.cc index ffbc573..a8a7425 100644 --- a/gpu/command_buffer/tests/gl_manager.cc +++ b/gpu/command_buffer/tests/gl_manager.cc @@ -255,12 +255,14 @@ void GLManager::Initialize(const GLManager::Options& options) { transfer_buffer_.reset(new TransferBuffer(gles2_helper_.get())); // Create the object exposing the OpenGL API. + const bool support_client_side_arrays = true; gles2_implementation_.reset( new gles2::GLES2Implementation(gles2_helper_.get(), client_share_group, transfer_buffer_.get(), options.bind_generates_resource, options.lose_context_when_out_of_memory, + support_client_side_arrays, this)); ASSERT_TRUE(gles2_implementation_->Initialize( diff --git a/gpu/gles2_conform_support/egl/display.cc b/gpu/gles2_conform_support/egl/display.cc index afd5908..3fc17b9 100644 --- a/gpu/gles2_conform_support/egl/display.cc +++ b/gpu/gles2_conform_support/egl/display.cc @@ -228,6 +228,7 @@ EGLContext Display::CreateContext(EGLConfig config, bool bind_generates_resources = true; bool lose_context_when_out_of_memory = false; + bool support_client_side_arrays = true; context_.reset( new gpu::gles2::GLES2Implementation(gles2_cmd_helper_.get(), @@ -235,6 +236,7 @@ EGLContext Display::CreateContext(EGLConfig config, transfer_buffer_.get(), bind_generates_resources, lose_context_when_out_of_memory, + support_client_side_arrays, this)); if (!context_->Initialize( diff --git a/gpu/gles2_conform_support/gles2_conform_support.gyp b/gpu/gles2_conform_support/gles2_conform_support.gyp index 92af9d9..928b152 100644 --- a/gpu/gles2_conform_support/gles2_conform_support.gyp +++ b/gpu/gles2_conform_support/gles2_conform_support.gyp @@ -35,7 +35,7 @@ 'dependencies': [ '../../base/base.gyp:base', '../../gpu/gpu.gyp:command_buffer_service', - '../../gpu/gpu.gyp:gles2_implementation_client_side_arrays_no_check', + '../../gpu/gpu.gyp:gles2_implementation_no_check', '../../gpu/gpu.gyp:gpu', '../../third_party/khronos/khronos.gyp:khronos_headers', '../../ui/base/ui_base.gyp:ui_base', diff --git a/gpu/gpu.gyp b/gpu/gpu.gyp index 5968dab..0878a1d 100644 --- a/gpu/gpu.gyp +++ b/gpu/gpu.gyp @@ -61,35 +61,10 @@ }, { # Library emulates GLES2 using command_buffers. - # GN version: //gpu/command_buffer/client:gles2_implementation_client_side_arrays - 'target_name': 'gles2_implementation_client_side_arrays', + 'target_name': 'gles2_implementation_no_check', 'type': '<(component)', 'defines': [ 'GLES2_IMPL_IMPLEMENTATION', - 'GLES2_SUPPORT_CLIENT_SIDE_ARRAYS=1', - ], - 'dependencies': [ - '../base/base.gyp:base', - '../third_party/khronos/khronos.gyp:khronos_headers', - '../ui/gl/gl.gyp:gl', - '../ui/gfx/gfx.gyp:gfx_geometry', - '../ui/gfx/gfx.gyp:gfx', - 'command_buffer/command_buffer.gyp:gles2_utils', - 'gles2_cmd_helper', - ], - 'sources': [ - '<@(gles2_implementation_source_files)', - ], - # TODO(jschuh): crbug.com/167187 fix size_t to int truncations. - 'msvs_disabled_warnings': [ 4267, ], - }, - { - # Library emulates GLES2 using command_buffers. - 'target_name': 'gles2_implementation_client_side_arrays_no_check', - 'type': '<(component)', - 'defines': [ - 'GLES2_IMPL_IMPLEMENTATION', - 'GLES2_SUPPORT_CLIENT_SIDE_ARRAYS=1', 'GLES2_CONFORMANCE_TESTS=1', ], 'dependencies': [ @@ -141,7 +116,7 @@ '../base/third_party/dynamic_annotations/dynamic_annotations.gyp:dynamic_annotations', 'command_buffer/command_buffer.gyp:gles2_utils', 'command_buffer_client', - 'gles2_implementation_client_side_arrays_no_check', + 'gles2_implementation_no_check', ], 'sources': [ '<@(gles2_c_lib_source_files)', @@ -197,7 +172,7 @@ 'command_buffer_service', 'gpu', 'gpu_unittest_utils', - 'gles2_implementation_client_side_arrays', + 'gles2_implementation', 'gles2_cmd_helper', 'gles2_c_lib', ], @@ -329,7 +304,7 @@ 'command_buffer_service', 'gpu', 'gpu_unittest_utils', - 'gles2_implementation_client_side_arrays', + 'gles2_implementation', 'gles2_cmd_helper', 'gles2_c_lib', #'gl_unittests', diff --git a/ppapi/shared_impl/ppb_graphics_3d_shared.cc b/ppapi/shared_impl/ppb_graphics_3d_shared.cc index 1b3677b1..32eebe6 100644 --- a/ppapi/shared_impl/ppb_graphics_3d_shared.cc +++ b/ppapi/shared_impl/ppb_graphics_3d_shared.cc @@ -119,6 +119,7 @@ bool PPB_Graphics3D_Shared::CreateGLES2Impl( const bool bind_creates_resources = true; const bool lose_context_when_out_of_memory = false; + const bool support_client_side_arrays = true; // Create the object exposing the OpenGL API. gles2_impl_.reset(new gpu::gles2::GLES2Implementation( @@ -127,6 +128,7 @@ bool PPB_Graphics3D_Shared::CreateGLES2Impl( transfer_buffer_.get(), bind_creates_resources, lose_context_when_out_of_memory, + support_client_side_arrays, GetGpuControl())); if (!gles2_impl_->Initialize( |