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

Side by Side Diff: gpu/command_buffer/service/gles2_cmd_decoder.cc

Issue 9694025: Add support for GL_COMMANDS_ISSUED_CHROMIUM fence like query. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h"
6 6
7 #include <stdio.h> 7 #include <stdio.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <list> 10 #include <list>
(...skipping 2004 matching lines...) Expand 10 before | Expand all | Expand 10 after
2015 Destroy(); 2015 Destroy();
2016 return false; 2016 return false;
2017 } 2017 }
2018 2018
2019 CHECK_GL_ERROR(); 2019 CHECK_GL_ERROR();
2020 disallowed_features_ = disallowed_features; 2020 disallowed_features_ = disallowed_features;
2021 2021
2022 vertex_attrib_manager_.reset(new VertexAttribManager()); 2022 vertex_attrib_manager_.reset(new VertexAttribManager());
2023 vertex_attrib_manager_->Initialize(group_->max_vertex_attribs()); 2023 vertex_attrib_manager_->Initialize(group_->max_vertex_attribs());
2024 2024
2025 query_manager_.reset(new QueryManager()); 2025 query_manager_.reset(new QueryManager(this));
2026 2026
2027 util_.set_num_compressed_texture_formats( 2027 util_.set_num_compressed_texture_formats(
2028 validators_->compressed_texture_format.GetValues().size()); 2028 validators_->compressed_texture_format.GetValues().size());
2029 2029
2030 if (gfx::GetGLImplementation() != gfx::kGLImplementationEGLGLES2) { 2030 if (gfx::GetGLImplementation() != gfx::kGLImplementationEGLGLES2) {
2031 // We have to enable vertex array 0 on OpenGL or it won't render. Note that 2031 // We have to enable vertex array 0 on OpenGL or it won't render. Note that
2032 // OpenGL ES 2.0 does not have this issue. 2032 // OpenGL ES 2.0 does not have this issue.
2033 glEnableVertexAttribArray(0); 2033 glEnableVertexAttribArray(0);
2034 } 2034 }
2035 glGenBuffersARB(1, &attrib_0_buffer_id_); 2035 glGenBuffersARB(1, &attrib_0_buffer_id_);
(...skipping 1117 matching lines...) Expand 10 before | Expand all | Expand 10 after
3153 } 3153 }
3154 GLuint service_id = glCreateShader(type); 3154 GLuint service_id = glCreateShader(type);
3155 if (service_id != 0) { 3155 if (service_id != 0) {
3156 CreateShaderInfo(client_id, service_id, type); 3156 CreateShaderInfo(client_id, service_id, type);
3157 } 3157 }
3158 return true; 3158 return true;
3159 } 3159 }
3160 3160
3161 void GLES2DecoderImpl::DoFinish() { 3161 void GLES2DecoderImpl::DoFinish() {
3162 glFinish(); 3162 glFinish();
3163 if (!query_manager_->ProcessPendingQueries(this)) { 3163 if (!query_manager_->ProcessPendingQueries()) {
3164 current_decoder_error_ = error::kOutOfBounds; 3164 current_decoder_error_ = error::kOutOfBounds;
3165 } 3165 }
3166 } 3166 }
3167 3167
3168 void GLES2DecoderImpl::DoFlush() { 3168 void GLES2DecoderImpl::DoFlush() {
3169 glFlush(); 3169 glFlush();
3170 if (!query_manager_->ProcessPendingQueries(this)) { 3170 if (!query_manager_->ProcessPendingQueries()) {
3171 current_decoder_error_ = error::kOutOfBounds; 3171 current_decoder_error_ = error::kOutOfBounds;
3172 } 3172 }
3173 } 3173 }
3174 3174
3175 void GLES2DecoderImpl::DoActiveTexture(GLenum texture_unit) { 3175 void GLES2DecoderImpl::DoActiveTexture(GLenum texture_unit) {
3176 GLuint texture_index = texture_unit - GL_TEXTURE0; 3176 GLuint texture_index = texture_unit - GL_TEXTURE0;
3177 if (texture_index >= group_->max_texture_units()) { 3177 if (texture_index >= group_->max_texture_units()) {
3178 SetGLError(GL_INVALID_ENUM, "glActiveTexture: texture_unit out of range."); 3178 SetGLError(GL_INVALID_ENUM, "glActiveTexture: texture_unit out of range.");
3179 return; 3179 return;
3180 } 3180 }
(...skipping 2044 matching lines...) Expand 10 before | Expand all | Expand 10 after
5225 bool simulated_fixed_attribs = false; 5225 bool simulated_fixed_attribs = false;
5226 if (SimulateFixedAttribs(max_vertex_accessed, &simulated_fixed_attribs, 5226 if (SimulateFixedAttribs(max_vertex_accessed, &simulated_fixed_attribs,
5227 primcount)) { 5227 primcount)) {
5228 bool textures_set = SetBlackTextureForNonRenderableTextures(); 5228 bool textures_set = SetBlackTextureForNonRenderableTextures();
5229 ApplyDirtyState(); 5229 ApplyDirtyState();
5230 if (!instanced) { 5230 if (!instanced) {
5231 glDrawArrays(mode, first, count); 5231 glDrawArrays(mode, first, count);
5232 } else { 5232 } else {
5233 glDrawArraysInstancedANGLE(mode, first, count, primcount); 5233 glDrawArraysInstancedANGLE(mode, first, count, primcount);
5234 } 5234 }
5235 if (!query_manager_->ProcessPendingQueries(this)) { 5235 if (!query_manager_->ProcessPendingQueries()) {
5236 current_decoder_error_ = error::kOutOfBounds; 5236 current_decoder_error_ = error::kOutOfBounds;
5237 } 5237 }
5238 if (textures_set) { 5238 if (textures_set) {
5239 RestoreStateForNonRenderableTextures(); 5239 RestoreStateForNonRenderableTextures();
5240 } 5240 }
5241 if (simulated_fixed_attribs) { 5241 if (simulated_fixed_attribs) {
5242 RestoreStateForSimulatedFixedAttribs(); 5242 RestoreStateForSimulatedFixedAttribs();
5243 } 5243 }
5244 } 5244 }
5245 if (simulated_attrib_0) { 5245 if (simulated_attrib_0) {
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
5338 if (SimulateFixedAttribs(max_vertex_accessed, &simulated_fixed_attribs, 5338 if (SimulateFixedAttribs(max_vertex_accessed, &simulated_fixed_attribs,
5339 primcount)) { 5339 primcount)) {
5340 bool textures_set = SetBlackTextureForNonRenderableTextures(); 5340 bool textures_set = SetBlackTextureForNonRenderableTextures();
5341 ApplyDirtyState(); 5341 ApplyDirtyState();
5342 const GLvoid* indices = reinterpret_cast<const GLvoid*>(offset); 5342 const GLvoid* indices = reinterpret_cast<const GLvoid*>(offset);
5343 if (!instanced) { 5343 if (!instanced) {
5344 glDrawElements(mode, count, type, indices); 5344 glDrawElements(mode, count, type, indices);
5345 } else { 5345 } else {
5346 glDrawElementsInstancedANGLE(mode, count, type, indices, primcount); 5346 glDrawElementsInstancedANGLE(mode, count, type, indices, primcount);
5347 } 5347 }
5348 if (!query_manager_->ProcessPendingQueries(this)) { 5348 if (!query_manager_->ProcessPendingQueries()) {
5349 current_decoder_error_ = error::kOutOfBounds; 5349 current_decoder_error_ = error::kOutOfBounds;
5350 } 5350 }
5351 if (textures_set) { 5351 if (textures_set) {
5352 RestoreStateForNonRenderableTextures(); 5352 RestoreStateForNonRenderableTextures();
5353 } 5353 }
5354 if (simulated_fixed_attribs) { 5354 if (simulated_fixed_attribs) {
5355 RestoreStateForSimulatedFixedAttribs(); 5355 RestoreStateForSimulatedFixedAttribs();
5356 } 5356 }
5357 } 5357 }
5358 if (simulated_attrib_0) { 5358 if (simulated_attrib_0) {
(...skipping 2572 matching lines...) Expand 10 before | Expand all | Expand 10 after
7931 return false; 7931 return false;
7932 } 7932 }
7933 7933
7934 bool GLES2DecoderImpl::GenQueriesEXTHelper( 7934 bool GLES2DecoderImpl::GenQueriesEXTHelper(
7935 GLsizei n, const GLuint* client_ids) { 7935 GLsizei n, const GLuint* client_ids) {
7936 for (GLsizei ii = 0; ii < n; ++ii) { 7936 for (GLsizei ii = 0; ii < n; ++ii) {
7937 if (query_manager_->GetQuery(client_ids[ii])) { 7937 if (query_manager_->GetQuery(client_ids[ii])) {
7938 return false; 7938 return false;
7939 } 7939 }
7940 } 7940 }
7941 scoped_array<GLuint> service_ids(new GLuint[n]); 7941 // NOTE: We don't generate Query objects here. Only in BeginQueryEXT
7942 glGenQueriesARB(n, service_ids.get());
7943 for (GLsizei ii = 0; ii < n; ++ii) {
7944 query_manager_->CreateQuery(client_ids[ii], service_ids[ii]);
7945 }
7946 return true; 7942 return true;
7947 } 7943 }
7948 7944
7949 void GLES2DecoderImpl::DeleteQueriesEXTHelper( 7945 void GLES2DecoderImpl::DeleteQueriesEXTHelper(
7950 GLsizei n, const GLuint* client_ids) { 7946 GLsizei n, const GLuint* client_ids) {
7951 for (GLsizei ii = 0; ii < n; ++ii) { 7947 for (GLsizei ii = 0; ii < n; ++ii) {
7952 QueryManager::Query* query = query_manager_->GetQuery(client_ids[ii]); 7948 QueryManager::Query* query = query_manager_->GetQuery(client_ids[ii]);
7953 if (query && !query->IsDeleted()) { 7949 if (query && !query->IsDeleted()) {
7954 if (query == current_query_) { 7950 if (query == current_query_) {
7955 current_query_ = NULL; 7951 current_query_ = NULL;
7956 } 7952 }
7957 GLuint service_id = query->service_id(); 7953 query->Destroy(true);
7958 glDeleteQueriesARB(1, &service_id);
7959 query_manager_->RemoveQuery(client_ids[ii]); 7954 query_manager_->RemoveQuery(client_ids[ii]);
7960 } 7955 }
7961 } 7956 }
7962 } 7957 }
7963 7958
7964 error::Error GLES2DecoderImpl::HandleBeginQueryEXT( 7959 error::Error GLES2DecoderImpl::HandleBeginQueryEXT(
7965 uint32 immediate_data_size, const gles2::BeginQueryEXT& c) { 7960 uint32 immediate_data_size, const gles2::BeginQueryEXT& c) {
7966 GLenum target = static_cast<GLenum>(c.target); 7961 GLenum target = static_cast<GLenum>(c.target);
7967 GLuint client_id = static_cast<GLuint>(c.id); 7962 GLuint client_id = static_cast<GLuint>(c.id);
7968 int32 sync_shm_id = static_cast<int32>(c.sync_data_shm_id); 7963 int32 sync_shm_id = static_cast<int32>(c.sync_data_shm_id);
7969 uint32 sync_shm_offset = static_cast<uint32>(c.sync_data_shm_offset); 7964 uint32 sync_shm_offset = static_cast<uint32>(c.sync_data_shm_offset);
7970 7965
7971 if (!feature_info_->feature_flags().occlusion_query_boolean) { 7966 switch (target) {
7972 SetGLError(GL_INVALID_OPERATION, "glBeginQueryEXT: not enabled"); 7967 case GL_COMMANDS_ISSUED_CHROMIUM:
7973 return error::kNoError; 7968 break;
7969 default:
7970 if (!feature_info_->feature_flags().occlusion_query_boolean) {
7971 SetGLError(GL_INVALID_OPERATION, "glBeginQueryEXT: not enabled");
7972 return error::kNoError;
7973 }
7974 break;
7974 } 7975 }
7975 7976
7976 if (current_query_) { 7977 if (current_query_) {
7977 SetGLError( 7978 SetGLError(
7978 GL_INVALID_OPERATION, "glBeginQueryEXT: query already in progress"); 7979 GL_INVALID_OPERATION, "glBeginQueryEXT: query already in progress");
7979 return error::kNoError; 7980 return error::kNoError;
7980 } 7981 }
7981 7982
7982 if (client_id == 0) { 7983 if (client_id == 0) {
7983 SetGLError(GL_INVALID_OPERATION, "glBeginQueryEXT: id is 0"); 7984 SetGLError(GL_INVALID_OPERATION, "glBeginQueryEXT: id is 0");
7984 return error::kNoError; 7985 return error::kNoError;
7985 } 7986 }
7986 7987
7987 QueryManager::Query* query = query_manager_->GetQuery(client_id); 7988 QueryManager::Query* query = query_manager_->GetQuery(client_id);
7988 if (!query) { 7989 if (!query) {
7989 // Checks id was made by glGenQueries 7990 // Checks id was made by glGenQueries
7990 IdAllocatorInterface* id_allocator = 7991 IdAllocatorInterface* id_allocator =
7991 group_->GetIdAllocator(id_namespaces::kQueries); 7992 group_->GetIdAllocator(id_namespaces::kQueries);
7992 if (!id_allocator->InUse(client_id)) { 7993 if (!id_allocator->InUse(client_id)) {
7993 SetGLError(GL_INVALID_OPERATION, 7994 SetGLError(GL_INVALID_OPERATION,
7994 "glBeginQueryEXT: id not made by glGenQueriesEXT"); 7995 "glBeginQueryEXT: id not made by glGenQueriesEXT");
7995 return error::kNoError; 7996 return error::kNoError;
7996 } 7997 }
7997 // Makes object and assoicates with memory. 7998
7998 GLuint service_id = 0; 7999 query = query_manager_->CreateQuery(
7999 glGenQueriesARB(1, &service_id); 8000 target, client_id, sync_shm_id, sync_shm_offset);
8000 DCHECK_NE(0u, service_id);
8001 query = query_manager_->CreateQuery(client_id, service_id);
8002 } 8001 }
8003 8002
8004 QuerySync* sync = GetSharedMemoryAs<QuerySync*>( 8003 if (query->target() != target) {
8005 sync_shm_id, sync_shm_offset, sizeof(*sync));
8006 if (!sync) {
8007 DLOG(ERROR) << "Invalid shared memory referenced by query";
8008 return error::kOutOfBounds;
8009 }
8010
8011 if (!query->IsInitialized()) {
8012 query->Initialize(target, sync_shm_id, sync_shm_offset);
8013 } else if (query->target() != target) {
8014 SetGLError(GL_INVALID_OPERATION, "glBeginQueryEXT: target does not match"); 8004 SetGLError(GL_INVALID_OPERATION, "glBeginQueryEXT: target does not match");
8015 return error::kNoError; 8005 return error::kNoError;
8016 } else if (query->shm_id() != sync_shm_id || 8006 } else if (query->shm_id() != sync_shm_id ||
8017 query->shm_offset() != sync_shm_offset) { 8007 query->shm_offset() != sync_shm_offset) {
8018 DLOG(ERROR) << "Shared memory used by query not the same as before"; 8008 DLOG(ERROR) << "Shared memory used by query not the same as before";
8019 return error::kInvalidArguments; 8009 return error::kInvalidArguments;
8020 } 8010 }
8021 8011
8022 query_manager_->RemovePendingQuery(query); 8012 if (!query_manager_->BeginQuery(query)) {
8013 return error::kOutOfBounds;
8014 }
8023 8015
8024 glBeginQueryARB(target, query->service_id());
8025 current_query_ = query; 8016 current_query_ = query;
8026
8027 return error::kNoError; 8017 return error::kNoError;
8028 } 8018 }
8029 8019
8030 error::Error GLES2DecoderImpl::HandleEndQueryEXT( 8020 error::Error GLES2DecoderImpl::HandleEndQueryEXT(
8031 uint32 immediate_data_size, const gles2::EndQueryEXT& c) { 8021 uint32 immediate_data_size, const gles2::EndQueryEXT& c) {
8032 GLenum target = static_cast<GLenum>(c.target); 8022 GLenum target = static_cast<GLenum>(c.target);
8033 uint32 submit_count = static_cast<GLuint>(c.submit_count); 8023 uint32 submit_count = static_cast<GLuint>(c.submit_count);
8034 8024
8035 if (!current_query_) { 8025 if (!current_query_) {
8036 SetGLError(GL_INVALID_OPERATION, "glEndQueryEXT: No active query"); 8026 SetGLError(GL_INVALID_OPERATION, "glEndQueryEXT: No active query");
8037 return error::kNoError; 8027 return error::kNoError;
8038 } 8028 }
8039 if (current_query_->target() != target) { 8029 if (current_query_->target() != target) {
8040 SetGLError(GL_INVALID_OPERATION, 8030 SetGLError(GL_INVALID_OPERATION,
8041 "glEndQueryEXT: target does not match active query"); 8031 "glEndQueryEXT: target does not match active query");
8042 return error::kNoError; 8032 return error::kNoError;
8043 } 8033 }
8044 glEndQueryARB(target); 8034
8045 query_manager_->AddPendingQuery(current_query_, submit_count); 8035 if (!query_manager_->EndQuery(current_query_, submit_count)) {
8036 return error::kOutOfBounds;
8037 }
8038
8046 current_query_ = NULL; 8039 current_query_ = NULL;
8047
8048 return error::kNoError; 8040 return error::kNoError;
8049 } 8041 }
8050 8042
8051 error::Error GLES2DecoderImpl::HandleCreateStreamTextureCHROMIUM( 8043 error::Error GLES2DecoderImpl::HandleCreateStreamTextureCHROMIUM(
8052 uint32 immediate_data_size, 8044 uint32 immediate_data_size,
8053 const gles2::CreateStreamTextureCHROMIUM& c) { 8045 const gles2::CreateStreamTextureCHROMIUM& c) {
8054 if (!feature_info_->feature_flags().chromium_stream_texture) { 8046 if (!feature_info_->feature_flags().chromium_stream_texture) {
8055 SetGLError(GL_INVALID_OPERATION, 8047 SetGLError(GL_INVALID_OPERATION,
8056 "glOpenStreamTextureCHROMIUM: " 8048 "glOpenStreamTextureCHROMIUM: "
8057 "not supported."); 8049 "not supported.");
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
8367 } 8359 }
8368 } 8360 }
8369 8361
8370 // Include the auto-generated part of this file. We split this because it means 8362 // Include the auto-generated part of this file. We split this because it means
8371 // we can easily edit the non-auto generated parts right here in this file 8363 // we can easily edit the non-auto generated parts right here in this file
8372 // instead of having to edit some template or the code generator. 8364 // instead of having to edit some template or the code generator.
8373 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 8365 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
8374 8366
8375 } // namespace gles2 8367 } // namespace gles2
8376 } // namespace gpu 8368 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698