summaryrefslogtreecommitdiffstats
path: root/gpu/command_buffer
diff options
context:
space:
mode:
Diffstat (limited to 'gpu/command_buffer')
-rwxr-xr-xgpu/command_buffer/build_gles2_cmd_buffer.py19
-rw-r--r--gpu/command_buffer/client/gles2_implementation.cc45
-rw-r--r--gpu/command_buffer/client/gles2_implementation.h16
-rw-r--r--gpu/command_buffer/client/gles2_implementation_impl_autogen.h4
4 files changed, 54 insertions, 30 deletions
diff --git a/gpu/command_buffer/build_gles2_cmd_buffer.py b/gpu/command_buffer/build_gles2_cmd_buffer.py
index 1c7b019..a9e13bc 100755
--- a/gpu/command_buffer/build_gles2_cmd_buffer.py
+++ b/gpu/command_buffer/build_gles2_cmd_buffer.py
@@ -1283,6 +1283,7 @@ _PEPPER_INTERFACES = [
# extension_flag: Function is an extension and should be enabled only when
# the corresponding feature info flag is enabled. Implies
# 'extension': True.
+# not_shared: For GENn types, True if objects can't be shared between contexts
_FUNCTION_INFO = {
'ActiveTexture': {
@@ -2353,6 +2354,7 @@ _FUNCTION_INFO = {
'resource_types': 'Queries',
'unit_test': False,
'pepper_interface': 'Query',
+ 'not_shared': 'True',
},
'DeleteQueriesEXT': {
'type': 'DELn',
@@ -4048,9 +4050,20 @@ class GENnHandler(TypeHandler):
self.WriteClientGLCallLog(func, file)
for arg in func.GetOriginalArgs():
arg.WriteClientSideValidationCode(file, func)
- code = """ GPU_CLIENT_SINGLE_THREAD_CHECK();
- GetIdHandler(id_namespaces::k%(resource_types)s)->
- MakeIds(this, 0, %(args)s);
+ not_shared = func.GetInfo('not_shared')
+ if not_shared:
+ alloc_code = (
+""" IdAllocatorInterface* id_allocator = GetIdAllocator(id_namespaces::k%s);
+ for (GLsizei ii = 0; ii < n; ++ii)
+ %s[ii] = id_allocator->AllocateID();""" %
+ (func.GetInfo('resource_types'), func.GetOriginalArgs()[1].name))
+ else:
+ alloc_code = (""" GetIdHandler(id_namespaces::k%(resource_types)s)->
+ MakeIds(this, 0, %(args)s);""" % args)
+ args['alloc_code'] = alloc_code
+
+ code = """ GPU_CLIENT_SINGLE_THREAD_CHECK();
+%(alloc_code)s
%(name)sHelper(%(args)s);
helper_->%(name)sImmediate(%(args)s);
if (share_group_->bind_generates_resource())
diff --git a/gpu/command_buffer/client/gles2_implementation.cc b/gpu/command_buffer/client/gles2_implementation.cc
index 716fb55..91e6031 100644
--- a/gpu/command_buffer/client/gles2_implementation.cc
+++ b/gpu/command_buffer/client/gles2_implementation.cc
@@ -192,6 +192,7 @@ bool GLES2Implementation::Initialize(
buffer_tracker_.reset(new BufferTracker(mapped_memory_.get()));
gpu_memory_buffer_tracker_.reset(new GpuMemoryBufferTracker(gpu_control_));
+ 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]);
@@ -325,6 +326,14 @@ IdHandlerInterface* GLES2Implementation::GetIdHandler(int namespace_id) const {
return share_group_->GetIdHandler(namespace_id);
}
+IdAllocatorInterface* GLES2Implementation::GetIdAllocator(
+ int namespace_id) const {
+ if (namespace_id == id_namespaces::kQueries)
+ return query_id_allocator_.get();
+ NOTREACHED();
+ return NULL;
+}
+
void* GLES2Implementation::GetResultBuffer() {
return transfer_buffer_->GetResultBuffer();
}
@@ -568,7 +577,7 @@ bool GLES2Implementation::GetBucketContents(uint32 bucket_id,
offset += size_to_copy;
size -= size_to_copy;
buffer.Release();
- };
+ }
// Free the bucket. This is not required but it does free up the memory.
// and we don't have to wait for the result so from the client's perspective
// it's cheap.
@@ -1321,7 +1330,10 @@ void GLES2Implementation::VertexAttribDivisorANGLE(
}
void GLES2Implementation::ShaderSource(
- GLuint shader, GLsizei count, const GLchar* const* source, const GLint* length) {
+ GLuint shader,
+ GLsizei count,
+ const GLchar* const* source,
+ const GLint* length) {
GPU_CLIENT_SINGLE_THREAD_CHECK();
GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glShaderSource("
<< shader << ", " << count << ", "
@@ -1581,8 +1593,7 @@ BufferTracker::Buffer*
GLES2Implementation::GetBoundPixelUnpackTransferBufferIfValid(
GLuint buffer_id,
const char* function_name,
- GLuint offset, GLsizei size)
-{
+ GLuint offset, GLsizei size) {
DCHECK(buffer_id);
BufferTracker::Buffer* buffer = buffer_tracker_->GetBuffer(buffer_id);
if (!buffer) {
@@ -3285,7 +3296,7 @@ void GLES2Implementation::GetProgramInfoCHROMIUM(
}
// Make sure they've set size to 0 else the value will be undefined on
// lost context.
- DCHECK(*size == 0);
+ DCHECK_EQ(0, *size);
std::vector<int8> result;
GetProgramInfoCHROMIUMHelper(program, &result);
if (result.empty()) {
@@ -3332,26 +3343,14 @@ void GLES2Implementation::PostSubBufferCHROMIUM(
void GLES2Implementation::DeleteQueriesEXTHelper(
GLsizei n, const GLuint* queries) {
- // TODO(gman): Remove this as queries are not shared resources.
- if (!GetIdHandler(id_namespaces::kQueries)->FreeIds(
- this, n, queries, &GLES2Implementation::DeleteQueriesStub)) {
- SetGLError(
- GL_INVALID_VALUE,
- "glDeleteTextures", "id not created by this context.");
- return;
- }
-
- for (GLsizei ii = 0; ii < n; ++ii)
+ for (GLsizei ii = 0; ii < n; ++ii) {
query_tracker_->RemoveQuery(queries[ii]);
+ query_id_allocator_->FreeID(queries[ii]);
+ }
helper_->DeleteQueriesEXTImmediate(n, queries);
}
-// TODO(gman): Remove this. Queries are not shared resources.
-void GLES2Implementation::DeleteQueriesStub(
- GLsizei /* n */, const GLuint* /* queries */) {
-}
-
GLboolean GLES2Implementation::IsQueryEXT(GLuint id) {
GPU_CLIENT_SINGLE_THREAD_CHECK();
GPU_CLIENT_LOG("[" << GetLogPrefix() << "] IsQueryEXT(" << id << ")");
@@ -3382,7 +3381,11 @@ void GLES2Implementation::BeginQueryEXT(GLenum target, GLuint id) {
return;
}
- // TODO(gman) if id not GENned INV_OPERATION
+ // if not GENned INV_OPERATION
+ if (!query_id_allocator_->InUse(id)) {
+ SetGLError(GL_INVALID_OPERATION, "glBeginQueryEXT", "invalid id");
+ return;
+ }
// if id does not have an object
QueryTracker::Query* query = query_tracker_->GetQuery(id);
diff --git a/gpu/command_buffer/client/gles2_implementation.h b/gpu/command_buffer/client/gles2_implementation.h
index 55d42d5..0c6e916 100644
--- a/gpu/command_buffer/client/gles2_implementation.h
+++ b/gpu/command_buffer/client/gles2_implementation.h
@@ -7,20 +7,22 @@
#include <GLES2/gl2.h>
+#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
+#include <utility>
#include <vector>
#include "base/compiler_specific.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
-#include "gles2_impl_export.h"
#include "gpu/command_buffer/client/buffer_tracker.h"
#include "gpu/command_buffer/client/client_context_state.h"
#include "gpu/command_buffer/client/context_support.h"
#include "gpu/command_buffer/client/gles2_cmd_helper.h"
+#include "gpu/command_buffer/client/gles2_impl_export.h"
#include "gpu/command_buffer/client/gles2_interface.h"
#include "gpu/command_buffer/client/gpu_memory_buffer_tracker.h"
#include "gpu/command_buffer/client/mapped_memory.h"
@@ -31,6 +33,7 @@
#include "gpu/command_buffer/common/capabilities.h"
#include "gpu/command_buffer/common/debug_marker_manager.h"
#include "gpu/command_buffer/common/gles2_cmd_utils.h"
+#include "gpu/command_buffer/common/id_allocator.h"
#if !defined(NDEBUG) && !defined(__native_client__) && !defined(GLES2_CONFORMANCE_TESTS) // NOLINT
#if defined(GLES2_INLINE_OPTIMIZATION)
@@ -153,7 +156,7 @@ class GLES2_IMPL_EXPORT GLES2Implementation
};
IntState int_state;
- typedef std::pair<GLenum,GLenum> ShaderPrecisionKey;
+ typedef std::pair<GLenum, GLenum> ShaderPrecisionKey;
typedef std::map<ShaderPrecisionKey,
cmds::GetShaderPrecisionFormat::Result>
ShaderPrecisionMap;
@@ -382,7 +385,7 @@ class GLES2_IMPL_EXPORT GLES2Implementation
// Checks for single threaded access.
class SingleThreadChecker {
public:
- SingleThreadChecker(GLES2Implementation* gles2_implementation);
+ explicit SingleThreadChecker(GLES2Implementation* gles2_implementation);
~SingleThreadChecker();
private:
@@ -531,8 +534,6 @@ class GLES2_IMPL_EXPORT GLES2Implementation
void DeleteTexturesStub(GLsizei n, const GLuint* textures);
void DeleteProgramStub(GLsizei n, const GLuint* programs);
void DeleteShaderStub(GLsizei n, const GLuint* shaders);
- // TODO(gman): Remove this as queries are not shared.
- void DeleteQueriesStub(GLsizei n, const GLuint* queries);
void DeleteVertexArraysOESStub(GLsizei n, const GLuint* arrays);
void BufferDataHelper(
@@ -592,6 +593,10 @@ class GLES2_IMPL_EXPORT GLES2Implementation
bool SetCapabilityState(GLenum cap, bool enabled);
IdHandlerInterface* GetIdHandler(int id_namespace) const;
+ // IdAllocators for objects that can't be shared among contexts.
+ // For now, used only for Queries. TODO(hj.r.chung) Should be added for
+ // Framebuffer and Vertex array objects.
+ IdAllocatorInterface* GetIdAllocator(int id_namespace) const;
void FinishHelper();
@@ -764,6 +769,7 @@ class GLES2_IMPL_EXPORT GLES2Implementation
scoped_ptr<QueryTracker> query_tracker_;
typedef std::map<GLuint, QueryTracker::Query*> QueryMap;
QueryMap current_queries_;
+ scoped_ptr<IdAllocatorInterface> query_id_allocator_;
scoped_ptr<BufferTracker> buffer_tracker_;
diff --git a/gpu/command_buffer/client/gles2_implementation_impl_autogen.h b/gpu/command_buffer/client/gles2_implementation_impl_autogen.h
index 4f721a8..9d9a020 100644
--- a/gpu/command_buffer/client/gles2_implementation_impl_autogen.h
+++ b/gpu/command_buffer/client/gles2_implementation_impl_autogen.h
@@ -1842,7 +1842,9 @@ void GLES2Implementation::GenQueriesEXT(GLsizei n, GLuint* queries) {
return;
}
GPU_CLIENT_SINGLE_THREAD_CHECK();
- GetIdHandler(id_namespaces::kQueries)->MakeIds(this, 0, n, queries);
+ IdAllocatorInterface* id_allocator = GetIdAllocator(id_namespaces::kQueries);
+ for (GLsizei ii = 0; ii < n; ++ii)
+ queries[ii] = id_allocator->AllocateID();
GenQueriesEXTHelper(n, queries);
helper_->GenQueriesEXTImmediate(n, queries);
if (share_group_->bind_generates_resource())