summaryrefslogtreecommitdiffstats
path: root/chromium/gpu/command_buffer/client/gles2_implementation.h
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/gpu/command_buffer/client/gles2_implementation.h')
-rw-r--r--chromium/gpu/command_buffer/client/gles2_implementation.h123
1 files changed, 92 insertions, 31 deletions
diff --git a/chromium/gpu/command_buffer/client/gles2_implementation.h b/chromium/gpu/command_buffer/client/gles2_implementation.h
index 6b6877f18b3..55d42d5a436 100644
--- a/chromium/gpu/command_buffer/client/gles2_implementation.h
+++ b/chromium/gpu/command_buffer/client/gles2_implementation.h
@@ -110,6 +110,12 @@ namespace gles2 {
class ImageFactory;
class VertexArrayObjectManager;
+class GLES2ImplementationErrorMessageCallback {
+ public:
+ virtual ~GLES2ImplementationErrorMessageCallback() { }
+ virtual void OnErrorMessage(const char* msg, int id) = 0;
+};
+
// This class emulates GLES2 over command buffers. It can be used by a client
// program so that the program does not need deal with shared memory and command
// buffer management. See gl2_lib.h. Note that there is a performance gain to
@@ -123,11 +129,6 @@ class GLES2_IMPL_EXPORT GLES2Implementation
enum MappedMemoryLimit {
kNoLimit = MappedMemoryManager::kNoLimit,
};
- class ErrorMessageCallback {
- public:
- virtual ~ErrorMessageCallback() { }
- virtual void OnErrorMessage(const char* msg, int id) = 0;
- };
// Stores GL state that never changes.
struct GLES2_IMPL_EXPORT GLStaticState {
@@ -148,6 +149,7 @@ class GLES2_IMPL_EXPORT GLES2Implementation
GLint max_vertex_uniform_vectors;
GLint num_compressed_texture_formats;
GLint num_shader_binary_formats;
+ GLint bind_generates_resource_chromium;
};
IntState int_state;
@@ -180,13 +182,12 @@ class GLES2_IMPL_EXPORT GLES2Implementation
// Number of swap buffers allowed before waiting.
static const size_t kMaxSwapBuffers = 2;
- GLES2Implementation(
- GLES2CmdHelper* helper,
- ShareGroup* share_group,
- TransferBufferInterface* transfer_buffer,
- bool bind_generates_resource,
- bool free_everything_when_invisible,
- GpuControl* gpu_control);
+ GLES2Implementation(GLES2CmdHelper* helper,
+ ShareGroup* share_group,
+ TransferBufferInterface* transfer_buffer,
+ bool bind_generates_resource,
+ bool lose_context_when_out_of_memory,
+ GpuControl* gpu_control);
virtual ~GLES2Implementation();
@@ -217,10 +218,15 @@ class GLES2_IMPL_EXPORT GLES2Implementation
// ContextSupport implementation.
virtual void Swap() OVERRIDE;
- virtual void PartialSwapBuffers(gfx::Rect sub_buffer) OVERRIDE;
+ virtual void PartialSwapBuffers(const gfx::Rect& sub_buffer) OVERRIDE;
virtual void SetSwapBuffersCompleteCallback(
const base::Closure& swap_buffers_complete_callback)
OVERRIDE;
+ virtual void ScheduleOverlayPlane(int plane_z_order,
+ gfx::OverlayTransform plane_transform,
+ unsigned overlay_texture_id,
+ const gfx::Rect& display_bounds,
+ const gfx::RectF& uv_rect) OVERRIDE;
void GetProgramInfoCHROMIUMHelper(GLuint program, std::vector<int8>* result);
GLint GetAttribLocationHelper(GLuint program, const char* name);
@@ -241,10 +247,9 @@ class GLES2_IMPL_EXPORT GLES2Implementation
virtual void SignalQuery(uint32 query,
const base::Closure& callback) OVERRIDE;
virtual void SetSurfaceVisible(bool visible) OVERRIDE;
- virtual void SendManagedMemoryStats(const ManagedMemoryStats& stats)
- OVERRIDE;
- void SetErrorMessageCallback(ErrorMessageCallback* callback) {
+ void SetErrorMessageCallback(
+ GLES2ImplementationErrorMessageCallback* callback) {
error_message_callback_ = callback;
}
@@ -260,6 +265,10 @@ class GLES2_IMPL_EXPORT GLES2Implementation
return gpu_control_;
}
+ ShareGroupContextData* share_group_context_data() {
+ return &share_group_context_data_;
+ }
+
private:
friend class GLES2ImplementationTest;
friend class VertexArrayObjectManager;
@@ -491,12 +500,14 @@ class GLES2_IMPL_EXPORT GLES2Implementation
bool IsRenderbufferReservedId(GLuint id) { return false; }
bool IsTextureReservedId(GLuint id) { return false; }
bool IsVertexArrayReservedId(GLuint id) { return false; }
+ bool IsProgramReservedId(GLuint id) { return false; }
bool BindBufferHelper(GLenum target, GLuint texture);
bool BindFramebufferHelper(GLenum target, GLuint texture);
bool BindRenderbufferHelper(GLenum target, GLuint texture);
bool BindTextureHelper(GLenum target, GLuint texture);
- bool BindVertexArrayHelper(GLuint array);
+ bool BindVertexArrayOESHelper(GLuint array);
+ bool UseProgramHelper(GLuint program);
void GenBuffersHelper(GLsizei n, const GLuint* buffers);
void GenFramebuffersHelper(GLsizei n, const GLuint* framebuffers);
@@ -532,10 +543,12 @@ class GLES2_IMPL_EXPORT GLES2Implementation
GLenum target, GLintptr offset, GLsizeiptr size, const void* data,
ScopedTransferBufferPtr* buffer);
- GLuint CreateImageCHROMIUMHelper(
- GLsizei width, GLsizei height, GLenum internalformat);
+ GLuint CreateImageCHROMIUMHelper(GLsizei width,
+ GLsizei height,
+ GLenum internalformat,
+ GLenum usage);
void DestroyImageCHROMIUMHelper(GLuint image_id);
- void* MapImageCHROMIUMHelper(GLuint image_id, GLenum access);
+ void* MapImageCHROMIUMHelper(GLuint image_id);
void UnmapImageCHROMIUMHelper(GLuint image_id);
void GetImageParameterivCHROMIUMHelper(
GLuint image_id, GLenum pname, GLint* params);
@@ -582,15 +595,50 @@ class GLES2_IMPL_EXPORT GLES2Implementation
void FinishHelper();
- // Asserts that the context is lost.
- // NOTE: This is an expensive call and should only be called
- // for error checking.
- bool MustBeContextLost();
-
void RunIfContextNotLost(const base::Closure& callback);
void OnSwapBuffersComplete();
+ // Validate if an offset is valid, i.e., non-negative and fit into 32-bit.
+ // If not, generate an approriate error, and return false.
+ bool ValidateOffset(const char* func, GLintptr offset);
+
+ // Validate if a size is valid, i.e., non-negative and fit into 32-bit.
+ // If not, generate an approriate error, and return false.
+ bool ValidateSize(const char* func, GLsizeiptr offset);
+
+ // Remove the transfer buffer from the buffer tracker. For buffers used
+ // asynchronously the memory is free:ed if the upload has completed. For
+ // other buffers, the memory is either free:ed immediately or free:ed pending
+ // a token.
+ void RemoveTransferBuffer(BufferTracker::Buffer* buffer);
+
+ // Returns true if the async upload token has passed.
+ //
+ // NOTE: This will detect wrapped async tokens by checking if the most
+ // significant bit of async token to check is 1 but the last read is 0, i.e.
+ // the uint32 wrapped.
+ bool HasAsyncUploadTokenPassed(uint32 token) const {
+ return async_upload_sync_->HasAsyncUploadTokenPassed(token);
+ }
+
+ // Get the next async upload token.
+ uint32 NextAsyncUploadToken();
+
+ // Ensure that the shared memory used for synchronizing async upload tokens
+ // has been mapped.
+ //
+ // Returns false on error, true on success.
+ bool EnsureAsyncUploadSync();
+
+ // Checks the last read asynchronously upload token and frees any unmanaged
+ // transfer buffer that has its async token passed.
+ void PollAsyncUploads();
+
+ // Free every async upload buffer. If some async upload buffer is still in use
+ // wait for them to finish before freeing.
+ void FreeAllAsyncUploadBuffers();
+
bool GetBoundPixelTransferBuffer(
GLenum target, const char* function_name, GLuint* buffer_id);
BufferTracker::Buffer* GetBoundPixelUnpackTransferBufferIfValid(
@@ -663,6 +711,18 @@ class GLES2_IMPL_EXPORT GLES2Implementation
GLuint bound_pixel_pack_transfer_buffer_id_;
GLuint bound_pixel_unpack_transfer_buffer_id_;
+ // The current asynchronous pixel buffer upload token.
+ uint32 async_upload_token_;
+
+ // The shared memory used for synchronizing asynchronous upload tokens.
+ AsyncUploadSync* async_upload_sync_;
+ int32 async_upload_sync_shm_id_;
+ unsigned int async_upload_sync_shm_offset_;
+
+ // Unmanaged pixel transfer buffer memory pending asynchronous upload token.
+ typedef std::list<std::pair<void*, uint32> > DetachedAsyncUploadMemoryList;
+ DetachedAsyncUploadMemoryList detached_async_upload_memory_;
+
// Client side management for vertex array objects. Needed to correctly
// track client side arrays.
scoped_ptr<VertexArrayObjectManager> vertex_array_object_manager_;
@@ -675,6 +735,9 @@ class GLES2_IMPL_EXPORT GLES2Implementation
// Whether or not to print debugging info.
bool debug_;
+ // When true, the context is lost when a GL_OUT_OF_MEMORY error occurs.
+ bool lose_context_when_out_of_memory_;
+
// Used to check for single threaded access.
int use_count_;
@@ -696,26 +759,24 @@ class GLES2_IMPL_EXPORT GLES2Implementation
scoped_ptr<MappedMemoryManager> mapped_memory_;
scoped_refptr<ShareGroup> share_group_;
+ ShareGroupContextData share_group_context_data_;
scoped_ptr<QueryTracker> query_tracker_;
- QueryTracker::Query* current_query_;
+ typedef std::map<GLuint, QueryTracker::Query*> QueryMap;
+ QueryMap current_queries_;
scoped_ptr<BufferTracker> buffer_tracker_;
scoped_ptr<GpuMemoryBufferTracker> gpu_memory_buffer_tracker_;
- ErrorMessageCallback* error_message_callback_;
+ GLES2ImplementationErrorMessageCallback* error_message_callback_;
scoped_ptr<std::string> current_trace_name_;
GpuControl* gpu_control_;
- bool surface_visible_;
- bool free_everything_when_invisible_;
-
Capabilities capabilities_;
- bool use_echo_for_swap_ack_;
base::Closure swap_buffers_complete_callback_;
base::WeakPtrFactory<GLES2Implementation> weak_ptr_factory_;