summaryrefslogtreecommitdiffstats
path: root/gpu/command_buffer/service/buffer_manager.cc
diff options
context:
space:
mode:
authorzmo@chromium.org <zmo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-06 17:48:26 +0000
committerzmo@chromium.org <zmo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-06 17:48:26 +0000
commita8fb8f44bc56943c45bd06034fc004e22ef5da85 (patch)
tree0cf04d8183f36b63d56b3704176ea2d53b42f023 /gpu/command_buffer/service/buffer_manager.cc
parentb375601e95723c66b63b567c80dfc69544c91c43 (diff)
downloadchromium_src-a8fb8f44bc56943c45bd06034fc004e22ef5da85.zip
chromium_src-a8fb8f44bc56943c45bd06034fc004e22ef5da85.tar.gz
chromium_src-a8fb8f44bc56943c45bd06034fc004e22ef5da85.tar.bz2
Revert 186416
> Use client side arrays for GL_STREAM_DRAW attributes > > Certain GPU/drivers are slow when using constantly changing > vertex buffers. They also run out of memory as the pipeline > the buffers so while a buffer is in used being drawn to they > can't delete it immediately when you upload new data to the > buffer. > > This is an attempt to work around that issue seemlessly by > using client side arrays for buffers marked as GL_STREAM_DRAW > > BUG=178093 > > > Review URL: https://chromiumcodereview.appspot.com/12494005 TBR=gman@chromium.org Review URL: https://codereview.chromium.org/12544006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@186459 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu/command_buffer/service/buffer_manager.cc')
-rw-r--r--gpu/command_buffer/service/buffer_manager.cc86
1 files changed, 9 insertions, 77 deletions
diff --git a/gpu/command_buffer/service/buffer_manager.cc b/gpu/command_buffer/service/buffer_manager.cc
index 207ae3b..cb3062a 100644
--- a/gpu/command_buffer/service/buffer_manager.cc
+++ b/gpu/command_buffer/service/buffer_manager.cc
@@ -7,26 +7,18 @@
#include "base/debug/trace_event.h"
#include "base/logging.h"
#include "gpu/command_buffer/common/gles2_cmd_utils.h"
-#include "gpu/command_buffer/service/feature_info.h"
#include "gpu/command_buffer/service/gles2_cmd_decoder.h"
#include "gpu/command_buffer/service/memory_tracking.h"
-#include "ui/gl/gl_bindings.h"
namespace gpu {
namespace gles2 {
-BufferManager::BufferManager(
- MemoryTracker* memory_tracker,
- FeatureInfo* feature_info)
+BufferManager::BufferManager(MemoryTracker* memory_tracker)
: memory_tracker_(
new MemoryTypeTracker(memory_tracker, MemoryTracker::kManaged)),
- feature_info_(feature_info),
allow_buffers_on_multiple_targets_(false),
buffer_info_count_(0),
- have_context_(true),
- use_client_side_arrays_for_stream_buffers_(
- feature_info ? feature_info->workarounds(
- ).use_client_side_arrays_for_stream_buffers : 0) {
+ have_context_(true) {
}
BufferManager::~BufferManager() {
@@ -78,8 +70,7 @@ Buffer::Buffer(BufferManager* manager, GLuint service_id)
target_(0),
size_(0),
usage_(GL_STATIC_DRAW),
- shadowed_(false),
- is_client_side_array_(false) {
+ shadowed_(false) {
manager_->StartTracking(this);
}
@@ -95,24 +86,14 @@ Buffer::~Buffer() {
}
void Buffer::SetInfo(
- GLsizeiptr size, GLenum usage, bool shadow, const GLvoid* data,
- bool is_client_side_array) {
+ GLsizeiptr size, GLenum usage, bool shadow) {
usage_ = usage;
- is_client_side_array_ = is_client_side_array;
if (size != size_ || shadow != shadowed_) {
shadowed_ = shadow;
size_ = size;
ClearCache();
if (shadowed_) {
shadow_.reset(new int8[size]);
- } else {
- shadow_.reset();
- }
- }
- if (shadowed_) {
- if (data) {
- memcpy(shadow_.get(), data, size);
- } else {
memset(shadow_.get(), 0, size);
}
}
@@ -236,66 +217,17 @@ bool BufferManager::GetClientId(GLuint service_id, GLuint* client_id) const {
return false;
}
-bool BufferManager::IsUsageClientSideArray(GLenum usage) {
- return usage == GL_STREAM_DRAW && use_client_side_arrays_for_stream_buffers_;
-}
-
void BufferManager::SetInfo(
- Buffer* info, GLsizeiptr size, GLenum usage, const GLvoid* data) {
+ Buffer* info, GLsizeiptr size, GLenum usage) {
DCHECK(info);
memory_tracker_->TrackMemFree(info->size());
- bool is_client_side_array = IsUsageClientSideArray(usage);
- bool shadow = info->target() == GL_ELEMENT_ARRAY_BUFFER ||
- allow_buffers_on_multiple_targets_ ||
- is_client_side_array;
- info->SetInfo(size, usage, shadow, data, is_client_side_array);
+ info->SetInfo(size,
+ usage,
+ info->target() == GL_ELEMENT_ARRAY_BUFFER ||
+ allow_buffers_on_multiple_targets_);
memory_tracker_->TrackMemAlloc(info->size());
}
-void BufferManager::DoBufferData(
- GLES2Decoder* decoder,
- Buffer* buffer,
- GLsizeiptr size,
- GLenum usage,
- const GLvoid* data) {
- // Clear the buffer to 0 if no initial data was passed in.
- scoped_array<int8> zero;
- if (!data) {
- zero.reset(new int8[size]);
- memset(zero.get(), 0, size);
- data = zero.get();
- }
-
- decoder->CopyRealGLErrorsToWrapper();
- if (IsUsageClientSideArray(usage)) {
- glBufferData(buffer->target(), 0, NULL, usage);
- } else {
- glBufferData(buffer->target(), size, data, usage);
- }
- GLenum error = decoder->PeekGLError();
- if (error == GL_NO_ERROR) {
- SetInfo(buffer, size, usage, data);
- } else {
- SetInfo(buffer, 0, usage, NULL);
- }
-}
-
-void BufferManager::DoBufferSubData(
- GLES2Decoder* decoder,
- Buffer* buffer,
- GLintptr offset,
- GLsizeiptr size,
- const GLvoid* data) {
- if (!buffer->SetRange(offset, size, data)) {
- decoder->SetGLError(GL_INVALID_VALUE, "glBufferSubData", "out of range");
- return;
- }
-
- if (!buffer->IsClientSideArray()) {
- glBufferSubData(buffer->target(), offset, size, data);
- }
-}
-
bool BufferManager::SetTarget(Buffer* info, GLenum target) {
// Check that we are not trying to bind it to a different target.
if (info->target() != 0 && info->target() != target &&