summaryrefslogtreecommitdiffstats
path: root/gpu/command_buffer/client
diff options
context:
space:
mode:
Diffstat (limited to 'gpu/command_buffer/client')
-rw-r--r--gpu/command_buffer/client/BUILD.gn25
-rw-r--r--gpu/command_buffer/client/gl_in_process_context.cc4
-rw-r--r--gpu/command_buffer/client/gles2_implementation.cc33
-rw-r--r--gpu/command_buffer/client/gles2_implementation.h4
-rw-r--r--gpu/command_buffer/client/gles2_implementation_unittest.cc2
-rw-r--r--gpu/command_buffer/client/vertex_array_object_manager.cc22
-rw-r--r--gpu/command_buffer/client/vertex_array_object_manager.h5
-rw-r--r--gpu/command_buffer/client/vertex_array_object_manager_unittest.cc4
8 files changed, 35 insertions, 64 deletions
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 {}