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

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

Issue 2435803004: Initialize buffers before allowing access to them. (Closed)
Patch Set: win failure Created 4 years, 2 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
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 bb69e7dfe0c2f2603a82f662b039868c4f0a0de4..845824c56679ceaf6cfce6d27ddd8a8e5cc34a9f 100644
--- a/gpu/command_buffer/service/buffer_manager.h
+++ b/gpu/command_buffer/service/buffer_manager.h
@@ -78,9 +78,8 @@ class GPU_EXPORT Buffer : public base::RefCounted<Buffer> {
// Check if an offset, size range is valid for the current buffer.
bool CheckRange(GLintptr offset, GLsizeiptr size) const;
- // Sets a range of this buffer's shadowed data. Returns false if offset/size
- // is out of range.
- bool SetRange(GLintptr offset, GLsizeiptr size, const GLvoid * data);
+ // Sets a range of this buffer's shadowed data.
+ void SetRange(GLintptr offset, GLsizeiptr size, const GLvoid * data);
bool IsDeleted() const {
return deleted_;
@@ -96,15 +95,8 @@ class GPU_EXPORT Buffer : public base::RefCounted<Buffer> {
void SetMappedRange(GLintptr offset, GLsizeiptr size, GLenum access,
void* pointer, scoped_refptr<gpu::Buffer> shm,
- unsigned int shm_offset) {
- mapped_range_.reset(
- new MappedRange(offset, size, access, pointer, shm, shm_offset));
- }
-
- void RemoveMappedRange() {
- mapped_range_.reset(nullptr);
- }
-
+ unsigned int shm_offset);
+ void RemoveMappedRange();
const MappedRange* GetMappedRange() const {
return mapped_range_.get();
}
@@ -306,6 +298,30 @@ class GPU_EXPORT BufferManager : public base::trace_event::MemoryDumpProvider {
bool OnMemoryDump(const base::trace_event::MemoryDumpArgs& args,
base::trace_event::ProcessMemoryDump* pmd) override;
+ // Validate if a buffer is bound at target, if it's unmapped, if it's
+ // large enough. Return the buffer bound to |target| if access is granted;
+ // return nullptr if a GL error is generated.
+ Buffer* RequestBufferAccess(ContextState* context_state,
+ GLenum target,
+ GLintptr offset,
+ GLsizeiptr size,
+ const char* func_name);
+ // Same as above, but assume to access the entire buffer.
+ Buffer* RequestBufferAccess(ContextState* context_state,
+ GLenum target,
+ const char* func_name);
+ // Same as above, but it can be any buffer rather than the buffer bound to
+ // |target|. Return true if access is granted; return false if a GL error is
+ // generated.
+ bool RequestBufferAccess(ErrorState* error_state,
+ Buffer* buffer,
+ const char* func_name,
+ const char* message_tag);
+
+ uint32_t mapped_buffer_count() const {
piman 2016/10/24 22:47:11 nit: I didn't see being used. Is that for a follow
+ return mapped_buffer_count_;
+ }
+
private:
friend class Buffer;
friend class TestHelper; // Needs access to DoBufferData.
@@ -318,7 +334,6 @@ class GPU_EXPORT BufferManager : public base::trace_event::MemoryDumpProvider {
// Does a glBufferSubData and updates the appropriate accounting.
// Assumes the values have already been validated.
void DoBufferSubData(
- ErrorState* error_state,
Buffer* buffer,
GLenum target,
GLintptr offset,
@@ -357,6 +372,9 @@ class GPU_EXPORT BufferManager : public base::trace_event::MemoryDumpProvider {
GLenum usage,
bool use_shadow);
+ void IncreaseMappedBufferCount();
+ void DecreaseMappedBufferCount();
+
std::unique_ptr<MemoryTypeTracker> memory_type_tracker_;
MemoryTracker* memory_tracker_;
scoped_refptr<FeatureInfo> feature_info_;
@@ -383,6 +401,10 @@ class GPU_EXPORT BufferManager : public base::trace_event::MemoryDumpProvider {
bool lost_context_;
bool use_client_side_arrays_for_stream_buffers_;
+ // Keep track of total mapped buffer count. In most use cases it should be 0,
+ // so we could bypass checking each individual buffer as an optimization.
+ uint32_t mapped_buffer_count_;
+
DISALLOW_COPY_AND_ASSIGN(BufferManager);
};
« no previous file with comments | « content/test/gpu/gpu_tests/webgl_conformance_expectations.py ('k') | gpu/command_buffer/service/buffer_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698