Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(117)

Unified Diff: gpu/command_buffer/service/buffer_manager.h

Issue 1845963003: Make sure we call glBufferData on the same data we store internally. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: shadow->use_shadow, Format, vector Clear+Insert/Resize Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | gpu/command_buffer/service/buffer_manager.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gpu/command_buffer/service/buffer_manager.h
diff --git a/gpu/command_buffer/service/buffer_manager.h b/gpu/command_buffer/service/buffer_manager.h
index ba0c232116a0e88d335ad5126321940fdffd3a92..8ababfa8cd8389e174b428549395d21807249bc0 100644
--- a/gpu/command_buffer/service/buffer_manager.h
+++ b/gpu/command_buffer/service/buffer_manager.h
@@ -9,6 +9,8 @@
#include <stdint.h>
#include <map>
+#include <vector>
+
#include "base/containers/hash_tables.h"
#include "base/logging.h"
#include "base/macros.h"
@@ -143,19 +145,26 @@ class GPU_EXPORT Buffer : public base::RefCounted<Buffer> {
initial_target_ = target;
}
- bool shadowed() const {
- return shadowed_;
- }
+ bool shadowed() const { return !shadow_.empty(); }
void MarkAsDeleted() {
deleted_ = true;
}
+ // Setup the shadow buffer. This will either initialize the shadow buffer
+ // with the passed data or clear the shadow buffer if no shadow required. This
+ // will return a pointer to the shadowed data if using shadow, otherwise will
+ // return the original data pointer.
+ const GLvoid* StageShadow(bool use_shadow,
+ GLsizeiptr size,
+ const GLvoid* data);
+
// Sets the size, usage and initial data of a buffer.
// If shadow is true then if data is NULL buffer will be initialized to 0.
- void SetInfo(
- GLsizeiptr size, GLenum usage, bool shadow, const GLvoid* data,
- bool is_client_side_array);
+ void SetInfo(GLsizeiptr size,
+ GLenum usage,
+ bool use_shadow,
+ bool is_client_side_array);
// Sets a range of data for this buffer. Returns false if the offset or size
// is out of range.
@@ -171,9 +180,9 @@ class GPU_EXPORT Buffer : public base::RefCounted<Buffer> {
// The manager that owns this Buffer.
BufferManager* manager_;
- // A copy of the data in the buffer. This data is only kept if the target
- // is backed_ = true.
- scoped_ptr<int8_t[]> shadow_;
+ // A copy of the data in the buffer. This data is only kept if the conditions
+ // checked in UseShadowBuffer() are true.
+ std::vector<uint8_t> shadow_;
// Size of buffer.
GLsizeiptr size_;
@@ -181,9 +190,6 @@ class GPU_EXPORT Buffer : public base::RefCounted<Buffer> {
// True if deleted.
bool deleted_;
- // Whether or not the data is shadowed.
- bool shadowed_;
-
// Whether or not this Buffer is not uploaded to the GPU but just
// sitting in local memory.
bool is_client_side_array_;
@@ -311,10 +317,16 @@ class GPU_EXPORT BufferManager : public base::trace_event::MemoryDumpProvider {
GLenum usage,
const GLvoid* data);
+ // Tests whether a shadow buffer needs to be used.
+ bool UseShadowBuffer(GLenum target, GLenum usage);
+
// Sets the size, usage and initial data of a buffer.
// If data is NULL buffer will be initialized to 0 if shadowed.
- void SetInfo(Buffer* buffer, GLenum target, GLsizeiptr size, GLenum usage,
- const GLvoid* data);
+ void SetInfo(Buffer* buffer,
+ GLenum target,
+ GLsizeiptr size,
+ GLenum usage,
+ bool use_shadow);
scoped_ptr<MemoryTypeTracker> memory_type_tracker_;
MemoryTracker* memory_tracker_;
« no previous file with comments | « no previous file | gpu/command_buffer/service/buffer_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698