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

Unified Diff: gpu/command_buffer/client/gles2_implementation.cc

Issue 371363002: Query objects should not be shared between contexts (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: reverted DCHECK -> DCHECK_NE change to avoid error Created 6 years, 5 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/client/gles2_implementation.cc
diff --git a/gpu/command_buffer/client/gles2_implementation.cc b/gpu/command_buffer/client/gles2_implementation.cc
index 716fb55fbc2eaac205d249c20f9bbd4a2e761b1a..91e6031e72ef5beb7db06086fbd409a0b596e5ce 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);
« no previous file with comments | « gpu/command_buffer/client/gles2_implementation.h ('k') | gpu/command_buffer/client/gles2_implementation_impl_autogen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698